From 7424b153c23ee90343dd1f357bf167f90dbe249d Mon Sep 17 00:00:00 2001 From: Nebz <28622481+NebzHB@users.noreply.github.com> Date: Sat, 25 May 2024 10:03:21 +0200 Subject: [PATCH] Update myLogger.js --- lib/myLogger.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/myLogger.js b/lib/myLogger.js index af85d27..58a5a9e 100644 --- a/lib/myLogger.js +++ b/lib/myLogger.js @@ -41,7 +41,7 @@ var loggerCache = {}; function myLogger(debugLevel,logger,creationLogPath) { this.logger = logger; this.debugLevel= debugLevel; - this.allowedLevel = ['debug','info','warning','error','conf']; + this.allowedLevel = ['debug','info','warning','error','conf','|debug','|info','|warning','|error']; this.creationLogPath = creationLogPath; this.creationPassed = false; fs.writeFileSync(this.creationLogPath+startLog, '['+(new Date().toISOString())+"] ---Début du log de création---\n"); @@ -50,7 +50,11 @@ function myLogger(debugLevel,logger,creationLogPath) { if(msg) { if(this.allowedLevel.indexOf(level.toLowerCase()) !== -1) { - msg="["+level.toUpperCase()+"] "+msg; + if(level.charAt(0) === '|') { + msg="| ["+level.toUpperCase().replace("|","")+"] "+msg; + } else { + msg="["+level.toUpperCase()+"] "+msg; + } } else { msg=level.toLowerCase()+' '+msg; } @@ -67,10 +71,10 @@ function myLogger(debugLevel,logger,creationLogPath) { } if(this.debugLevel == debug.NO) {msg=null;return;} - if(this.debugLevel > debug.DEBUG && level == "debug") {msg=null;return;} - if(this.debugLevel > debug.INFO && level == "info") {msg=null;return;} - if(this.debugLevel > debug.WARNING && level == "warning") {msg=null;return;} - if(this.debugLevel > debug.ERROR && level == "error") {msg=null;return;} + if(this.debugLevel > debug.DEBUG && (level == "debug" || level == "|debug")) {msg=null;return;} + if(this.debugLevel > debug.INFO && (level == "info" || level == "|info")) {msg=null;return;} + if(this.debugLevel > debug.WARNING && (level == "warning" || level == "|warning")) {msg=null;return;} + if(this.debugLevel > debug.ERROR && (level == "error" || level == "|error")) {msg=null;return;} this.logger(msg); msg=null;