From 0defb2665b10d295af0464defd0a94293928c00e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 29 Jul 2016 05:08:45 +0200 Subject: [PATCH 1/3] Revert #810 and remove the context info in the php error logger of ErrorHandler, fixes #828, closes #810 --- src/Monolog/ErrorHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Monolog/ErrorHandler.php b/src/Monolog/ErrorHandler.php index 715b93a9..f21eb285 100644 --- a/src/Monolog/ErrorHandler.php +++ b/src/Monolog/ErrorHandler.php @@ -149,7 +149,7 @@ class ErrorHandler // fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) { $level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL; - $this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line, 'context' => $context)); + $this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line)); } if ($this->previousErrorHandler === true) { From 3419d216690c9acd90d22cff296433038530949b Mon Sep 17 00:00:00 2001 From: Adam Kiss Date: Wed, 6 Jul 2016 14:15:46 +0200 Subject: [PATCH 2/3] Added option to log errors regardless of error_reporting setting --- src/Monolog/ErrorHandler.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Monolog/ErrorHandler.php b/src/Monolog/ErrorHandler.php index f21eb285..0152298d 100644 --- a/src/Monolog/ErrorHandler.php +++ b/src/Monolog/ErrorHandler.php @@ -33,6 +33,7 @@ class ErrorHandler private $previousErrorHandler; private $errorLevelMap; + private $handleOnlyReportedErrors; private $hasFatalErrorHandler; private $fatalLevel; @@ -80,13 +81,15 @@ class ErrorHandler } } - public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1) + public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1, $handleOnlyReportedErrors = true) { $prev = set_error_handler(array($this, 'handleError'), $errorTypes); $this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap); if ($callPrevious) { $this->previousErrorHandler = $prev ?: true; } + + $this->handleOnlyReportedErrors = $handleOnlyReportedErrors; } public function registerFatalHandler($level = null, $reservedMemorySize = 20) @@ -142,7 +145,7 @@ class ErrorHandler */ public function handleError($code, $message, $file = '', $line = 0, $context = array()) { - if (!(error_reporting() & $code)) { + if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) { return; } From f42fbdfd53e306bda545845e4dbfd3e72edb4952 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 29 Jul 2016 05:23:52 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.mdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.mdown b/CHANGELOG.mdown index 7624cac4..5f81e24f 100644 --- a/CHANGELOG.mdown +++ b/CHANGELOG.mdown @@ -1,3 +1,11 @@ +### 1.21.0 (2016-07-29) + + * Break: Reverted the addition of $context when the ErrorHandler handles regular php errors from 1.20.0 as it was causing issues + * Added support for more formats in RotatingFileHandler::setFilenameFormat as long as they have Y, m and d in order + * Added ability to format the main line of text the SlackHandler sends by explictly setting a formatter on the handler + * Added information about SoapFault instances in NormalizerFormatter + * Added $handleOnlyReportedErrors option on ErrorHandler::registerErrorHandler (default true) to allow logging of all errors no matter the error_reporting level + ### 1.20.0 (2016-07-02) * Added FingersCrossedHandler::activate() to manually trigger the handler regardless of the activation policy