فهرست منبع

Merge branch '1.x'

Jordi Boggiano 9 سال پیش
والد
کامیت
cc1fe9fa91
2فایلهای تغییر یافته به همراه14 افزوده شده و 3 حذف شده
  1. 8 0
      CHANGELOG.mdown
  2. 6 3
      src/Monolog/ErrorHandler.php

+ 8 - 0
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

+ 6 - 3
src/Monolog/ErrorHandler.php

@@ -32,6 +32,7 @@ class ErrorHandler
 
     private $previousErrorHandler;
     private $errorLevelMap;
+    private $handleOnlyReportedErrors;
 
     private $hasFatalErrorHandler;
     private $fatalLevel;
@@ -79,13 +80,15 @@ class ErrorHandler
         }
     }
 
-    public function registerErrorHandler(array $levelMap = [], $callPrevious = true, $errorTypes = -1)
+    public function registerErrorHandler(array $levelMap = [], $callPrevious = true, $errorTypes = -1, $handleOnlyReportedErrors = true)
     {
         $prev = set_error_handler([$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)
@@ -157,14 +160,14 @@ class ErrorHandler
      */
     public function handleError($code, $message, $file = '', $line = 0, $context = [])
     {
-        if (!(error_reporting() & $code)) {
+        if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
             return;
         }
 
         // 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, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line, 'context' => $context]);
+            $this->logger->log($level, self::codeToString($code).': '.$message, ['code' => $code, 'message' => $message, 'file' => $file, 'line' => $line]);
         }
 
         if ($this->previousErrorHandler === true) {