Skip to content

Commit

Permalink
Update myLogger.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NebzHB authored May 25, 2024
1 parent 7f5dc8d commit 7424b15
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/myLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 7424b15

Please sign in to comment.