lordphnx / cake-sentry-errorlogger
A CakePHP ErrorLogger implementation that logs to Sentry
1.0.3
2023-01-16 14:01 UTC
Requires
- php: ^8.0|^7.2
- cakephp/cakephp: ^4.4
- sentry/sentry: ^3.2
Requires (Dev)
- guzzlehttp/guzzle: 7.4.5
- php-http/guzzle7-adapter: 1.0.0
- phpunit/phpunit: ^9.5
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