From 5434f3f73d3ed81dedc35a27b5f93f3c480e5c37 Mon Sep 17 00:00:00 2001 From: David Neilsen Date: Thu, 14 Nov 2013 15:14:00 +1300 Subject: [PATCH 1/2] Prevent throwing an exception in the case that the fatal error level is not set. --- src/Monolog/ErrorHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Monolog/ErrorHandler.php b/src/Monolog/ErrorHandler.php index dd651321..8df401ff 100644 --- a/src/Monolog/ErrorHandler.php +++ b/src/Monolog/ErrorHandler.php @@ -92,7 +92,7 @@ class ErrorHandler register_shutdown_function(array($this, 'handleFatalError')); $this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize); - $this->fatalLevel = $level === null ? LogLevel::ALERT : $level; + $this->fatalLevel = $level; } protected function defaultErrorLevelMap() @@ -157,7 +157,7 @@ class ErrorHandler $lastError = error_get_last(); if ($lastError && in_array($lastError['type'], self::$fatalErrors)) { $this->logger->log( - $this->fatalLevel, + $this->fatalLevel === null ? LogLevel::ALERT : $this->fatalLevel, 'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'], array('file' => $lastError['file'], 'line' => $lastError['line']) ); From b66237f825b4b0b152265e3c223c615c3e4a557d Mon Sep 17 00:00:00 2001 From: David Neilsen Date: Thu, 14 Nov 2013 15:34:27 +1300 Subject: [PATCH 2/2] Also prevent throwing another exception in the case that the exception logger level is not set. Also prevent throwing another exception in the case that the exception logger level is not set. --- src/Monolog/ErrorHandler.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Monolog/ErrorHandler.php b/src/Monolog/ErrorHandler.php index 8df401ff..d870767e 100644 --- a/src/Monolog/ErrorHandler.php +++ b/src/Monolog/ErrorHandler.php @@ -72,7 +72,7 @@ class ErrorHandler public function registerExceptionHandler($level = null, $callPrevious = true) { $prev = set_exception_handler(array($this, 'handleException')); - $this->uncaughtExceptionLevel = $level === null ? LogLevel::ERROR : $level; + $this->uncaughtExceptionLevel = $level; if ($callPrevious && $prev) { $this->previousExceptionHandler = $prev; } @@ -121,7 +121,11 @@ class ErrorHandler */ public function handleException(\Exception $e) { - $this->logger->log($this->uncaughtExceptionLevel, 'Uncaught exception', array('exception' => $e)); + $this->logger->log( + $this->uncaughtExceptionLevel === null ? LogLevel::ERROR : $this->uncaughtExceptionLevel, + 'Uncaught exception', + array('exception' => $e) + ); if ($this->previousExceptionHandler) { call_user_func($this->previousExceptionHandler, $e);