Skip to content

Conversation

HypeMC
Copy link
Member

@HypeMC HypeMC commented Aug 9, 2024

Adds support for getsentry/sentry-php#1199.

monolog:
  handlers:
    sentry:
      type: sentry
      hub_id: Sentry\State\HubInterface
      level: !php/const Monolog\Logger::ERROR
    sentry_breadcrumb:
      type: sentry_breadcrumb
      sentry_handler: sentry
      level: !php/const Monolog\Logger::INFO

# or if you don't have Sentry bundle installed

monolog:
  handlers:
    sentry:
      type: sentry
      dsn: "https://[email protected]/1"
      level: !php/const Monolog\Logger::ERROR
    sentry_breadcrumb:
      type: sentry_breadcrumb
      sentry_handler: sentry
      level: !php/const Monolog\Logger::INFO

Initially, I considered using the existing handler option instead of introducing the new sentry_handler option. However, I decided against it because the PSR logger doesn't get auto-enabled when the handler option is used:

if (null === $handler['process_psr_3_messages']['enabled']) {
$handler['process_psr_3_messages']['enabled'] = !isset($handler['handler']) && !$handler['members'];
}

@HypeMC HypeMC force-pushed the add-sentry-breadcrumbhandler-support branch from 7d533ee to 10c35d5 Compare August 11, 2024 20:27
@HypeMC HypeMC force-pushed the add-sentry-breadcrumbhandler-support branch 5 times, most recently from ce023ed to 133cd1c Compare August 30, 2025 21:46
@HypeMC HypeMC force-pushed the add-sentry-breadcrumbhandler-support branch from 133cd1c to c469777 Compare September 5, 2025 22:37
->thenInvalid('You can not use both a hub_id and a client_id in a Sentry handler')
->end()
->validate()
->ifTrue(function ($v) { return 'sentry_breadcrumb' === $v['type'] && empty($v['sentry_handler']); })
Copy link
Member

Choose a reason for hiding this comment

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

I think $v['sentry_handler'] is always defined, and null by default.

Suggested change
->ifTrue(function ($v) { return 'sentry_breadcrumb' === $v['type'] && empty($v['sentry_handler']); })
->ifTrue(function ($v) { return 'sentry_breadcrumb' === $v['type'] && !$v['sentry_handler']; })

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you're right, fixed.

@HypeMC HypeMC force-pushed the add-sentry-breadcrumbhandler-support branch from c469777 to 7572a98 Compare September 7, 2025 23:18
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.

2 participants