feat(logger): 更新日志格式,添加 JSON 格式化并注释掉简单文本格式化
All checks were successful
/ release (push) Successful in 27s

This commit is contained in:
zhaoyingbo 2025-03-18 10:37:05 +00:00
parent 6ab0d5baae
commit c963202226

View File

@ -40,12 +40,13 @@ if (isProd) {
const formatList = [
format.simple(), // 简单文本格式化
format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
format.printf(({ level, message, timestamp, requestId }) => {
const singleLineMessage = isProd
? message.replace(/\n/g, " ") // 将换行符替换为空格
: message
return `${timestamp} [${level}]${requestId ? ` [RequestId: ${requestId}]` : ""}: ${singleLineMessage}`
}),
format.json(), // json格式化
// format.printf(({ level, message, timestamp, requestId }) => {
// const singleLineMessage = isProd
// ? message.replace(/\n/g, " ") // 将换行符替换为空格
// : message
// return `${timestamp} [${level}]${requestId ? ` [RequestId: ${requestId}]` : ""}: ${singleLineMessage}`
// }),
]
// 开发环境下输出彩色日志