From 0fd6efac9976088165e87248ceb01007a39c5a50 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Sat, 4 Nov 2017 23:58:00 +0100 Subject: [PATCH] Removing conole Color symbols in Logfiles --- package.json | 2 +- src/index.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a3ac1b4..6b9ad9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "logger-perfcloud", - "version": "1.0.8", + "version": "1.0.9", "description": "", "main": "out/index.js", "types": "out/index.d.ts", diff --git a/src/index.ts b/src/index.ts index e07fd7b..251f07f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -114,6 +114,14 @@ export class Logging { } var m = "[" + LoggingTypes[type] + "][" + _getCallerFile() + "][" + new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '') + "]: " + mb; + if (this.stdout) console.log(consoleLogFormat + m + Reset); + + let index = m.indexOf("\x1b"); + while (index >= 0) { + m = m.substring(0, index) + m.substring(index + 4, m.length); + index = m.indexOf("\x1b"); + } + if (this.logFileLocation) { if (!this.fileStream || !this.errorStream) { await Logging.initializeFile(); @@ -121,7 +129,6 @@ export class Logging { Logging.writeMessageToFile(m, type === LoggingTypes.Error); } Logging.events.emit("message", { type: type, message: mb }); - if (this.stdout) console.log(consoleLogFormat + m + Reset); } private static writeMessageToFile(message: string, error?: boolean) {