gpt4 book ai didi

javascript - winston 记录器名称

转载 作者:数据小太阳 更新时间:2023-10-29 05:13:14 27 4
gpt4 key购买 nike

Flatiron 的日志记录库 Winston 非常有用,但我不知道如何为记录器分配名称。我期待与其他日志库类似的输出,例如:

 [<date>] [<log level>] <logger name> - <the message>

是否可以这样配置Winston?

谢谢。

最佳答案

创建日志传输时,您可以提供一个label 参数,该参数将添加到日志级别和日志消息之间的日志输出中。例如:

var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
colorize: true,
prettyPrint: true,
timestamp: true,
label: 'CustomLabel'
})
]
});

这将导致以下输出:

2016-09-06T12:16:17.335Z - info: [CustomLabel] hello

关于javascript - winston 记录器名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12238199/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com