Skip to content

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jun 20, 2025

ref #15952

resolves #16622

This PR adds the ability to send logs to sentry via a pino transport.

Usage

import pino from 'pino';

const logger = pino({
  transport: {
    target: '@sentry/pino-transport',
    options: {
      // Optional: filter which log levels to send to Sentry
      logLevels: ['error', 'fatal'], // defaults to all levels
    },
  },
});

// Now your logs will be sent to Sentry
logger.info('This is an info message');
logger.error('This is an error message');

Options

logLevels

Type: Array<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'>

Default: ['trace', 'debug', 'info', 'warn', 'error', 'fatal'] (all levels)

Use this option to filter which log levels should be sent to Sentry.

const transport = pino.transport({
  target: '@sentry/pino-transport',
  options: {
    logLevels: ['warn', 'error', 'fatal'], // Only send warnings and above
  },
});

Next

I need to write some integration tests - this is being tracked by #16624

@AbhiPrasad AbhiPrasad self-assigned this Jun 20, 2025
@AbhiPrasad AbhiPrasad force-pushed the abhi-pino-logs-impl branch from 4661a26 to ad39866 Compare June 20, 2025 15:54
| error | 50 | error |
| fatal | 60 | fatal |

### Custom Levels Support
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still undecided about this behaviour.

See https://getpino.io/#/docs/api?id=opt-customlevels for details about pino custom levels.

What does everyone think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the level ranges?

Currently, you're "cutting" it in the middle of the range (or are those already the Pino level cuts?). How about cutting it at the point where the level changes? Like this:

  • 0-19trace
  • 20-29debug
  • 30-39info
  • 40-49warn
  • 50-59error
  • 60+fatal

But I am not quite sure how pino works here 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit hard to map, your call!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about cutting it at the point where the level changes

I think that feels better, just tried it out in my test app. Feels easier to explain to users as well.

@AbhiPrasad AbhiPrasad marked this pull request as ready for review June 20, 2025 15:58
@AbhiPrasad AbhiPrasad requested review from a team, Lms24 and s1gr1d and removed request for a team June 20, 2025 15:58
| error | 50 | error |
| fatal | 60 | fatal |

### Custom Levels Support
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the level ranges?

Currently, you're "cutting" it in the middle of the range (or are those already the Pino level cuts?). How about cutting it at the point where the level changes? Like this:

  • 0-19trace
  • 20-29debug
  • 30-39info
  • 40-49warn
  • 50-59error
  • 60+fatal

But I am not quite sure how pino works here 🤔

| error | 50 | error |
| fatal | 60 | fatal |

### Custom Levels Support
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit hard to map, your call!

@AbhiPrasad AbhiPrasad force-pushed the abhi-pino-logs-impl branch from 398fe71 to 4f3435a Compare June 24, 2025 15:22
@AbhiPrasad AbhiPrasad force-pushed the abhi-pino-logs-impl branch from 4f3435a to 57434de Compare June 24, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement logs pino support via pino-abstract-transport

3 participants