Skip to content

Commit c2bb740

Browse files
authored
Log deprecated (symfony) errors optionally
1 parent afd4704 commit c2bb740

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/LaravelDebugbar.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public function boot()
124124

125125
/** @var Application $app */
126126
$app = $this->app;
127+
128+
// Set custom error handler
129+
if ($app['config']->get('debugbar.error_handler' , false)) {
130+
set_error_handler([$this, 'handleError']);
131+
}
127132

128133
$this->selectStorage($debugbar);
129134

@@ -449,6 +454,25 @@ public function shouldCollect($name, $default = false)
449454
return $this->app['config']->get('debugbar.collectors.' . $name, $default);
450455
}
451456

457+
/**
458+
* Handle silenced errors
459+
*
460+
* @param $level
461+
* @param $message
462+
* @param string $file
463+
* @param int $line
464+
* @param array $context
465+
* @throws \ErrorException
466+
*/
467+
public function handleError($level, $message, $file = '', $line = 0, $context = [])
468+
{
469+
if (error_reporting() & $level) {
470+
throw new \ErrorException($message, 0, $level, $file, $line);
471+
} else {
472+
$this->addMessage($message, 'deprecation');
473+
}
474+
}
475+
452476
/**
453477
* Starts a measure
454478
*

0 commit comments

Comments
 (0)