Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/200338

Change subject: Log fatal errors to a separate 'fatal' log group
......................................................................

Log fatal errors to a separate 'fatal' log group

'error' is currently disabled in Wikimedia production, but we still need to
log stacktraces for fatals.

Bug: T89169
Change-Id: Id0255651f228037152b87022f5eb696c1050b9ec
---
M includes/exception/MWExceptionHandler.php
1 file changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/38/200338/1

diff --git a/includes/exception/MWExceptionHandler.php 
b/includes/exception/MWExceptionHandler.php
index 5644231..3526b4f 100644
--- a/includes/exception/MWExceptionHandler.php
+++ b/includes/exception/MWExceptionHandler.php
@@ -214,7 +214,7 @@
                }
 
                $e = new ErrorException( "PHP $levelName: $message", 0, $level, 
$file, $line );
-               self::logError( $e );
+               self::logError( $e, 'error' );
 
                // This handler is for logging only. Return false will instruct 
PHP
                // to continue regular handling.
@@ -257,7 +257,7 @@
                                // @codingStandardsIgnoreEnd
                        }
                        $e = new ErrorException( $msg, 0, $lastError['type'] );
-                       self::logError( $e );
+                       self::logError( $e, 'fatal' );
                }
        }
 
@@ -489,8 +489,9 @@
         *
         * @since 1.25
         * @param ErrorException $e
+        * @param string $channel
        */
-       protected static function logError( ErrorException $e ) {
+       protected static function logError( ErrorException $e, $channel ) {
                global $wgLogExceptionBacktrace;
 
                // The set_error_handler callback is independent from 
error_reporting.
@@ -498,16 +499,16 @@
                if ( ( error_reporting() & $e->getSeverity() ) !== 0 ) {
                        $log = self::getLogMessage( $e );
                        if ( $wgLogExceptionBacktrace ) {
-                               wfDebugLog( 'error', $log . "\n" . 
$e->getTraceAsString() );
+                               wfDebugLog( $channel, $log . "\n" . 
$e->getTraceAsString() );
                        } else {
-                               wfDebugLog( 'error', $log );
+                               wfDebugLog( $channel, $log );
                        }
                }
 
                // Include all errors in the json log (surpressed errors will 
be flagged)
                $json = self::jsonSerializeException( $e, false, 
FormatJson::ALL_OK );
                if ( $json !== false ) {
-                       wfDebugLog( 'error-json', $json, 'private' );
+                       wfDebugLog( "$channel-json", $json, 'private' );
                }
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/200338
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0255651f228037152b87022f5eb696c1050b9ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to