Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
bug #1354 Adding a flag to disable the Monolog error handler (skalpa)
Browse files Browse the repository at this point in the history
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  a53ce59 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
-------

8ecd0f0 Adding the monolog.use_error_handler parameter to configure whether the monolog ErrorHandler should be registered.
  • Loading branch information
fabpot committed May 17, 2016
2 parents 2b303b4 + 8ecd0f0 commit cb2f361
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions doc/providers/monolog.rst
Expand Up @@ -31,6 +31,14 @@ Parameters
* **monolog.exception.logger_filter** (optional): An anonymous function that
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
--------

Expand Down
5 changes: 4 additions & 1 deletion src/Silex/Provider/MonologServiceProvider.php
Expand Up @@ -106,11 +106,14 @@ public function register(Container $app)
$app['monolog.permission'] = null;
$app['monolog.exception.logger_filter'] = null;
$app['monolog.logfile'] = null;
$app['monolog.use_error_handler'] = !$app['debug'];
}

public function boot(Application $app)
{
ErrorHandler::register($app['monolog']);
if ($app['monolog.use_error_handler']) {
ErrorHandler::register($app['monolog']);
}

if (isset($app['monolog.listener'])) {
$app['dispatcher']->addSubscriber($app['monolog.listener']);
Expand Down

0 comments on commit cb2f361

Please sign in to comment.