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

Commit e55bb5a

Browse files
author
Michal Vlasák
committed
⚡️ Call originalWrite before Sentry handler
1 parent 324e25a commit e55bb5a

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/sentry.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ export const extendSentry = (logger: Cosmas, options: { sentry: string | true; s
3333
// unfortunately, this is the only place in pino, we can hook onto, where we can be sure all
3434
// the hooks, formatters and serializers are already applied
3535
logger[streamSym].write = function (s: string) {
36+
originalWrite.call(this, s);
3637
const obj = JSON.parse(s);
37-
if (obj.level >= (options.sentryLevel || levels.warn)) {
38-
withScope((scope) => {
39-
scope.setLevel(PINO_TO_SENTRY[obj.level]);
40-
scope.setExtras(obj);
41-
reportToSentry(obj);
42-
});
43-
}
44-
return originalWrite.call(this, s);
38+
if (obj.level < (options.sentryLevel || levels.warn)) return;
39+
withScope((scope) => {
40+
scope.setLevel(PINO_TO_SENTRY[obj.level]);
41+
scope.setExtras(obj);
42+
reportToSentry(obj);
43+
});
4544
};
4645
};

0 commit comments

Comments
 (0)