jenkins-bot has submitted this change and it was merged.

Change subject: Send messages logged via MWLoggerLegacyLogger::log() to the 
debug toolbar
......................................................................


Send messages logged via MWLoggerLegacyLogger::log() to the debug toolbar

Bug: T93145
Change-Id: Ia96525faf4ffcbd2b5beae9716d6be009f2b6074
---
M includes/GlobalFunctions.php
M includes/debug/MWDebug.php
M includes/debug/logger/legacy/Logger.php
3 files changed, 17 insertions(+), 28 deletions(-)

Approvals:
  BryanDavis: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 9ae6cb8..47e7a15 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -1030,12 +1030,7 @@
  * @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() ) {
@@ -1044,13 +1039,6 @@
 
        if ( !$wgDebugRawPage && wfIsDebugRawPage() ) {
                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 );
@@ -1065,16 +1053,6 @@
                        '%5.1fM',
                        ( memory_get_usage( true ) / ( 1024 * 1024 ) )
                );
-       }
-
-       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 !== '' ) {
@@ -1180,10 +1158,6 @@
        }
 
        $text = trim( $text );
-
-       if ( $dest === 'all' ) {
-               MWDebug::debugMsg( "[{$logGroup}] {$text}\n" );
-       }
 
        $logger = MWLoggerFactory::getInstance( $logGroup );
        $context['private'] = ( $dest === 'private' );
diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php
index 48d4e8d..dc80a46 100644
--- a/includes/debug/MWDebug.php
+++ b/includes/debug/MWDebug.php
@@ -309,11 +309,24 @@
         *
         * @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 be46c27..c53aeaa 100644
--- a/includes/debug/logger/legacy/Logger.php
+++ b/includes/debug/logger/legacy/Logger.php
@@ -84,6 +84,8 @@
                        $destination = self::destination( $this->channel, 
$message, $context );
                        self::emit( $text, $destination );
                }
+               // Add to debug toolbar
+               MWDebug::debugMsg( $message, array( 'channel' => $this->channel 
) + $context );
        }
 
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia96525faf4ffcbd2b5beae9716d6be009f2b6074
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to