Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enumerate level and message before meta #7

Open
aseemk opened this issue Feb 27, 2013 · 0 comments
Open

Enumerate level and message before meta #7

aseemk opened this issue Feb 27, 2013 · 0 comments

Comments

@aseemk
Copy link

aseemk commented Feb 27, 2013

Great work on winston-loggly. We've been using it for a while, and it generally works great, but we had one request.

Currently, when you look at the logs on Loggly, the level and message are always last, following all the other metadata. This isn't great: the level is probably the most important high-order information worth processing, and the message gives context to the rest of the metadata.

E.g.

req=33609775, method=GET, url=/users, currentUser=, error=Error: socket hang up
  at createHangUpError (http.js:1124:15)
  at CleartextStream.socketCloseListener (http.js:1173:23)
  at CleartextStream.emit (events.js:88:20)
  at Array.<anonymous> (tls.js:792:22)
  at Array.1 (/app/www/node_modules/nodetime/lib/core/proxy.js:131:20)
  at EventEmitter._tickCallback (node.js:190:38)
  ...
 , level=error, message=Unhandled error!

I suspected this was because the JSON getting sent to Loggly lists the level and message as the last keys, when they could/should be the first. And indeed, that seems to be it:

https://github.com/indexzero/winston-loggly/blob/v0.6.0/lib/winston-loggly.js#L103-L107

  var self = this,
      message = winston.clone(meta || {});

  message.level = level;
  message.message = msg;

This would be solved by creating an object with level and message first, then extending it with meta, instead of cloning meta first and adding level and message second.

I would be happy to submit this as a pull request, but I wasn't sure how you preferred the implementation: Winston unfortunately doesn't expose an extend utility like it does clone, so is that something that belongs there, or here?

Thanks again for the great work, and for the consideration!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant