1
0
mirror of https://git.stamm.me/OpenServer/NodeLogging.git synced 2024-09-28 02:17:07 +00:00

adding option to add custom colors

This commit is contained in:
Fabian Stamm 2017-09-16 19:21:22 +02:00
parent 3562efdd6f
commit feae07bcb0

View File

@ -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") {