midway icon indicating copy to clipboard operation
midway copied to clipboard

日志输出格式化了2次

Open ghostoy opened this issue 2 years ago • 6 comments

  • Node Version: 18.5.0
  • Midway Version(Decorator/Core): 3.3.6
  • Component Name/Version: @midwayjs/[email protected]
  • Platform:
  • Mini Showcase Repository:
logger.info('%s', '%Y-%m-%d')
// 应该输出
// %Y-%m-%d
// 实际输出
// %Y-%m-NaN

在@midwayjs/logger中使用util.format%s部分格式化一遍,然后到了winston里又被splat格式化了一遍,导致日志中输出错误。

ghostoy avatar Jul 18 '22 05:07 ghostoy

@midwayjs/logger上也提交了相同的issue (midwayjs/logger#62)

ghostoy avatar Jul 18 '22 05:07 ghostoy

日志里要打 % 格式的内容?

czy88840616 avatar Jul 18 '22 05:07 czy88840616

日志里要打 % 格式的内容?

是的

ghostoy avatar Jul 18 '22 06:07 ghostoy

@czy88840616 你们会修复吗,我提交了PR (midwayjs/logger#63)

ghostoy avatar Jul 26 '22 03:07 ghostoy

需要用 % 在后续日志中继续解析? 会不会有安全问题(好比 log4j 那种)

waitingsong avatar Jul 26 '22 03:07 waitingsong

@ghostoy 我把单测修了下,可以先 rebase 下master

czy88840616 avatar Jul 27 '22 16:07 czy88840616