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)"
|
"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"
|
||||||
},
|
},
|
||||||
|
56
ts/index.ts
56
ts/index.ts
@ -2,30 +2,46 @@ import * as plugins from './logtail.plugins';
|
|||||||
|
|
||||||
export class LogTailAccount {
|
export class LogTailAccount {
|
||||||
private token: string;
|
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) {
|
constructor(logTailToken: string) {
|
||||||
this.token = logTailToken;
|
this.token = logTailToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
async log(logPackage: plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>) {
|
async log(logPackageArg: plugins.smartlogInterfaces.ILogPackage<{[key: string]: any}>) {
|
||||||
const requestBody = {
|
this.timedAggregator.add(logPackageArg);
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get smartlogDestination(): plugins.smartlogInterfaces.ILogDestination {
|
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 smartlogInterfaces from '@pushrocks/smartlog-interfaces';
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
lik,
|
||||||
smartlogInterfaces,
|
smartlogInterfaces,
|
||||||
smartrequest,
|
smartrequest,
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user