From b293ac7cfca269fa75e5a534c54679b2093ff88f Mon Sep 17 00:00:00 2001 From: Sebastian Kurfuerst Date: Mon, 24 Apr 2017 16:56:52 +0200 Subject: [PATCH] FEATURE: Take exception rendering configuration into account when logging exceptions to Graylog As an example, the following configuration can be used to disable logging (to disk AND to graylog): ``` Neos: Flow: error: exceptionHandler: renderingGroups: hmacErrors: matchingExceptionClassNames: ['Neos\Flow\Security\Exception\InvalidHashException'] options: logException: FALSE ``` --- Classes/Error/GraylogExceptionHandler.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Classes/Error/GraylogExceptionHandler.php b/Classes/Error/GraylogExceptionHandler.php index 66a6034..ccb27d7 100644 --- a/Classes/Error/GraylogExceptionHandler.php +++ b/Classes/Error/GraylogExceptionHandler.php @@ -28,10 +28,15 @@ class GraylogExceptionHandler extends ProductionExceptionHandler */ protected function echoExceptionWeb($exception) { + if ($this->graylogService === null) { $this->graylogService = new GraylogService(); } - $this->graylogService->logException($exception); + + if (isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) { + $this->graylogService->logException($exception); + } + parent::echoExceptionWeb($exception); } @@ -44,7 +49,11 @@ protected function echoExceptionCli($exception) if ($this->graylogService === null) { $this->graylogService = new GraylogService(); } - $this->graylogService->logException($exception); + + if (isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) { + $this->graylogService->logException($exception); + } + parent::echoExceptionCli($exception); } }