Skip to content

colorize (only with console transport) doest not work with custom format #1774

@Minyar2004

Description

@Minyar2004

Please tell us about your environment:

  • winston version?
    • winston@2
    • [ x] winston@3
  • node -v outputs: v10
  • Operating System? (Windows, macOS, or Linux) windows 7
  • Language? (all | TypeScript X.X | ES6/7 | ES5 | Dart) javascript

What is the problem?

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'
});

`

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions