fix(core): update
This commit is contained in:
38
ts/index.ts
Normal file
38
ts/index.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import * as plugins from './logtail.plugins';
|
||||
|
||||
export class LogTailAccount {
|
||||
private token: string;
|
||||
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.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,
|
||||
});
|
||||
console.log(response.statusCode);
|
||||
}
|
||||
|
||||
public get smartlogDestination(): plugins.smartlogInterfaces.ILogDestination {
|
||||
return {
|
||||
handleLog: async (logPackage: plugins.smartlogInterfaces.ILogPackage) => {
|
||||
await this.log(logPackage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
ts/logtail.plugins.ts
Normal file
7
ts/logtail.plugins.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import * as smartlogInterfaces from '@pushrocks/smartlog-interfaces';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
|
||||
export {
|
||||
smartlogInterfaces,
|
||||
smartrequest,
|
||||
}
|
Reference in New Issue
Block a user