pino-sentry-stream
A pino stream to automatically pass errors to Sentry.
Installation
# npm
npm install @ips-hosting/pino-sentry-stream
# pnpm
pnpm add @ips-hosting/pino-sentry-stream
# yarn
yarn add @ips-hosting/pino-sentry-stream
The package is ESM-only and requires at least Node.js 20.
Usage
import { pinoSentryStream } from '@ips-hosting/pino-sentry-stream'
import * as Sentry from '@sentry/node'
import { pino } from 'pino'
const sentryStream = pinoSentryStream({ sentry: Sentry });
const pinoOpts = { };
const pinoLogger = pino(pinoOpts, sentryStream);
const streams = [
{
level: 'debug',
stream: process.env.NODE_ENV === 'production'
? process.stdout
: await import('pino-pretty').then((m) => m.default.default()),
},
{
level: 'info',
stream: sentryStream,
},
]
const pinoLogger = pino(pinoOpts, pino.multiStream(streams))