Fixing winston duplicate loggers issue
This commit is contained in:
parent
3ee39e63c5
commit
471e7e669e
1 changed files with 21 additions and 13 deletions
|
|
@ -3,7 +3,10 @@
|
||||||
const winston = require("winston");
|
const winston = require("winston");
|
||||||
require("winston-daily-rotate-file");
|
require("winston-daily-rotate-file");
|
||||||
|
|
||||||
module.exports = function(logFileName, logLevel) {
|
const winstonAttached = new Map();
|
||||||
|
|
||||||
|
module.exports = (logFileName, logLevel) => {
|
||||||
|
if (!winstonAttached.has(logFileName)) {
|
||||||
winston.cli();
|
winston.cli();
|
||||||
|
|
||||||
winston.level = logLevel;
|
winston.level = logLevel;
|
||||||
|
|
@ -18,5 +21,10 @@ module.exports = function(logFileName, logLevel) {
|
||||||
level: logLevel
|
level: logLevel
|
||||||
});
|
});
|
||||||
|
|
||||||
|
winstonAttached.set(logFileName, winston)
|
||||||
|
|
||||||
return winston;
|
return winston;
|
||||||
|
}
|
||||||
|
|
||||||
|
return winstonAttached.get(logFileName);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue