Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ips-hosting/pino-sentry-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ips-hosting/pino-sentry-stream

A pino stream to automatically pass errors to Sentry.

  • 3.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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'
// ...

/**
 * Available options:
 * sentry (required): The Sentry SDK
 * severityMap (optional): Maps pino levels to sentry severities. See index.ts for an example and the default mapping.
 * callback (optional): (obj: { log: PinoLog; scope: Sentry.Scope; severity: Sentry.Severity }) => void | false
 * 	Called for every pino log message. Use to assign custom properties to the sentry scope. Return false to prevent that message from being sent to sentry.
 */
const sentryStream = pinoSentryStream({ sentry: Sentry });

// With pino
// All messages will directly go to Sentry.
// They won't be passed to stdout so you don't see them in your terminal.
const pinoOpts = { /* ... */ };
const pinoLogger = pino(pinoOpts, sentryStream);

// Using pino.multistream
// You can send log messages to multiple destination streams.
// In this example, log messages are sent both to stdout and Sentry, while being prettified in development.
const streams = [
	// Log everything to stdout in production, prettify in dev environments.
		{
			level: 'debug',
			stream: process.env.NODE_ENV === 'production'
				? process.stdout
				: await import('pino-pretty').then((m) => m.default.default()),
		},
		// In addition to logging to stdout, send everything starting from level info to sentry.
		{
			level: 'info',
			stream: sentryStream,
		},
]

const pinoLogger = pino(pinoOpts, pino.multiStream(streams))

FAQs

Package last updated on 05 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc