monolog-bundle icon indicating copy to clipboard operation
monolog-bundle copied to clipboard

Add Sentry `BreadcrumbHandler` support

Open HypeMC opened this issue 6 months ago • 0 comments

Adds support for https://github.com/getsentry/sentry-php/pull/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:

https://github.com/symfony/monolog-bundle/blob/ed0e4a287282971d110fd8c99d9ac391559a43ce/DependencyInjection/MonologExtension.php#L179-L183

HypeMC avatar Aug 09 '24 11:08 HypeMC