lordphnx/cake-sentry-errorlogger

A CakePHP ErrorLogger implementation that logs to Sentry

1.0.3 2023-01-16 14:01 UTC

This package is auto-updated.

Last update: 2024-10-23 22:36:27 UTC


README

Since CakePHP 4.4, the error handlers have been updated to ErrorTrap and ExceptionTrap. Both use Cake\Error\ErrorLoggerInterface, making packages such as connehito/CakeSentry less interesting.

This repository provides a Sentry implementation of the Cake\Error\ErrorLoggerInterface

Configure

In your config/bootstrap.php

/*
 * Register application error and exception handlers.
 */
$errorConfig = Cake\Core\Configure::consume('Error');

//if sentry, log to SentryErrorLogger
if (Configure::read('Sentry.dsn', false)) {
	$errorConfig = [
		...$errorConfig,
		'logger' => SentryErrorLogger::class
	];
}
(new ErrorTrap($errorConfig))->register();
(new ExceptionTrap($errorConfig))->register();

In your config/app.php

you can either use the Sentry key

[
    'Sentry' => [
        'dsn' => '......'        
    ] 

or Error.Sentry

[
    /*...*/
    'Error' => [
        /*....*/
        'Sentry' => [
            'dsn' => '......'        
        ]   
    ]

Setting options

Global


Per Error/Exception