question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No colorize support in 3.0?

See original GitHub issue

It doesn’t seem to be working.

logger = winston.createLogger({
  level: 'verbose',
  transports: [
    new WinstonDailyRotateFile({
      filename: './app-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      maxFiles: '3d',
      format: winston.format.colorize(),
    }),
  ],
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
mattberthercommented, Mar 23, 2018

winston@3 does not set formats on the individual transports. Try this instead:

logger = winston.createLogger({
  level: 'verbose',
  format: winston.format.combine(
    winston.format.colorize({message: true}),
    winston.format.simple()
  ),
  transports: [
    new WinstonDailyRotateFile({
      filename: './app-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      maxFiles: '3d'
    }),
  ],
});
2reactions
indexzerocommented, Mar 23, 2018

@mattberther interesting. From an intention perspective, these two code blocks should be equivalent in winston@3. If they are not then it may be a bug:

single transport, format on logger

logger = winston.createLogger({
  level: 'verbose',
  format: winston.format.combine(
    winston.format.colorize({message: true}),
    winston.format.simple()
  ),
  transports: [
    new WinstonDailyRotateFile({
      filename: './app-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      maxFiles: '3d'
    }),
  ],
});

single transport, format on transport

logger = winston.createLogger({
  level: 'verbose',
  transports: [
    new WinstonDailyRotateFile({
      filename: './app-%DATE%.log',
      datePattern: 'YYYY-MM-DD',
      maxFiles: '3d',
      format: winston.format.combine(
        winston.format.colorize({message: true}),
        winston.format.simple()
      )
    }),
  ],
});

If you have a chance to dig in the relevant code is:

  1. format set on TransportStream instances
  2. format consumed in TransportStream.prototype._write
Read more comments on GitHub >

github_iconTop Results From Across the Web

Winston 3.0 colorize whole output on console - Stack Overflow
I want the whole output of the messages from the winston logger to appear in color, not just the label and the message,...
Read more >
colorize is not available for download in the curr... - Page 3
My colourize neural filter worked fine yesterday,but today it's asking me to download it. It of course will not download now,and just stays...
Read more >
Colors | Chart.js
Charts support three color options: for geometric elements, you can change background and border colors;; for textual elements, ...
Read more >
CSS Color Module Level 3 - W3C
This color is set to #000 if the current display driver does not support a solid gray color. Highlight: Item(s) selected in a...
Read more >
NO_COLOR: disabling ANSI color output in various Unix ...
Software Description Date/Version Supported alogview Android logcat Filter 2018‑10‑31 Ammonite Scala Scripting 2017‑07‑03 / 1.0.0 Ansible IT automation system 2021‑04‑26 / 2.11.0
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found