Pass exceptions from the ExceptionListener to Monolog

This commit is contained in:
Matthias Pigulla 2013-05-10 11:17:13 +02:00 committed by Fabien Potencier
parent 7fc0768b48
commit 97bee2050c
2 changed files with 5 additions and 2 deletions

View File

@ -10,6 +10,8 @@ CHANGELOG
* deprecated `Symfony\Component\HttpKernel\Kernel::init()`` * deprecated `Symfony\Component\HttpKernel\Kernel::init()``
* added the possibility to specify an id an extra attributes to hinclude tags * added the possibility to specify an id an extra attributes to hinclude tags
* added the collect of data if a controller is a Closure in the Request collector * added the collect of data if a controller is a Closure in the Request collector
* pass exceptions from the ExceptionListener to the logger using the logging context to allow for more
detailed messages
2.2.0 2.2.0
----- -----

View File

@ -95,11 +95,12 @@ class ExceptionListener implements EventSubscriberInterface
protected function logException(\Exception $exception, $message, $original = true) protected function logException(\Exception $exception, $message, $original = true)
{ {
$isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500; $isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500;
$context = array('exception' => $exception);
if (null !== $this->logger) { if (null !== $this->logger) {
if ($isCritical) { if ($isCritical) {
$this->logger->critical($message); $this->logger->critical($message, $context);
} else { } else {
$this->logger->error($message); $this->logger->error($message, $context);
} }
} elseif (!$original || $isCritical) { } elseif (!$original || $isCritical) {
error_log($message); error_log($message);