Open Minyar2004 opened 4 years ago
winston
winston@2
winston@3
node -v
Problem with colorize() `
const winston = require('winston'); const customLogFormat = winston.format.printf(info => { return `${info.timestamp} [${info.module}] ${info.level}: ${info.message} `; }); const logger = module.exports = winston.createLogger({ level: 'silly', format: winston.format.combine( winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.errors({ stack: true }), winston.format.splat(), customLogFormat ), defaultMeta: { module: 'nomModule1' }, transports: [ new winston.transports.File({ filename: 'fileLog.log' }), new winston.transports.Console({ format: winston.format.colorize() }) ] }); logger.debug({ message: 'myMessage', a: 'a', b: 'b' });
`
Expected behavior: levels should be colored in console transport, but with the code above colorize() does not work and level are not colored...
It does work. You are giving the format property on global level. Give it inside the transport property like shown here https://github.com/winstonjs/winston#common-transport-options
Please tell us about your environment:
winston
version?winston@2
winston@3
node -v
outputs: v10What is the problem?
Problem with colorize() `
`
What do you expect to happen instead?
Expected behavior: levels should be colored in console transport, but with the code above colorize() does not work and level are not colored...
Other information