fix(core): update
This commit is contained in:
@ -6,6 +6,11 @@ import { TLogLevel, TEnvironment, ILogPackage } from '@pushrocks/smartlog-interf
|
||||
* the constructor options for LogdnaMessage
|
||||
*/
|
||||
export interface ILogdnaMessageContructorOptions {
|
||||
/**
|
||||
* a timestamp for then the log message was created
|
||||
*/
|
||||
timestamp: number;
|
||||
|
||||
/**
|
||||
* the hostname where the log message was created
|
||||
*/
|
||||
@ -62,6 +67,7 @@ export class LogdnaMessage {
|
||||
*/
|
||||
static fromSmartLogPackage(smartlogPackageArg: ILogPackage): LogdnaMessage {
|
||||
return new LogdnaMessage({
|
||||
timestamp: smartlogPackageArg.timestamp,
|
||||
line: smartlogPackageArg.message,
|
||||
meta: {
|
||||
...smartlogPackageArg.context,
|
||||
|
@ -37,21 +37,23 @@ export class LogdnaAccount {
|
||||
// let construct the request uri
|
||||
const requestUrlWithParams = `${this.baseUrl}?hostname=${euc(lm.options.hostname)}&mac=${euc(
|
||||
lm.options.mac
|
||||
)}&ip=1${euc(lm.options.ip)}&now=${Date.now()}`;
|
||||
)}&ip=1${euc(lm.options.ip)}&now=${Date.now()}&tags=${euc(
|
||||
(() => {
|
||||
return lm.options.tags.reduce((reduced, newItem) => {
|
||||
return `${reduced},${newItem}`;
|
||||
});
|
||||
})()
|
||||
)}`;
|
||||
|
||||
const requestBodyObject = {
|
||||
lines: [
|
||||
{
|
||||
timestamp: lm.options.timestamp,
|
||||
line: lm.options.line,
|
||||
app: lm.options.app,
|
||||
level: lm.options.level,
|
||||
env: lm.options.env,
|
||||
meta: lm.options.meta,
|
||||
tags: (() => {
|
||||
return lm.options.tags.reduce((reduced, newItem) => {
|
||||
return `${reduced},${newItem}`;
|
||||
});
|
||||
})()
|
||||
meta: lm.options.meta
|
||||
}
|
||||
]
|
||||
};
|
||||
@ -71,16 +73,16 @@ export class LogdnaAccount {
|
||||
/**
|
||||
* convenience function for smartlog
|
||||
*/
|
||||
public async sendSmartlogPackage (smartlogPackageArg: ILogPackage) {
|
||||
public async sendSmartlogPackage(smartlogPackageArg: ILogPackage) {
|
||||
this.sendLogDnaMessage(LogdnaMessage.fromSmartLogPackage(smartlogPackageArg));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a smartlog compatible log destination
|
||||
*/
|
||||
public get smartlogDestination (): ILogDestination {
|
||||
public get smartlogDestination(): ILogDestination {
|
||||
return {
|
||||
handleLog: (logPackageArg) => {
|
||||
handleLog: logPackageArg => {
|
||||
this.sendSmartlogPackage(logPackageArg);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user