You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(node): Allow selective tracking of pino loggers (#17933)
- Closes#17904
This PR adds two methods to the `pinoIntegration` export. `trackLogger`
and `untrackLogger`;
`untrackLogger` can be used to disable capturing from a specific logger.
You can also disable `autoInstrument` and only track specific loggers:
```ts
import * as Sentry from '@sentry/node';
import pino from 'pino';
Sentry.init({
dsn: '__DSN__',
integrations: [Sentry.pinoIntegration({ autoInstrument: false })],
});
const logger = pino({});
Sentry.pinoIntegration.trackLogger(logger);
logger.debug('This will be captured!');
```
* Marks a Pino logger to be tracked by the Pino integration.
187
+
*
188
+
* @param logger A Pino logger instance.
189
+
*/
190
+
trackLogger(logger: unknown): void;
191
+
/**
192
+
* Marks a Pino logger to be ignored by the Pino integration.
193
+
*
194
+
* @param logger A Pino logger instance.
195
+
*/
196
+
untrackLogger(logger: unknown): void;
197
+
}
198
+
199
+
/**
200
+
* Integration for Pino logging library.
201
+
* Captures Pino logs as Sentry logs and optionally captures some log levels as events.
202
+
*
203
+
* By default, all Pino loggers will be captured. To ignore a specific logger, use `pinoIntegration.untrackLogger(logger)`.
204
+
*
205
+
* If you disable automatic instrumentation with `autoInstrument: false`, you can mark specific loggers to be tracked with `pinoIntegration.trackLogger(logger)`.
206
+
*
207
+
* Requires Pino >=v8.0.0 and Node >=20.6.0 or >=18.19.0
0 commit comments