From 6f9f6643d725609494925f70cbe4f89e9d590689 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Thu, 17 Sep 2009 18:55:29 +0000 Subject: [PATCH] * indent debug output produced when both $wgShowDebug and $wgDebugFunctionEntry are enabled for better readability. In this case, unindented comment will be displayed "inline" with a yellow background * added an id to the debug data list * allow to use $wgShowDebug with $wgDebugComments set to false * update HTMLFileCache to use full method name in debug output --- includes/GlobalFunctions.php | 4 ++-- includes/HTMLFileCache.php | 8 +++---- includes/Skin.php | 41 +++++++++++++++++++++++++++++++++--- includes/SkinTemplate.php | 9 ++++++-- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d63515112b..fa60b421de 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -308,7 +308,7 @@ function wfUrlencode( $s ) { */ function wfDebug( $text, $logonly = false ) { global $wgOut, $wgDebugLogFile, $wgDebugComments, $wgProfileOnly, $wgDebugRawPage; - global $wgDebugLogPrefix; + global $wgDebugLogPrefix, $wgShowDebug; static $recursion = 0; static $cache = array(); // Cache of unoutputted messages @@ -318,7 +318,7 @@ function wfDebug( $text, $logonly = false ) { return; } - if ( $wgDebugComments && !$logonly ) { + if ( ( $wgDebugComments || $wgShowDebug ) && !$logonly ) { $cache[] = $text; if ( !isset( $wgOut ) ) { diff --git a/includes/HTMLFileCache.php b/includes/HTMLFileCache.php index d205624e1a..4611042901 100644 --- a/includes/HTMLFileCache.php +++ b/includes/HTMLFileCache.php @@ -55,7 +55,7 @@ class HTMLFileCache { if( $this->useGzip() ) $this->mFileCache .= '.gz'; - wfDebug( " fileCacheName() - {$this->mFileCache}\n" ); + wfDebug( __METHOD__ . ": {$this->mFileCache}\n" ); } return $this->mFileCache; } @@ -111,7 +111,7 @@ class HTMLFileCache { $cachetime = $this->fileCacheTime(); $good = $timestamp <= $cachetime && $wgCacheEpoch <= $cachetime; - wfDebug(" isFileCacheGood() - cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n"); + wfDebug( __METHOD__ . ": cachetime $cachetime, touched '{$timestamp}' epoch {$wgCacheEpoch}, good $good\n"); return $good; } @@ -137,7 +137,7 @@ class HTMLFileCache { /* Working directory to/from output */ public function loadFromFileCache() { global $wgOut, $wgMimeType, $wgOutputEncoding, $wgContLanguageCode; - wfDebug(" loadFromFileCache()\n"); + wfDebug( __METHOD__ . "()\n"); $filename = $this->fileCacheName(); // Raw pages should handle cache control on their own, // even when using file cache. This reduces hits from clients. @@ -176,7 +176,7 @@ class HTMLFileCache { return $text; } - wfDebug(" saveToFileCache()\n", false); + wfDebug( __METHOD__ . "()\n", false); $this->checkCacheDirs(); diff --git a/includes/Skin.php b/includes/Skin.php index 42262cd85f..845d4ac84e 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -959,13 +959,48 @@ END; protected function generateDebugHTML() { global $wgShowDebug, $wgOut; if ( $wgShowDebug ) { - $listInternals = str_replace( "\n", "\n
  • ", htmlspecialchars( $wgOut->mDebugtext ) ); - return "\n
    \nDebug data:\n"; + $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext ); + return "\n
    \nDebug data:\n"; } return ''; } + private function formatDebugHTML( $debugText ) { + $lines = explode( "\n", $debugText ); + $curIdent = 0; + $ret = '
  • '; + foreach( $lines as $line ) { + $m = array(); + $display = ltrim( $line ); + $ident = strlen( $line ) - strlen( $display ); + $diff = $ident - $curIdent; + + if ( $display == '' ) + $display = "\xc2\xa0"; + + if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) { + $ident = $curIdent; + $diff = 0; + $display = '' . htmlspecialchars( $display ) . ''; + } else { + $display = htmlspecialchars( $display ); + } + + if ( $diff < 0 ) + $ret .= str_repeat( "
  • \n", -$diff ) . "
  • \n"; + elseif ( $diff == 0 ) + $ret .= "
  • \n"; + else + $ret .= str_repeat( "', $curIdent ) . '
  • '; + return $ret; + } + /** * This gets called shortly before the tag. * @return String HTML to be put before diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index d943c0b3ea..2423c197bd 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -141,7 +141,7 @@ class SkinTemplate extends Skin { global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks; global $wgMaxCredits, $wgShowCreditsIfMax; global $wgPageShowWatchingUsers; - global $wgUseTrackbacks, $wgUseSiteJs; + global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments; global $wgArticlePath, $wgScriptPath, $wgServer, $wgCanonicalNamespaceNames; wfProfileIn( __METHOD__ ); @@ -419,7 +419,12 @@ class SkinTemplate extends Skin { $tpl->set( 'privacy', $this->privacyLink() ); $tpl->set( 'about', $this->aboutLink() ); - $tpl->setRef( 'debug', $out->mDebugtext ); + if ( $wgDebugComments ) { + $tpl->setRef( 'debug', $out->mDebugtext ); + } else { + $tpl->set( 'debug', '' ); + } + $tpl->set( 'reporttime', wfReportTime() ); $tpl->set( 'sitenotice', wfGetSiteNotice() ); $tpl->set( 'bottomscripts', $this->bottomScripts() ); -- 2.20.1