fix(core): update

This commit is contained in:
Philipp Kunz 2021-08-24 22:14:20 +02:00
parent 11c88ce533
commit 62f18b16b1
5 changed files with 891 additions and 1003 deletions

1825
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,16 +12,17 @@
"build": "(tsbuild --web)" "build": "(tsbuild --web)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.26",
"@gitzone/tsbundle": "^1.0.78", "@gitzone/tsbundle": "^1.0.84",
"@gitzone/tstest": "^1.0.44", "@gitzone/tstest": "^1.0.57",
"@pushrocks/qenv": "^4.0.10", "@pushrocks/qenv": "^4.0.10",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.11.2", "@types/node": "^16.7.1",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^4.0.20",
"@pushrocks/smartlog-interfaces": "^2.0.22", "@pushrocks/smartlog-interfaces": "^2.0.22",
"@pushrocks/smartrequest": "^1.1.52" "@pushrocks/smartrequest": "^1.1.52"
}, },

View File

@ -2,21 +2,28 @@ import * as plugins from './logtail.plugins';
export class LogTailAccount { export class LogTailAccount {
private token: string; private token: string;
constructor(logTailToken: string) {
this.token = logTailToken;
}
async log(logPackage: plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>) { private timedAggregator = new plugins.lik.TimedAggregtor<plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>>({
const requestBody = { aggregationIntervalInMillis: 2000,
dt: new Date(logPackage.timestamp).toISOString(), functionForAggregation: async (logPackagesArg) => {
level: logPackage.level, const requestBody = [];
message: `${logPackage.context?.containerName}: ${logPackage.message}`, let lastTimestamp: number = 0;
originalMessage: logPackage.message, for (const logPackageArg of logPackagesArg) {
context: logPackage.context, if (logPackageArg.timestamp === lastTimestamp) {
correlation: logPackage.correlation, logPackageArg.timestamp++;
data: logPackage.data, }
type: logPackage.type lastTimestamp = logPackageArg.timestamp;
}; requestBody.push({
dt: new Date(logPackageArg.timestamp).toISOString(),
level: logPackageArg.level,
message: `${logPackageArg.context?.containerName}: ${logPackageArg.message}`,
originalMessage: logPackageArg.message,
context: logPackageArg.context,
correlation: logPackageArg.correlation,
data: logPackageArg.data,
type: logPackageArg.type
});
}
const response = await plugins.smartrequest.request('https://in.logtail.com', { const response = await plugins.smartrequest.request('https://in.logtail.com', {
method: 'post', method: 'post',
headers: { headers: {
@ -27,6 +34,15 @@ export class LogTailAccount {
keepAlive: true, keepAlive: true,
}); });
} }
});
constructor(logTailToken: string) {
this.token = logTailToken;
}
async log(logPackageArg: plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>) {
this.timedAggregator.add(logPackageArg);
}
public get smartlogDestination(): plugins.smartlogInterfaces.ILogDestination { public get smartlogDestination(): plugins.smartlogInterfaces.ILogDestination {
return { return {

View File

@ -1,7 +1,9 @@
import * as lik from '@pushrocks/lik';
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces'; import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
export { export {
lik,
smartlogInterfaces, smartlogInterfaces,
smartrequest, smartrequest,
} }