diff --git a/src/LogHandler/Filter404Handler.php b/src/LogHandler/Filter404Handler.php index acb1866..0f228e5 100644 --- a/src/LogHandler/Filter404Handler.php +++ b/src/LogHandler/Filter404Handler.php @@ -16,36 +16,40 @@ use Monolog\Handler\AbstractHandler; use Monolog\Level; use Monolog\LogRecord; +use Pimcore\Version; -/** - * Ignores warning messages for 404 errors as they are spamming the logs - * - * @internal - */ -final class Filter404Handler extends AbstractHandler -{ - private bool $ignoreNextResponseWarning = false; +if(Version::getMajorVersion() >= 11) { - public function isHandling(LogRecord $record): bool + /** + * Ignores warning messages for 404 errors as they are spamming the logs + * + * @internal + */ + final class Filter404Handler extends AbstractHandler { - $ignore = - $record->level === Level::Warning - && ($record->context['HTTP code'] ?? null) === 404; - - if ($ignore) { - $this->ignoreNextResponseWarning = true; - } else { - $ignore = $this->ignoreNextResponseWarning - && $record->level === Level::Warning - && $record->message === 'Response'; - $this->ignoreNextResponseWarning = false; + private bool $ignoreNextResponseWarning = false; + + public function isHandling(LogRecord $record): bool + { + $ignore = + $record->level === Level::Warning + && ($record->context['HTTP code'] ?? null) === 404; + + if ($ignore) { + $this->ignoreNextResponseWarning = true; + } else { + $ignore = $this->ignoreNextResponseWarning + && $record->level === Level::Warning + && $record->message === 'Response'; + $this->ignoreNextResponseWarning = false; + } + + return $ignore; } - return $ignore; - } - - public function handle(LogRecord $record): bool - { - return $this->isHandling($record); + public function handle(LogRecord $record): bool + { + return $this->isHandling($record); + } } }