MediaWiki r10598 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r10597‎ | r10598 (on ViewVC)‎ | 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:

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
===================================================================
--- trunk/phase3/includes/GlobalFunctions.php	(revision 10597)
+++ trunk/phase3/includes/GlobalFunctions.php	(revision 10598)
@@ -176,6 +176,22 @@
 }
 
 /**
+ * Send a line to a supplementary debug log file, if configured, or main debug log if not.
+ * $wgDebugLogGroups[$logGroup] should be set to a filename to send to a separate log.
+ * @param string $logGroup
+ * @param string $text
+ */
+function wfDebugLog( $logGroup, $text ) {
+	global $wgDebugLogGroups, $wgDBname;
+	if( $text{strlen( $text ) - 1} != "\n" ) $text .= "\n";
+	if( isset( $wgDebugLogGroups[$logGroup] ) ) {
+		@error_log( "$wgDBname: $text", 3, $wgDebugLogGroups[$logGroup] );
+	} else {
+		wfDebug( $text, true );
+	}
+}
+
+/**
  * Log for database errors
  * @param string $text Database error message.
  */
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 10597)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 10598)
@@ -616,6 +616,14 @@
 $wgDebugDumpSql         = false;
 
 /**
+ * Set to an array of log group keys to filenames.
+ * If set, wfDebugLog() output for that group will go to that file instead 
+ * of the regular $wgDebugLogFile. Useful for enabling selective logging
+ * in production.
+ */
+$wgDebugLogGroups       = array();
+
+/**
  * Whether to show "we're sorry, but there has been a database error" pages.
  * Displaying errors aids in debugging, but may display information useful
  * to an attacker.
Index: trunk/phase3/includes/LoadBalancer.php
===================================================================
--- trunk/phase3/includes/LoadBalancer.php	(revision 10597)
+++ trunk/phase3/includes/LoadBalancer.php	(revision 10598)
@@ -140,7 +140,7 @@
 			return false;
 		}
 
-		#wfDebug( var_export( $loads, true ) );
+		#wfDebugLog( 'connect', var_export( $loads, true ) );
 
 		# Return a random representative of the remainder
 		return $this->pickRandom( $loads );
@@ -183,8 +183,9 @@
 							$i = $this->pickRandom( $loads );
 						}
 					}
+					$serverIndex = $i;
 					if ( $i !== false ) {
-						wfDebug( "Using reader #$i: {$this->mServers[$i]['host']}...\n" );
+						wfDebugLog( 'connect', "Using reader #$i: {$this->mServers[$i]['host']}...\n" );
 						$this->openConnection( $i );
 
 						if ( !$this->isOpen( $i ) ) {
@@ -211,7 +212,10 @@
 					}
 					if ( $sleepTime ) {
 							$totalElapsed += $sleepTime;
+							$x = "{$this->mServers[$serverIndex]['host']} $sleepTime [$serverIndex]";
+							wfProfileIn( "$fname-sleep $x" );
 							usleep( $sleepTime );
+							wfProfileOut( "$fname-sleep $x" );
 					}
 				} while ( count( $loads ) && !$done && $totalElapsed / 1e6 < $wgDBClusterTimeout );
 
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 10597)
+++ trunk/phase3/RELEASE-NOTES	(revision 10598)
@@ -29,7 +29,10 @@
 * (bug 3170) Page Title failed to obey MediaWiki:Pagetitle.
   wikititlesuffix was removed
 * (bug 3177) Estonian date formats not implemented in LanguageEt.php
+* Add ability to break off certain debug topics into additional log files;
+  use $wgDebugLogGroups to configure and wfDebugLog() to log.
 
+
 === Caveats ===
 
 Some output, particularly involving user-supplied inline HTML, may not

Status & tagging log

  • 01:58, 13 October 2010 ^demon (Talk | contribs) changed the status of r10598 [removed: new added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox