diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /includes/debug/MWDebug.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'includes/debug/MWDebug.php')
-rw-r--r-- | includes/debug/MWDebug.php | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php index c2f22233..ae2d9954 100644 --- a/includes/debug/MWDebug.php +++ b/includes/debug/MWDebug.php @@ -26,8 +26,6 @@ * By default, most methods do nothing ( self::$enabled = false ). You have * to explicitly call MWDebug::init() to enabled them. * - * @todo Profiler support - * * @since 1.19 */ class MWDebug { @@ -46,7 +44,7 @@ class MWDebug { protected static $debug = array(); /** - * SQL statements of the databses queries. + * SQL statements of the database queries. * * @var array $query */ @@ -311,12 +309,25 @@ 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 ) { - self::$debug[] = rtrim( UtfNormal::cleanUp( $str ) ); + 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\Validator::cleanUp( $str ) ); } } @@ -529,12 +540,11 @@ class MWDebug { MWDebug::log( 'MWDebug output complete' ); $debugInfo = self::getDebugInfo( $context ); - $result->setIndexedTagName( $debugInfo, 'debuginfo' ); - $result->setIndexedTagName( $debugInfo['log'], 'line' ); - $result->setIndexedTagName( $debugInfo['debugLog'], 'msg' ); - $result->setIndexedTagName( $debugInfo['queries'], 'query' ); - $result->setIndexedTagName( $debugInfo['includes'], 'queries' ); - $result->setIndexedTagName( $debugInfo['profile'], 'function' ); + ApiResult::setIndexedTagName( $debugInfo, 'debuginfo' ); + ApiResult::setIndexedTagName( $debugInfo['log'], 'line' ); + ApiResult::setIndexedTagName( $debugInfo['debugLog'], 'msg' ); + ApiResult::setIndexedTagName( $debugInfo['queries'], 'query' ); + ApiResult::setIndexedTagName( $debugInfo['includes'], 'queries' ); $result->addValue( null, 'debuginfo', $debugInfo ); } @@ -578,7 +588,6 @@ class MWDebug { 'memory' => $context->getLanguage()->formatSize( memory_get_usage( $realMemoryUsage ) ), 'memoryPeak' => $context->getLanguage()->formatSize( memory_get_peak_usage( $realMemoryUsage ) ), 'includes' => self::getFilesIncluded( $context ), - 'profile' => Profiler::instance()->getRawData(), ); } } |