bigfork/silverstripe-sentry-handler

A standalone Monolog handler for Sentry

Maintainers

๐Ÿ‘ kinglozzer

Package info

github.com/bigfork/silverstripe-sentry-handler

Type:silverstripe-vendormodule

pkg:composer/bigfork/silverstripe-sentry-handler

Statistics

Installs: 8โ€‰260

Dependents: 1

Suggesters: 1

Stars: 1

Open Issues: 0

3.0.0 2025-08-20 14:33 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause f0d198638826a6a5cc1a40a63cecd8a66ad94ff4

  • Loz Calver <lozcalver.woop@bigfork.co.uk>

This package is auto-updated.

Last update: 2026-06-20 16:17:04 UTC


README

Minimalistic module designed to make it easier to obtain a Sentry\Monolog\Handler instance for consumption by Monolog loggers.

โš ๏ธ If you simply want errors logged to Sentry, youโ€™re probably better off using the phptek/sentry module instead of this one.

This module differs in that its goal is to make it easier to use Sentry with multiple Logger instances that have different configuration options.

Installation

composer require bigfork/silverstripe-sentry-handler

Configuration

Simply add a SENTRY_DSN environment variable containing the DSN provided in the Sentry UI.

Customisation

By default, this module will push an additional handler to the default Psr\Log\LoggerInterface.errorhandler service which will push errors to Sentry (similar to the phptek/sentry module). You can disable this behaviour with:

SilverStripe\Core\Injector\Injector:
 Psr\Log\LoggerInterface.errorhandler:
 calls:
 pushSentryErrorHandler: null

You can configure another Sentry\Monolog\Handler instance by using the SentryHubFactory class to help build out your Sentry hub to be passed the handler:

SilverStripe\Core\Injector\Injector:
 # Build a custom Hub object which holds our Sentry config, will be passed to the handler below
 MySentryHub:
 factory: 'Bigfork\SilverstripeSentryHandler\SentryHubFactory'
 constructor:
 options:
 dsn: '`SENTRY_DSN`'
 tags:
 - 'sometag'
 default_integrations: false
 integrations:
 - '%$MyCustomIntegrationClass'

 # Build Sentry\Monolog\Handler instance, to be pushed to logger above
 MySentryMonologHandler:
 class: 'Sentry\Monolog\Handler'
 constructor:
 - '%$MySentryHub' # Our custom hub object defined above
 - 'info' # Send anything logged at "info" level or above

 # Finally, build the logger service - access with Injector::inst()->get('MyMonologLogger')
 MyMonologLogger:
 type: 'singleton'
 class: 'Monolog\Logger'
 constructor:
 - 'myloggername'
 calls:
 pushSentryHandler: [ pushHandler, ['%$MySentryMonologHandler'] ] # Handler instance defined above