r10598 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10597‎ | r10598 | r10599 >
Date:20:07, 17 August 2005
Author:vibber
Status:old
Tags:
Comment:
* Add ability to break off certain debug topics into additional log files;
use $wgDebugLogGroups to configure and wfDebugLog() to log.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/LoadBalancer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -176,6 +176,22 @@
177177 }
178178
179179 /**
 180+ * Send a line to a supplementary debug log file, if configured, or main debug log if not.
 181+ * $wgDebugLogGroups[$logGroup] should be set to a filename to send to a separate log.
 182+ * @param string $logGroup
 183+ * @param string $text
 184+ */
 185+function wfDebugLog( $logGroup, $text ) {
 186+ global $wgDebugLogGroups, $wgDBname;
 187+ if( $text{strlen( $text ) - 1} != "\n" ) $text .= "\n";
 188+ if( isset( $wgDebugLogGroups[$logGroup] ) ) {
 189+ @error_log( "$wgDBname: $text", 3, $wgDebugLogGroups[$logGroup] );
 190+ } else {
 191+ wfDebug( $text, true );
 192+ }
 193+}
 194+
 195+/**
180196 * Log for database errors
181197 * @param string $text Database error message.
182198 */
Index: trunk/phase3/includes/DefaultSettings.php
@@ -616,6 +616,14 @@
617617 $wgDebugDumpSql = false;
618618
619619 /**
 620+ * Set to an array of log group keys to filenames.
 621+ * If set, wfDebugLog() output for that group will go to that file instead
 622+ * of the regular $wgDebugLogFile. Useful for enabling selective logging
 623+ * in production.
 624+ */
 625+$wgDebugLogGroups = array();
 626+
 627+/**
620628 * Whether to show "we're sorry, but there has been a database error" pages.
621629 * Displaying errors aids in debugging, but may display information useful
622630 * to an attacker.
Index: trunk/phase3/includes/LoadBalancer.php
@@ -140,7 +140,7 @@
141141 return false;
142142 }
143143
144 - #wfDebug( var_export( $loads, true ) );
 144+ #wfDebugLog( 'connect', var_export( $loads, true ) );
145145
146146 # Return a random representative of the remainder
147147 return $this->pickRandom( $loads );
@@ -183,8 +183,9 @@
184184 $i = $this->pickRandom( $loads );
185185 }
186186 }
 187+ $serverIndex = $i;
187188 if ( $i !== false ) {
188 - wfDebug( "Using reader #$i: {$this->mServers[$i]['host']}...\n" );
 189+ wfDebugLog( 'connect', "Using reader #$i: {$this->mServers[$i]['host']}...\n" );
189190 $this->openConnection( $i );
190191
191192 if ( !$this->isOpen( $i ) ) {
@@ -211,7 +212,10 @@
212213 }
213214 if ( $sleepTime ) {
214215 $totalElapsed += $sleepTime;
 216+ $x = "{$this->mServers[$serverIndex]['host']} $sleepTime [$serverIndex]";
 217+ wfProfileIn( "$fname-sleep $x" );
215218 usleep( $sleepTime );
 219+ wfProfileOut( "$fname-sleep $x" );
216220 }
217221 } while ( count( $loads ) && !$done && $totalElapsed / 1e6 < $wgDBClusterTimeout );
218222
Index: trunk/phase3/RELEASE-NOTES
@@ -29,7 +29,10 @@
3030 * (bug 3170) Page Title failed to obey MediaWiki:Pagetitle.
3131 wikititlesuffix was removed
3232 * (bug 3177) Estonian date formats not implemented in LanguageEt.php
 33+* Add ability to break off certain debug topics into additional log files;
 34+ use $wgDebugLogGroups to configure and wfDebugLog() to log.
3335
 36+
3437 === Caveats ===
3538
3639 Some output, particularly involving user-supplied inline HTML, may not

Status & tagging log