Skip to content

[Feature Request] Allow to disable console logging or allow to provide custom logger #53

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

Open
doctorrokter opened this issue Aug 18, 2021 · 5 comments

Comments

@doctorrokter
Copy link

Hey!

In my Nest project I have a custom Logger implementation which is optimized for SumoLogic format. In case of errors I use my logger to print logs and @ntegral/nestjs-sentry to send error to Sentry. The problem is that lib by default also prints logs in default Nest format because of SentryService extends ConsoleLogger.

I would to have an ability to disable that default behaviour in order to keep my logs clean and without duplication.

Or, as another solution, would be great to have an ability to provide own custom logger to @ntegral/nestjs-sentry.

What do you think about that?

@holm
Copy link
Contributor

holm commented Aug 20, 2021

I was just looking to solve the same problem. It would be nice to be able to separate these concerns.

@doctorrokter
Copy link
Author

doctorrokter commented Aug 20, 2021

@holm for now I have a temp workaround in my project:

  • manually edited source code in /node_modules and simply disabled super.log, super.error etc calls inside SentryService.
  • created a patch using npx patch-package @ntegral/nestjs-sentry
  • added a post-install hook into package.json file which will run patch every time.

Definetely worth a try to fork the repo, get rid of inheritance and do a PR.

Rather than extending ConsoleLogger class would be better to implement LoggerService interface instead. In that case we still will have NestJS-like logging API.
And in addition we could provide custom logger class (or instance) during SentryModule initialization to let SentryService write custom logs if we want.

@doctorrokter
Copy link
Author

@ntegral @holm created PR for that FR, hope it looking not bad:

#54

@holm
Copy link
Contributor

holm commented Aug 23, 2021

Awesome. Thanks for doing that. Added a few comments on the PR, just from my perspective, although of course this is not my library at all :)

@foxted
Copy link

foxted commented Feb 3, 2022

Looks like by using the instance directly, it doesn't log into the console. So using: this.sentry.instance().captureMessage() instead of this.sentry.log().

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

3 participants