-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Implement custom logger logic for errors (#632)
Logger.error will now send the error message to sentry
- Loading branch information
1 parent
5b90288
commit 4351261
Showing
5 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Module } from '@nestjs/common' | ||
import { MyLogger } from './logger' | ||
|
||
@Module({ | ||
providers: [MyLogger], | ||
exports: [MyLogger], | ||
}) | ||
export class LoggerModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ConsoleLogger, Injectable } from '@nestjs/common' | ||
import { InjectSentry, SentryService } from '@ntegral/nestjs-sentry' | ||
|
||
@Injectable() | ||
export class MyLogger extends ConsoleLogger { | ||
constructor(@InjectSentry() private readonly client: SentryService) { | ||
super() | ||
} | ||
|
||
error(message: any, stack?: string, context?: string) { | ||
// add your tailored logic here | ||
|
||
this.client.instance().captureMessage(message, 'error') | ||
super.error(message, stack, context) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters