fix(core): update
This commit is contained in:
parent
11c88ce533
commit
62f18b16b1
1825
package-lock.json
generated
1825
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,16 +12,17 @@
|
||||
"build": "(tsbuild --web)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^1.0.78",
|
||||
"@gitzone/tstest": "^1.0.44",
|
||||
"@gitzone/tsbuild": "^2.1.26",
|
||||
"@gitzone/tsbundle": "^1.0.84",
|
||||
"@gitzone/tstest": "^1.0.57",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@types/node": "^14.11.2",
|
||||
"@types/node": "^16.7.1",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^4.0.20",
|
||||
"@pushrocks/smartlog-interfaces": "^2.0.22",
|
||||
"@pushrocks/smartrequest": "^1.1.52"
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as qenv from '@pushrocks/qenv';
|
||||
|
||||
export {
|
||||
export {
|
||||
qenv
|
||||
}
|
56
ts/index.ts
56
ts/index.ts
@ -2,30 +2,46 @@ import * as plugins from './logtail.plugins';
|
||||
|
||||
export class LogTailAccount {
|
||||
private token: string;
|
||||
|
||||
private timedAggregator = new plugins.lik.TimedAggregtor<plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>>({
|
||||
aggregationIntervalInMillis: 2000,
|
||||
functionForAggregation: async (logPackagesArg) => {
|
||||
const requestBody = [];
|
||||
let lastTimestamp: number = 0;
|
||||
for (const logPackageArg of logPackagesArg) {
|
||||
if (logPackageArg.timestamp === lastTimestamp) {
|
||||
logPackageArg.timestamp++;
|
||||
}
|
||||
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', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${this.token}`
|
||||
},
|
||||
requestBody,
|
||||
keepAlive: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
constructor(logTailToken: string) {
|
||||
this.token = logTailToken;
|
||||
}
|
||||
|
||||
async log(logPackage: plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>) {
|
||||
const requestBody = {
|
||||
dt: new Date(logPackage.timestamp).toISOString(),
|
||||
level: logPackage.level,
|
||||
message: `${logPackage.context?.containerName}: ${logPackage.message}`,
|
||||
originalMessage: logPackage.message,
|
||||
context: logPackage.context,
|
||||
correlation: logPackage.correlation,
|
||||
data: logPackage.data,
|
||||
type: logPackage.type
|
||||
};
|
||||
const response = await plugins.smartrequest.request('https://in.logtail.com', {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${this.token}`
|
||||
},
|
||||
requestBody,
|
||||
keepAlive: true,
|
||||
});
|
||||
async log(logPackageArg: plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>) {
|
||||
this.timedAggregator.add(logPackageArg);
|
||||
}
|
||||
|
||||
public get smartlogDestination(): plugins.smartlogInterfaces.ILogDestination {
|
||||
|
@ -1,7 +1,9 @@
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
|
||||
export {
|
||||
lik,
|
||||
smartlogInterfaces,
|
||||
smartrequest,
|
||||
}
|
Loading…
Reference in New Issue
Block a user