[HttpKernel] tweaked logging in the exception listener

When there is no logger, we should only log critical errors (this is
more sensible than the current behavior).
This commit is contained in:
Fabien Potencier 2012-12-28 18:06:25 +01:00
parent 1a6c9b3143
commit 0a4250122f

View File

@ -94,13 +94,14 @@ class ExceptionListener implements EventSubscriberInterface
*/
protected function logException(\Exception $exception, $message, $original = true)
{
$isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500;
if (null !== $this->logger) {
if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
if ($isCritical) {
$this->logger->crit($message);
} else {
$this->logger->err($message);
}
} else {
} elseif (!$original || $isCritical) {
error_log($message);
}
}