nestjs-sentry icon indicating copy to clipboard operation
nestjs-sentry copied to clipboard

Logger implementation should log non-error messages as breadcrumbs.

Open empz opened this issue 4 years ago • 6 comments

The default behaviour of any Sentry SDK is to capture non-error logs as breadcrumbs and send them all together as soon as an error happens.

I see SentryService extends Logger but the methods log, debug, verbose and warn are actually calling captureMessage and I think they should be storing that log as a breadcrumb in the current scope.

This way, replacing the default NestJS logger with this library would be a no-brainer and we'd get proper log messages before an exception on Sentry.

empz avatar Jun 08 '21 15:06 empz

Will add this to the backlog thanks

ntegral avatar Jun 08 '21 19:06 ntegral

Would you accept a PR? I've already forked and implemented it.

empz avatar Jun 09 '21 08:06 empz

Thanks.. I'll review it @empz

ntegral avatar Jun 14 '21 11:06 ntegral

This feature as been added in the latest version 3.0.7

ntegral avatar Jan 05 '22 20:01 ntegral

This feature as been added in the latest version 3.0.7

I see you've added a parameter to SentryService to log a non-error message as breadcrumb. Still this is not optimal as I'm using the SentryService as the default logger and I need to go and add that extra argument on each log call.... I understand you don't want to set this as the default (although it makes way more sense this way) to avoid breaking changes, but wouldn't be a global config much easier to set up?

Somewhere in the forRoot config we should have the option to say "store non-error messages as breadcrumbs".

dg-eparizzi avatar Mar 08 '22 10:03 dg-eparizzi

@dg-eparizzi Created a PR here, but I did it in the forked version from travelerdev. I think this would fit your use case. I can also create a PR here if relevant

bawahakim avatar Mar 06 '24 05:03 bawahakim