Closed Almad closed 10 years ago
A quick clarification on behalf of @Almad - we're using winston to log errors like:
log.error('Hi, I am a bad error', new Error())
However, winston-sentry
sees that the log level is error and automatically creates a new Error() object and logs that. The log function could be just a little more clever and check if the incoming parameters are instanceof Error
. In my mind, there are 3 valid signatures:
log.error('Hi, I am a bad error')
automatically creates a new error objectlog.error('Hi, I am a bad error', new Error())
uses provided error objectlog.error(new Error('Hi, I am a bad error'))
uses provided error objectI'll look into this when I can (cannot say when though), but I thank @zzen for the explanation and the suggestion. Anyway, AFAIK winston is currently unmantained, so it might be a good idea not to rely on this at least for new projects. I currently do not have time to check out what the situation is.
This issue is was resolved in #9, but I still need to publish a newer version to NPM (waiting for @guzru). I suggest to test your code on the master branch and let me know if it works for you. All the use cases you mentioned above are supported as follows:
log.error('Hi, I am a bad error')
: does not created a new error object. message logged as islog.error('Hi, I am a bad error', new Error())
: concatenates the provided message with the message of the Error object. Stack trace supportedlog.error(new Error('Hi, I am a bad error'))
: uses message in Error object. Stack trace supportedVersion 0.0.6 now supports stack traces as described above
Currently, there is no way to provide error objects in a way that will preserve stack traces in sentry.
For pinpointing production errors, that would be great (and is supported by raven-node).