You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If meta argument of a log method (destructured from splat rest parameters) is an Error-like object (e.g. having a message property), the original msg argument is concatenated with meta.message without any spaces, making the output unreadable.
Working example:
const{ format, transports, createLogger }=require('winston')constconsoleTransport=newtransports.Console({// General settingslevel: 'silly',format: format.combine(format.simple())})constlogger=createLogger({level: 'silly',transports: [consoleTransport]})logger.error('Description of other error',newError('Other error'))
Example output:
error: Description of other errorOther error {"stack":"Error: Other error\n at Object.<anonymous> (.../src/test.js:16:44)\n at Module._compile (module.js:643:30)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Function.Module.runMain (module.js:684:10)\n at startup (bootstrap_node.js:187:16)\n at bootstrap_node.js:608:3"}
What do you expect to happen instead?
The logged message is separated from the meta Error object message:
error: Description of other error Other error {"stack":"Error: Other error\n at Object.<anonymous> (.../src/test.js:16:44)\n at Module._compile (module.js:643:30)\n at Object.Module._extensions..js (module.js:654:10)\n at Module.load (module.js:556:32)\n at tryModuleLoad (module.js:499:12)\n at Function.Module._load (module.js:491:3)\n at Function.Module.runMain (module.js:684:10)\n at startup (bootstrap_node.js:187:16)\n at bootstrap_node.js:608:3"}
Please tell us about your environment:
winston
version?winston@2
winston@3
node -v
outputs: v8.9.4What is the problem?
If
meta
argument of alog
method (destructured fromsplat
rest parameters) is an Error-like object (e.g. having amessage
property), the originalmsg
argument is concatenated withmeta.message
without any spaces, making the output unreadable.Working example:
Example output:
What do you expect to happen instead?
The logged message is separated from the meta Error object message:
Other information
The problem is really within the
log
method:Simply concatenating like that will definitely produce strange results. Having something like that will solve the problem:
The best thing would be to not concatenate messages at all, having separate
stack
andmeta
object itself on theinfo
.The text was updated successfully, but these errors were encountered: