Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
♻️ Refactor sentry levels
Browse files Browse the repository at this point in the history
Related: #28
  • Loading branch information
smolijar committed Nov 25, 2019
1 parent 35199d0 commit 1b2fa12
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ const reportToSentry = (obj: any) => {
return captureException(error);
};

const PINO_TO_SENTRY: { [key: number]: Severity } = {
10: Severity.Debug,
20: Severity.Debug,
30: Severity.Info,
40: Severity.Warning,
50: Severity.Error,
60: Severity.Critical,
};

class SentryTransformStream extends Transform {
// tslint:disable-next-line:function-name
public _transform(chunk: any, _encoding: string, callback: TransformCallback) {
const PINO_TO_SENTRY: { [key: number]: Severity } = {
10: Severity.Debug,
20: Severity.Debug,
30: Severity.Info,
40: Severity.Warning,
50: Severity.Error,
60: Severity.Critical,
};
const obj = JSON.parse(chunk);
withScope(scope => {
scope.setLevel(PINO_TO_SENTRY[obj.level]);
Expand Down

0 comments on commit 1b2fa12

Please sign in to comment.