Skip to content

Commit e983a0d

Browse files
author
Christoph Lehmann
committed
Do not log twice to console
1 parent 4ab8455 commit e983a0d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Classes/Handler/DebugExceptionHandler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Neos\Flow\Log\ThrowableStorageInterface;
77
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
88
use Networkteam\SentryClient\ErrorHandler;
9+
use Networkteam\Util\Log\ThrowableStorage\ConsoleStorage;
910

1011
class DebugExceptionHandler extends DebugExceptionHandlerBase
1112
{
@@ -27,7 +28,11 @@ public function handleException($exception)
2728

2829
$exceptionWasLogged = false;
2930
if ($this->throwableStorage instanceof ThrowableStorageInterface && isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) {
30-
$this->throwableStorage->logThrowable($exception, ['sentryEventId' => $eventId]);
31+
$message = $this->throwableStorage->logThrowable($exception, ['sentryEventId' => $eventId]);
32+
// ConsoleStorage logs json to the console like the other loggers, so do not log twice.
33+
if (!$this->throwableStorage instanceof ConsoleStorage) {
34+
$this->logger->critical($message);
35+
}
3136
$exceptionWasLogged = true;
3237
}
3338

Classes/Handler/ProductionExceptionHandler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Neos\Flow\Log\ThrowableStorageInterface;
77
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
88
use Networkteam\SentryClient\ErrorHandler;
9+
use Networkteam\Util\Log\ThrowableStorage\ConsoleStorage;
910

1011
class ProductionExceptionHandler extends ProductionExceptionHandlerBase
1112
{
@@ -28,7 +29,11 @@ public function handleException($exception)
2829

2930
$exceptionWasLogged = false;
3031
if ($this->throwableStorage instanceof ThrowableStorageInterface && isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) {
31-
$this->throwableStorage->logThrowable($exception, ['sentryEventId' => $eventId]);
32+
$message = $this->throwableStorage->logThrowable($exception, ['sentryEventId' => $eventId]);
33+
// Our ConsoleStorage logs json to the console like the other loggers, so do not log twice.
34+
if (!$this->throwableStorage instanceof ConsoleStorage) {
35+
$this->logger->critical($message);
36+
}
3237
$exceptionWasLogged = true;
3338
}
3439

0 commit comments

Comments
 (0)