Skip to content

Commit

Permalink
add changeLevel function, conf level and lowercase level
Browse files Browse the repository at this point in the history
  • Loading branch information
NebzHB authored Jan 22, 2024
1 parent 30516c7 commit 58a9b78
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/myLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ var loggerCache = {};
function myLogger(debugLevel,logger,creationLogPath) {
this.logger = logger;
this.debugLevel= debugLevel;
this.allowedLevel = ['debug','info','warn','error'];
this.allowedLevel = ['debug','info','warn','error','conf'];
this.creationLogPath = creationLogPath;
this.creationPassed = false;
fs.writeFileSync(this.creationLogPath+startLog, '['+(new Date().toISOString())+"] ---Début du log de création---\n");
this.log = function(level, msg) {
level=level.toLowerCase();
msg = util.format.apply(util, Array.prototype.slice.call(arguments, 1));

if(msg) {
Expand Down Expand Up @@ -75,6 +76,9 @@ function myLogger(debugLevel,logger,creationLogPath) {
this.logger(msg);
msg=null;
};
this.changeLevel = (newDebugLevel) => {
this.debugLevel=newDebugLevel;
};
}

myLogger.createMyLogger = function(debugLevel,logger,creationLogPath) {
Expand All @@ -84,6 +88,7 @@ myLogger.createMyLogger = function(debugLevel,logger,creationLogPath) {
var ml = new myLogger(debugLevel,logger,creationLogPath);
var log = ml.log.bind(ml);
log.log = ml.log;
log.changeLevel = ml.changeLevel.bind(ml);
loggerCache[debugLevel] = log;
}
return loggerCache[debugLevel];
Expand Down

0 comments on commit 58a9b78

Please sign in to comment.