winstonjs / winston-loggly

A Loggly transport for winston
http://github.com/indexzero/winston-loggly
MIT License
85 stars 110 forks source link

Error instances are recorded as an empty object #37

Open tomhaigh opened 8 years ago

tomhaigh commented 8 years ago

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"}

This doesn't seem related to https://github.com/winstonjs/winston/issues/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 commented 8 years ago

We are running into this issue too

indexzero commented 8 years ago

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

tomhaigh commented 8 years ago

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 commented 8 years ago

Misread your original post. Reopening.

joseSantacruz commented 8 years ago

any advance on this issue??