Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Error instances are recorded as an empty object #37

Open
tomhaigh opened this issue Dec 3, 2015 · 5 comments
Open

Error instances are recorded as an empty object #37

tomhaigh opened this issue Dec 3, 2015 · 5 comments

Comments

@tomhaigh
Copy link

tomhaigh commented Dec 3, 2015

When logging a meta value which contains an error, none of the properties are written, and the log message is lost.
e.g. winston.error("error", new Error("test"))

output in loggly:
{"level":"error"}

  • The error properties (message and stack) are not written because node-loggly doesn't write them to the JSON string (they are non-enumerable).
  • The log message is lost because the meta parameter, if supplied, forms the base message object appended to and passed to loggly. For Errors this already contains the message property as a getter which (per the above) isn't written to JSON.

This doesn't seem related to winstonjs/winston#280 which I initially thought was the cause - updating to the latest version of Winston does not solve it.

I think a fix requires more than just fixing the JSON-encoding of Error objects - that would still result in conflict between the two message properties when logging Errors (the error message and the log message). It could be nicer if the meta parameter was written to the loggly message as a meta property within the JSON, but this would be a change to existing behaviour.

@ClarenceL
Copy link

We are running into this issue too

@indexzero
Copy link
Member

This is not a bug in winston-loggly. Could you please open this on winston or comment on the appropriate issue there?

@tomhaigh
Copy link
Author

Please can you explain why this isn't a bug in winston-loggly?

From what I can tell, some of the problematic behaviour is due to winston-loggly using the cloned meta parameter as the base message object that is eventually passed to node-loggly. If this meta parameter is an instance of Error, then the message property is a getter, but winston-loggly attempts to overwrite this with the actual log message string, which doesn't work, and so you get the empty log message problem.

@indexzero
Copy link
Member

Misread your original post. Reopening.

@indexzero indexzero reopened this Jan 21, 2016
@joseSantacruz
Copy link

any advance on this issue??

OtterCode pushed a commit to OtterCode/winston-loggly that referenced this issue Jun 28, 2018
Update package.json dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants