8000 merged branch webfactory/pass-excpetions-to-monolog (PR #8000) · symfony/symfony@31138f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31138f4

Browse files
committed
merged branch webfactory/pass-excpetions-to-monolog (PR #8000)
This PR was squashed before being merged into the master branch (closes #8000). Discussion ---------- Pass exceptions from the ExceptionListener to Monolog | Q | A | ------------- | --- | Bug fix? | rather yes | New feature? | rather no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7973, #7976 | License | MIT | Doc PR | n/a Pass exceptions caught by the ExceptionListener to Monolog, using the log message context. As of Monolog 1.5, exceptions passed that way will at least be logged with the line they were thrown in, also including any previous exceptions. Getting full stack traces (as suggested in #7976) becomes a possible change at the Monolog level (see Seldaek/monolog#192) or users can add their own Monolog Formatter for that. This PR is based on master. I'd be glad to provide similar ones for 2.1/2.2 if you'd pick them. Due to recent changes in the ExceptionListener I don't think a single patch on the older branches can easily be pulled to master anyway. Commits ------- 97bee20 Pass exceptions from the ExceptionListener to Monolog
2 parents 1003c39 + 97bee20 commit 31138f4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Symfony/Component/HttpKernel/CHANGELOG.md

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

1416
2.2.0
1517
-----

src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ public static function getSubscribedEvents()
9595
protected function logException(\Exception $exception, $message, $original = true)
9696
{
9797
$isCritical = !$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500;
98+
$context = array('exception' => $exception);
9899
if (null !== $this->logger) {
99100
if ($isCritical) {
100-
$this->logger->critical($message);
101+
$this->logger->critical($message, $context);
101102
} else {
102-
$this->logger->error($message);
103+
$this->logger->error($message, $context);
103104
}
104105
} elseif (!$original || $isCritical) {
105106
error_log($message);

0 commit comments

Comments
 (0)
0