winston version?_winston@2[email protected] node -v outputs: v10.1.0Using a custom format that uppercases the level with colorize will cause the log line output to have lots of empty space before it (clears my console so probably 50+ empty lines).
Ideally the upper cased level would be colorized. Worst case is it would not be colorized.
Here is the code:
const custom = format.printf((info) => {
return `${info.level.toUpperCase()}: ${info.message}`;
});
const log = createLogger({
format: format.combine(
format.colorize(),
custom
),
transports: [new transports.Console()]
});
It works fine if I do .toLowerCase()
info.level is mutable. It is changed from 'error' or 'info' to a string that includes ANSI color codes. e.g.:
// level = '\u001b[32minfo\u001b[39m'
info: wut
// level = '\u001b[32minfo\u001b[39m'
info: ok
// level = '\u001b[31merror\u001b[39m'
error: sure
... not 100% the right approach to add this feature. The underlying colorize code is in logform
@kingjerod this should be fixed by https://github.com/winstonjs/logform/pull/34. Once that lands you can solve this by:
const custom = format.printf((info) => {
return `${info.level}: ${info.message}`;
});
const log = createLogger({
format: format.combine(
format(info => {
info.level = info.level.toUpperCase()
return info;
})(),
format.colorize(),
custom
),
transports: [new transports.Console()]
});
Most helpful comment
@kingjerod this should be fixed by https://github.com/winstonjs/logform/pull/34. Once that lands you can solve this by: