saper has uploaded a new change for review.
https://gerrit.wikimedia.org/r/173667
Change subject: Pass $wgDebugTimestamp info to debug console
......................................................................
Pass $wgDebugTimestamp info to debug console
Bug: 73492
Change-Id: I2557601e85d1f4837c67621f2db27dae70b09880
---
M autoload.php
M includes/GlobalFunctions.php
M includes/debug/MWDebug.php
M includes/debug/logger/legacy/Logger.php
M resources/src/mediawiki/mediawiki.debug.js
5 files changed, 40 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/67/173667/1
diff --git a/autoload.php b/autoload.php
index c5fc22c..24ed452 100644
--- a/autoload.php
+++ b/autoload.php
@@ -676,6 +676,7 @@
'MWCryptHKDF' => __DIR__ . '/includes/utils/MWCryptHKDF.php',
'MWCryptRand' => __DIR__ . '/includes/utils/MWCryptRand.php',
'MWDebug' => __DIR__ . '/includes/debug/MWDebug.php',
+ 'MWDebugEntry' => __DIR__ . '/includes/debug/MWDebug.php',
'MWDocGen' => __DIR__ . '/maintenance/mwdocgen.php',
'MWException' => __DIR__ . '/includes/exception/MWException.php',
'MWExceptionHandler' => __DIR__ .
'/includes/exception/MWExceptionHandler.php',
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 81f767d..d48367f 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -973,19 +973,16 @@
}
$timer = wfDebugTimer();
- if ( $timer !== '' ) {
- // Prepend elapsed request time and real memory usage to each
line
- $text = preg_replace( '/[^\n]/', $timer . '\0', $text, 1 );
- }
if ( $dest === 'all' ) {
- MWDebug::debugMsg( $text );
+ MWDebug::debugMsg( $text, $timer );
}
$ctx = array();
if ( $wgDebugLogPrefix !== '' ) {
$ctx['prefix'] = $wgDebugLogPrefix;
}
+ $ctx['debugtimestamps'] = $timer;
$logger = MWLogger::getInstance( 'wfDebug' );
$logger->debug( rtrim( $text, "\n" ), $ctx );
@@ -1076,13 +1073,16 @@
$text = trim( $text );
+ $timer = wfDebugTimer();
+
if ( $dest === 'all' ) {
- MWDebug::debugMsg( "[{$logGroup}] {$text}\n" );
+ MWDebug::debugMsg( "[{$logGroup}] {$text}\n", $timer );
}
$logger = MWLogger::getInstance( $logGroup );
$logger->debug( $text, array(
'private' => ( $dest === 'private' ),
+ 'debugtimestamps' => $timer
) );
}
diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php
index ffc6b3b..1b05670 100644
--- a/includes/debug/MWDebug.php
+++ b/includes/debug/MWDebug.php
@@ -312,11 +312,11 @@
* @since 1.19
* @param string $str
*/
- public static function debugMsg( $str ) {
+ public static function debugMsg( $str, $debugtimestamp = '' ) {
global $wgDebugComments, $wgShowDebug;
if ( self::$enabled || $wgDebugComments || $wgShowDebug ) {
- self::$debug[] = rtrim( UtfNormal::cleanUp( $str ) );
+ self::$debug[] = new MWDebugEntry( rtrim(
UtfNormal::cleanUp( $str ) ), $debugtimestamp );
}
}
@@ -582,3 +582,24 @@
);
}
}
+
+/*
+ * Single debugger log entry
+ *
+ * @since 1.25
+ */
+class MWDebugEntry {
+
+ function __construct( $text, $timer = '' ) {
+ $this->text = $text;
+ $this->timer = $timer;
+ }
+
+ function __toString() {
+ if ( $this->timer) {
+ return "{$this->timer} {$this->text}";
+ } else {
+ return $this->text;
+ }
+ }
+}
diff --git a/includes/debug/logger/legacy/Logger.php
b/includes/debug/logger/legacy/Logger.php
index daf3f51..6e93e59 100644
--- a/includes/debug/logger/legacy/Logger.php
+++ b/includes/debug/logger/legacy/Logger.php
@@ -166,6 +166,7 @@
$log = sprintf( "%s\t%04.3f\t%s%s\n",
gmdate( 'YmdHis' ), $context['elapsed'],
$context['url'], $forward );
+ unset( $context['debugtimestamps'] ); // redundant with
profiling
$text = self::formatAsWfDebugLog(
$channel, $log . $context['output'], $context );
@@ -194,6 +195,9 @@
$text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1f]!', ' ',
$message );
if ( isset( $context['prefix'] ) ) {
$text = "{$context['prefix']}{$text}";
+ }
+ if ( $context['debugtimestamps'] ) {
+ $text = "{$context['debugtimestamps']} {$text}";
}
return "{$text}\n";
}
@@ -241,6 +245,9 @@
*/
protected static function formatAsWfDebugLog( $channel, $message,
$context ) {
$time = wfTimestamp( TS_DB );
+ if ( $context['debugtimestamps'] ) {
+ $time = "{$context['debugtimestamps']} {$time}";
+ }
$wiki = wfWikiID();
$host = wfHostname();
$text = "{$time} {$host} {$wiki}: {$message}\n";
diff --git a/resources/src/mediawiki/mediawiki.debug.js
b/resources/src/mediawiki/mediawiki.debug.js
index 4935984..6aa9c7d 100644
--- a/resources/src/mediawiki/mediawiki.debug.js
+++ b/resources/src/mediawiki/mediawiki.debug.js
@@ -311,11 +311,12 @@
* @return {jQuery}
*/
buildDebugLogTable: function () {
- var $list, i, length, line;
+ var $list, i, length, line, logentry;
$list = $( '<ul>' );
for ( i = 0, length = this.data.debugLog.length; i <
length; i += 1 ) {
- line = this.data.debugLog[i];
+ logentry = this.data.debugLog[i];
+ line = ( logentry.timer ? logentry.timer + " "
+ logentry.text : logentry.text );
$( '<li>' )
.html( mw.html.escape( line ).replace(
/\n/g, '<br />\n' ) )
.appendTo( $list );
--
To view, visit https://gerrit.wikimedia.org/r/173667
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2557601e85d1f4837c67621f2db27dae70b09880
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: saper <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits