From: Kunal Mehta Date: Wed, 18 Mar 2015 22:42:23 +0000 (-0700) Subject: Send messages logged via MWLoggerLegacyLogger::log() to the debug toolbar X-Git-Tag: 1.31.0-rc.0~12049 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=8911a8d0b70cb3cdfacd20b4e7ae6431afb59c30;p=lhc%2Fweb%2Fwiklou.git Send messages logged via MWLoggerLegacyLogger::log() to the debug toolbar Bug: T93145 Change-Id: Ia96525faf4ffcbd2b5beae9716d6be009f2b6074 --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 9ae6cb8570..47e7a151ea 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1030,12 +1030,7 @@ function wfMatchesDomainList( $url, $domains ) { * @since 1.25 support for additional context data * * @param string $text - * @param string|bool $dest Destination of the message: - * - 'all': both to the log and HTML (debug toolbar or HTML comments) - * - 'log': only to the log and not in HTML - * For backward compatibility, it can also take a boolean: - * - true: same as 'all' - * - false: same as 'log' + * @param string|bool $dest Unused * @param array $context Additional logging context data */ function wfDebug( $text, $dest = 'all', array $context = array() ) { @@ -1046,13 +1041,6 @@ function wfDebug( $text, $dest = 'all', array $context = array() ) { return; } - // Turn $dest into a string if it's a boolean (for b/c) - if ( $dest === true ) { - $dest = 'all'; - } elseif ( $dest === false ) { - $dest = 'log'; - } - $text = trim( $text ); // Inline logic from deprecated wfDebugTimer() @@ -1067,16 +1055,6 @@ function wfDebug( $text, $dest = 'all', array $context = array() ) { ); } - if ( $dest === 'all' ) { - $prefix = ''; - if ( $wgDebugTimestamps ) { - // Prepend elapsed request time and real memory usage with two - // trailing spaces. - $prefix = "{$context['seconds_elapsed']} {$context['memory_used']} "; - } - MWDebug::debugMsg( "{$prefix}{$text}" ); - } - if ( $wgDebugLogPrefix !== '' ) { $context['prefix'] = $wgDebugLogPrefix; } @@ -1181,10 +1159,6 @@ function wfDebugLog( $text = trim( $text ); - if ( $dest === 'all' ) { - MWDebug::debugMsg( "[{$logGroup}] {$text}\n" ); - } - $logger = MWLoggerFactory::getInstance( $logGroup ); $context['private'] = ( $dest === 'private' ); $logger->info( $text, $context ); diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php index 48d4e8d87f..dc80a46b26 100644 --- a/includes/debug/MWDebug.php +++ b/includes/debug/MWDebug.php @@ -309,11 +309,24 @@ class MWDebug { * * @since 1.19 * @param string $str + * @param array $context */ - public static function debugMsg( $str ) { + public static function debugMsg( $str, $context = array() ) { global $wgDebugComments, $wgShowDebug; if ( self::$enabled || $wgDebugComments || $wgShowDebug ) { + if ( $context ) { + $prefix = ''; + if ( isset( $context['prefix'] ) ) { + $prefix = $context['prefix']; + } elseif ( isset( $context['channel'] ) && $context['channel'] !== 'wfDebug' ) { + $prefix = "[{$context['channel']}] "; + } + if ( isset( $context['seconds_elapsed'] ) && isset( $context['memory_used'] ) ) { + $prefix .= "{$context['seconds_elapsed']} {$context['memory_used']} "; + } + $str = $prefix . $str; + } self::$debug[] = rtrim( UtfNormal::cleanUp( $str ) ); } } diff --git a/includes/debug/logger/legacy/Logger.php b/includes/debug/logger/legacy/Logger.php index be46c27e63..c53aeaa293 100644 --- a/includes/debug/logger/legacy/Logger.php +++ b/includes/debug/logger/legacy/Logger.php @@ -84,6 +84,8 @@ class MWLoggerLegacyLogger extends AbstractLogger { $destination = self::destination( $this->channel, $message, $context ); self::emit( $text, $destination ); } + // Add to debug toolbar + MWDebug::debugMsg( $message, array( 'channel' => $this->channel ) + $context ); }