【发布时间】:2018-01-11 17:40:42
【问题描述】:
使用 Bunyan 时,我所有的日志级别都使用相同的青色,如下所示:
这是我们正在使用的 Bunyan 配置:
const bunyan = require('bunyan');
module.exports = bunyan.createLogger({name: 'cdt-api-server'});
我的问题是 - 如何让 Bunyan 使用红色或洋红色来记录错误信息/堆栈跟踪?问题是红色字符中的“ERROR”不足以引起我的注意 - 我希望整个堆栈都用红色或洋红色。
这是班扬自述文件: https://github.com/trentm/node-bunyan
我只看到提到过一次“颜色”。
我们可以这样做吗?
const bunyan = require('bunyan');
module.exports = bunyan.createLogger({
name: 'cdt-api-server',
streams: [
{
level: 'trace',
stream: process.stdout,
color: 'black',
},
{
level: 'debug',
stream: process.stdout,
color: 'blue',
},
{
level: 'info',
stream: process.stdout,
color: 'cyan',
},
{
level: 'error',
path: process.stderr,
color: 'red'
},
{
level: 'warn',
path: process.stderr,
color: 'magenta'
}
]
});
【问题讨论】:
标签: node.js logging error-logging bunyan