Merge pull request #2 from shocknet/bug/winston_logger
Fixes an issue where Winston attaches duplicate loggers
This commit is contained in:
commit
9c2df34f0e
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