Can Winston logging be selectively disabled when executing unit tests of a node module?
Ideally, I\'d like to have logging for informational and debug purposes when the
Here's my setup:
const { createLogger, format, transports, config } = require("winston");
let level, silent;
switch (process.env.NODE_ENV) {
case "production":
level = "warning";
silent = false;
break;
case "test":
level = "emerg";
silent = true;
break;
default:
level = "debug";
silent = false;
break;
}
const options = {
console: {
level,
silent,
handleExceptions: true,
format: format.combine(
format.colorize(),
format.splat(),
format.printf(
info => `${new Date().toISOString()} ${info.level}: ${info.message}`,
),
),
},
};
const logger = createLogger({
levels: config.syslog.levels,
transports: [new transports.Console(options.console)],
exitOnError: false,
});
module.exports = logger;