Skip to content

dfr-exnaton/pino-nextjs-sentry-transport

 
 

Repository files navigation

Pino Sentry transport

NPM npm version GitHub Workflow Status

This module provides a 'transport' for pino that sends errors to Sentry.

Install

npm i @sentry/nextjs pino-nextjs-sentry-transport

usage

import pino from "pino";

const logger = pino({
  transport: {
    target: "pino-nextjs-sentry-transport",
    options: {
      withLogRecord: true, // default false - send the log record to sentry as a context.(if its more then 8Kb Sentry will throw an error)
      tags: ["id"], // sentry tags to add to the event, uses lodash.get to get the value from the log record
      context: ["hostname"], // sentry context to add to the event, uses lodash.get to get the value from the log record,
      minLevel: 40, // which level to send to sentry
      skipSentryInitialization: false, // default true - if you want that the transport to initialize Sentry. In this case, you also need to provide the sentry init object:
      //       sentry: {
      //  dsn: "https://<key>:<secret>@sentry.io/<project>",
      // additional options for sentry
      // },
    },
  },
});

if log contain error, it will send to sentry using captureException if not it will use captureMessage.

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • TypeScript 84.8%
  • JavaScript 15.2%