Closed robertrossmann closed 9 years ago
@Alaneor That's bunyan's behavior. The object should be before the message, not after.
I agree that it's totally confusing behavior, though. There's probably already an issue/discussion about this at trentm/node-bunyan.
> var bunyan = require('bunyan')
undefined
> var log = bunyan.createLogger({name: 'foo'})
undefined
> log.info('after', { foo: 'bar'})
{"name":"foo","hostname":"dlee-mac.local","pid":51461,"level":30,"msg":"after { foo: 'bar' }","time":"2015-10-22T21:29:50.292Z","v":0}
undefined
> log.info({foo: 'bar'}, 'before')
{"name":"foo","hostname":"dlee-mac.local","pid":51461,"level":30,"foo":"bar","msg":"before","time":"2015-10-22T21:30:04.135Z","v":0}
undefined
Hi, thanks for the tip! It seems, though, that the behaviour is still the same even if I use the object as first argument:
sails.log.info({ user: { prop: true } }, 'user data')
{"name":"sails","hostname":"localhost.local","pid":11115,"level":30,"msg":"Object { user: Object { prop: true } } user data","time":"2015-10-22T21:33:30.492Z","v":0}
Oops. I tried to 'be nice' and use the log config hooks provided by Sails, but it appears that they squash all the arguments into a string before passing off to the logger.
Should be fixed in v2.1.4
Awesome, thank you!
When I try to log an object with some properties, the object is stringified and appended to the log message, instead of the object's properties becoming part of the log data. Here is an example to illustrate this:
According to Bunyan logs, the object data should be merged into the log object itself, not stringified. Is there something I need to do to enable that behaviour? I am not providing any custom configuration options.
Thanks for help!