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

Commit

Permalink
Adding the monolog.use_error_handler parameter to configure whether t…
Browse files Browse the repository at this point in the history
…he monolog ErrorHandler should be registered.

The error handler is now disabled by default when the application debug parameter is set to true, to ensure it won't silence exceptions and/or errors.
  • Loading branch information
skalpa committed May 16, 2016
1 parent 4643214 commit 8ecd0f0
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 8ecd0f0

Please sign in to comment.