Closed jeremyhalin closed 5 years ago
I designed this to "send error and exception to sentry automatically".
This plugin provides "ErrorHandlerMiddleware" and "LogEngine". These class collaborate to handle errors, put data to sentry.
ErrorHandlerMiddleware
into inner of Cake\Error\Middleware\ErrorHandlerMiddleware
.
LogEngine
for error-logging is overloaded
ErrorHandlerMiddleware
catch itErrorHandlerMiddleware
, LogEngine
write out the error to Sentry.Describing the flow in roughly as bellow.
namespace Connehito\CakeSentry;
use Cake\Error\Middleware\ErrorHandlerMiddleware as CakeErrorHandlerMiddleware;
use Cake\Log\Log;
use Error\Middleware\ErrorHandlerMiddleware;
use Log\Engine\SentryLog; /* LogEngine adapting to Sentry integration */
Can you check these points?
Thanks :)
Thanks for your great explanation.
I added this in config/bootstrap.php
Plugin::load('Connehito/CakeSentry', ['bootstrap' => true]);
I also added this in config/app.php
'Sentry' => [
'dsn' => '*****'
]
Non catched exceptions are well sent to Sentry, but caught exceptions aren't. Maybe it's normal behavior ? If it is, how can I send them to Sentry ?
Maybe it's normal behavior ?
Your expectation is right, it's different from my intention 😢 Please give me a little time for examine it in detail.
In advance of it, can you tell me some information?
I will reply back once I have more details.
Thanks.
I'm using CakePHP version 3.6
Here are my values for 'Error' in config.app.php
'Error' => [
'errorLevel' => E_ALL,
'exceptionRenderer' => ExceptionRenderer::class,
'skipLog' => [],
'log' => true,
'trace' => true,
],
Changing debug mode is not helping. Plus, when I set debug mode to false, I end up with Internal server error even if I catch the error. And error is not sent to Sentry at all.
Yes Sentry dns is well formatted since it's working without catching error.
Behavior is so weird, I'm still trying to figure it out ðŸ˜
@o0h Hi, did you have time to investigate issue ? :)
Hi @o0h I tried with branch 2.x. It's working for fatal exceptions, but not for notices, warnings and deprecated. Do you have an idea why ? I'm stuck here :(
@JeremyWinalist
Thanks to trying with 2.x branch 😄
Im concerned about Cake's config for Log
, Error
and PHP's error_handler
.
Can you show me them?
Log config handles what and how write log.
After bootstraping your application(e.g. AppController::initialize()
), how about your Log
config?
Please dump it (\Cake\Core\Configure::read('Log')
) and post here.
Error config handles what logs will be output with errorLevel
.
As with Log
config , please dump it here. (\Cake\Core\Configure::read('Error')
).
The third point is that php's error(without shutdown) is passed to this plugin's error-handler. You can get it like below.
$handler = set_error_handler(function(){});
$reflection = new ReflectionFunction($handler);
var_dump($reflection->getClosure());
Hi, Sorry I couldn't find why this was not working, it's working with basic integration of Sentry Unified SDK. So I'm not using your plugin anymore.
When trying the 2.x implementation, I am not getting any exception/error into Sentry as well. Checked every config but I do not know why it is not working. And like JeremyWinalist says, it works also just with Sentry Unified SDK ; this is strange :/
@o0h Will it be better if I open a new issue with full context ?
@jtraulle yes, can you open new issue and describe your case in detail?
Should I manually send catched exceptions to Sentry ? Why it's not sent automatically ? I want to know if it's normal behavior. Thanks.