From c7ab71aea673773be550fc5f1cb65d4256fad4d1 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Mon, 29 Oct 2018 09:05:30 +0100 Subject: [PATCH] Refactoring --- package.json | 3 ++- src/index.ts | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2f1f1b8..b3f758a 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "@hibas123/nodelogging", - "version": "1.3.19", + "version": "1.3.10", "description": "", "main": "out/index.js", "types": "out/index.d.ts", "scripts": { + "prepublish": "tsc", "build": "tsc", "watch": "tsc --watch", "test": "node out/test.js", diff --git a/src/index.ts b/src/index.ts index 1a4d0fe..d3c1786 100644 --- a/src/index.ts +++ b/src/index.ts @@ -281,9 +281,9 @@ export class LoggingBase { let message_lines = mb.split("\n").map(line => prefix + line); if (this.config.console_out) { - let prefix = ""; - if (this.config.name) prefix = `[${this.config.name}]`; - message_lines.forEach(line => console.log(consoleLogFormat + prefix + line + Colors.Reset)); + let name = ""; + if (this.config.name) name = `[${this.config.name}]`; + message_lines.forEach(line => console.log(consoleLogFormat + name + line + Colors.Reset)); } let m = message_lines.join("\n"); @@ -303,7 +303,7 @@ export class LoggingBase { if (this.logFile) { this.logFile.write(data); } - this.events.emit("message", { type: type, message: data.toString("utf8") }); + this.events.emit("message", { type: type, message: m, module: this.config.name }); } }