Skip to content
Snippets Groups Projects
Commit cb2f3617 authored by Fabien Potencier's avatar Fabien Potencier
Browse files

bug #1354 Adding a flag to disable the Monolog error handler (skalpa)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

Adding a flag to disable the Monolog error handler

The monolog error handler can now be disabled by setting the value of the new `monolog.use_error_handler` parameter to false (since it was added in  a53ce590 it was always enabled).

The error handler is disabled by default when the application `debug` parameter is set to true, to ensure it won't silence exceptions and/or errors.

Without the flag, an uncaught exception thrown during boot on `master` will just result in a white page, even when using `debug` and `error_reporting` (because the error handler calls `exit` after logging exceptions).

Commits
-------

8ecd0f01 Adding the monolog.use_error_handler parameter to configure whether the monolog ErrorHandler should be registered.
parents 2b303b4d 8ecd0f01
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,14 @@ Parameters ...@@ -31,6 +31,14 @@ Parameters
* **monolog.exception.logger_filter** (optional): An anonymous function that * **monolog.exception.logger_filter** (optional): An anonymous function that
filters which exceptions should be logged. filters which exceptions should be logged.
* **monolog.use_error_handler** (optional): Whether errors and uncaught exceptions
should be handled by the Monolog ``ErrorHandler`` class and added to the log.
By default the error handler is enabled unless the application ``debug`` parameter
is set to true.
Please note that enabling the error handler may silence some errors,
ignoring the PHP ``display_errors`` configuration setting.
Services Services
-------- --------
......
...@@ -106,11 +106,14 @@ class MonologServiceProvider implements ServiceProviderInterface, BootableProvid ...@@ -106,11 +106,14 @@ class MonologServiceProvider implements ServiceProviderInterface, BootableProvid
$app['monolog.permission'] = null; $app['monolog.permission'] = null;
$app['monolog.exception.logger_filter'] = null; $app['monolog.exception.logger_filter'] = null;
$app['monolog.logfile'] = null; $app['monolog.logfile'] = null;
$app['monolog.use_error_handler'] = !$app['debug'];
} }
public function boot(Application $app) public function boot(Application $app)
{ {
if ($app['monolog.use_error_handler']) {
ErrorHandler::register($app['monolog']); ErrorHandler::register($app['monolog']);
}
if (isset($app['monolog.listener'])) { if (isset($app['monolog.listener'])) {
$app['dispatcher']->addSubscriber($app['monolog.listener']); $app['dispatcher']->addSubscriber($app['monolog.listener']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment