From feae07bcb020f94b6a900f542a9e14475cfbca53 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Sat, 16 Sep 2017 19:21:22 +0200 Subject: [PATCH] adding option to add custom colors --- src/index.ts | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3449cfd..740368e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,6 +57,10 @@ export class Logging { Logging.message(LoggingTypes.Log, message); } + static logWithCustomColors(type: LoggingTypes, colors: string, ...message: any[]) { + Logging.message(type, message, colors); + } + static error(error: Error | string) { if (typeof error === "string") { Logging.errorMessage(error); @@ -74,21 +78,25 @@ export class Logging { Logging.message(LoggingTypes.Error, message); } - private static async message(type: LoggingTypes, message: any[] | string) { + private static async message(type: LoggingTypes, message: any[] | string, customColors?: string) { var consoleLogFormat = Reset; - switch (type) { - case LoggingTypes.Log: - //m += FgWhite + BgBlack; - break; - case LoggingTypes.Error: - consoleLogFormat += FgRed;//FgWhite + BgRed + FgWhite; - break; - case LoggingTypes.Debug: - consoleLogFormat += FgCyan; - break; - case LoggingTypes.Warning: - consoleLogFormat += FgYellow; - break; + if (!customColors) { + switch (type) { + case LoggingTypes.Log: + //m += FgWhite + BgBlack; + break; + case LoggingTypes.Error: + consoleLogFormat += FgRed;//FgWhite + BgRed + FgWhite; + break; + case LoggingTypes.Debug: + consoleLogFormat += FgCyan; + break; + case LoggingTypes.Warning: + consoleLogFormat += FgYellow; + break; + } + } else { + consoleLogFormat += customColors; } var mb = ""; if (typeof message === "string") {