From 74e6bc7a3c11cafba7d6ec150f96d74b3912e928 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sun, 4 Nov 2018 18:21:18 +0100 Subject: [PATCH] fix(core): update --- package-lock.json | 6 +++--- package.json | 2 +- ts/smartlog.classes.smartlog.ts | 21 ++++++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6109e2..e9e09ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -168,9 +168,9 @@ } }, "@pushrocks/smartlog-interfaces": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-2.0.1.tgz", - "integrity": "sha512-c9onE52z/5fGX5uEvaI/rXbcC6n7PkLrNjehRM+6JsK7HIbdAzrgY1PGrqUfW0a03hSe03mFcggORID+fQI4tA==" + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-2.0.2.tgz", + "integrity": "sha512-kJNQ/6kfljgtwebhoiD8WtRWfdVhOoE1nr8FoUJLlOjLphU8SPa42Hg6/yPkSTaGxWwDhk6PkMJl64O7HNjRUQ==" }, "@pushrocks/smartpath": { "version": "4.0.1", diff --git a/package.json b/package.json index defd27a..8befcc3 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,6 @@ "tslint-config-prettier": "^1.15.0" }, "dependencies": { - "@pushrocks/smartlog-interfaces": "^2.0.1" + "@pushrocks/smartlog-interfaces": "^2.0.2" } } diff --git a/ts/smartlog.classes.smartlog.ts b/ts/smartlog.classes.smartlog.ts index 2e718b7..ed08d48 100644 --- a/ts/smartlog.classes.smartlog.ts +++ b/ts/smartlog.classes.smartlog.ts @@ -1,7 +1,7 @@ import * as plugins from './smartlog.plugins'; // interfaces -import { TLogType, TEnvironment, ILogContext, TLogLevel, TRuntime, ILogDestination } from '@pushrocks/smartlog-interfaces'; +import { TLogType, TEnvironment, ILogContext, TLogLevel, TRuntime, ILogDestination, ILogPackage } from '@pushrocks/smartlog-interfaces'; import { LogRouter } from './smartlog.classes.logrouter'; @@ -43,20 +43,26 @@ export class Smartlog { // log functions // ============= /** - * log stuff - * @param logLevelArg - * @param logMessageArg + * main log method + * @param logLevelArg - the log level + * @param logMessageArg - the log message + * @param logDataArg - any additional log data */ - public log(logLevelArg: TLogLevel, logMessageArg: string) { + public log(logLevelArg: TLogLevel, logMessageArg: string, logDataArg?: any) { if (this.consoleEnabled) { console.log(`LOG: ${logLevelArg}: ${logMessageArg}`); } - this.logRouter.routeLog({ + const logPackage: ILogPackage = { + timestamp: Date.now(), type: 'log', context: this.logContext, level: logLevelArg, message: logMessageArg - }); + }; + if(logDataArg) { + logPackage.data = logDataArg; + } + this.logRouter.routeLog(logPackage); } public increment(logLevelArg: TLogLevel, logMessageArg) { @@ -64,6 +70,7 @@ export class Smartlog { console.log(`INCREMENT: ${logLevelArg}: ${logMessageArg}`); } this.logRouter.routeLog({ + timestamp: Date.now(), type: 'increment', context: this.logContext, level: logLevelArg,