Merge pull request #2 from shocknet/bug/winston_logger

Fixes an issue where Winston attaches duplicate loggers
This commit is contained in:
Emad-salah 2019-12-01 14:37:02 +01:00 committed by GitHub
commit 9c2df34f0e

View file

@ -3,7 +3,10 @@
const winston = require("winston");
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.level = logLevel;
@ -18,5 +21,10 @@ module.exports = function(logFileName, logLevel) {
level: logLevel
});
winstonAttached.set(logFileName, winston)
return winston;
}
return winstonAttached.get(logFileName);
};