Skip to content

Commit

Permalink
Log deprecated (symfony) errors optionally
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored Mar 31, 2017
1 parent afd4704 commit c2bb740
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public function boot()

/** @var Application $app */
$app = $this->app;

// Set custom error handler
if ($app['config']->get('debugbar.error_handler' , false)) {
set_error_handler([$this, 'handleError']);
}

$this->selectStorage($debugbar);

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

/**
* Handle silenced errors
*
* @param $level
* @param $message
* @param string $file
* @param int $line
* @param array $context
* @throws \ErrorException
*/
public function handleError($level, $message, $file = '', $line = 0, $context = [])
{
if (error_reporting() & $level) {
throw new \ErrorException($message, 0, $level, $file, $line);
} else {
$this->addMessage($message, 'deprecation');
}
}

/**
* Starts a measure
*
Expand Down

0 comments on commit c2bb740

Please sign in to comment.