From: Gergő Tisza Date: Sat, 24 Aug 2019 11:33:38 +0000 (+0200) Subject: Allow logging arbitrary extra data in MWExceptionHandler::logException X-Git-Tag: 1.34.0-rc.0~182^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin//%22%24encUrl/%22?a=commitdiff_plain;h=59e461136df5cd3120c07ec33bc4b581d413e447;p=lhc%2Fweb%2Fwiklou.git Allow logging arbitrary extra data in MWExceptionHandler::logException Change-Id: I8215191900fa3a61d6e9c80bbe36c83c8be1710a --- diff --git a/includes/exception/MWExceptionHandler.php b/includes/exception/MWExceptionHandler.php index b4e483bf53..d7c5a855bd 100644 --- a/includes/exception/MWExceptionHandler.php +++ b/includes/exception/MWExceptionHandler.php @@ -683,16 +683,21 @@ TXT; * This method must not assume the exception is an MWException, * it is also used to handle PHP exceptions or exceptions from other libraries. * - * @since 1.22 * @param Exception|Throwable $e * @param string $catcher CAUGHT_BY_* class constant indicating what caught the error + * @param array $extraData (since 1.34) Additional data to log + * @since 1.22 */ - public static function logException( $e, $catcher = self::CAUGHT_BY_OTHER ) { + public static function logException( $e, $catcher = self::CAUGHT_BY_OTHER, $extraData = [] ) { if ( !( $e instanceof MWException ) || $e->isLoggable() ) { $logger = LoggerFactory::getInstance( 'exception' ); + $context = self::getLogContext( $e, $catcher ); + if ( $extraData ) { + $context['extraData'] = $extraData; + } $logger->error( self::getLogNormalMessage( $e ), - self::getLogContext( $e, $catcher ) + $context ); $json = self::jsonSerializeException( $e, false, FormatJson::ALL_OK, $catcher );