At the moment I have this code:
const logger = new winston.Logger();
logger.add(winston.transports.Console, {
level: environment === 'development' ? 'silly' : 'info',
colorize: true,
prettyPrint: true
});
But I want to be able to write
const logger = new winston.Logger({transports: [customConsoleTransport]});
How can I create customConsoleTransport
?
You can create a new instance of the winston.transports.Console
as it's just a constructor function. You'll end up with something like this:
const customConsoleTransport = new winston.transports.Console({
level: environment === 'development' ? 'silly' : 'info',
colorize: true,
prettyPrint: true
});
const logger = new winston.Logger({transports: [customConsoleTransport]});