Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -176,6 +176,22 @@ |
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
| 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 | +/** |
180 | 196 | * Log for database errors |
181 | 197 | * @param string $text Database error message. |
182 | 198 | */ |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -616,6 +616,14 @@ |
617 | 617 | $wgDebugDumpSql = false; |
618 | 618 | |
619 | 619 | /** |
| 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 | +/** |
620 | 628 | * Whether to show "we're sorry, but there has been a database error" pages. |
621 | 629 | * Displaying errors aids in debugging, but may display information useful |
622 | 630 | * to an attacker. |
Index: trunk/phase3/includes/LoadBalancer.php |
— | — | @@ -140,7 +140,7 @@ |
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | | - #wfDebug( var_export( $loads, true ) ); |
| 144 | + #wfDebugLog( 'connect', var_export( $loads, true ) ); |
145 | 145 | |
146 | 146 | # Return a random representative of the remainder |
147 | 147 | return $this->pickRandom( $loads ); |
— | — | @@ -183,8 +183,9 @@ |
184 | 184 | $i = $this->pickRandom( $loads ); |
185 | 185 | } |
186 | 186 | } |
| 187 | + $serverIndex = $i; |
187 | 188 | if ( $i !== false ) { |
188 | | - wfDebug( "Using reader #$i: {$this->mServers[$i]['host']}...\n" ); |
| 189 | + wfDebugLog( 'connect', "Using reader #$i: {$this->mServers[$i]['host']}...\n" ); |
189 | 190 | $this->openConnection( $i ); |
190 | 191 | |
191 | 192 | if ( !$this->isOpen( $i ) ) { |
— | — | @@ -211,7 +212,10 @@ |
212 | 213 | } |
213 | 214 | if ( $sleepTime ) { |
214 | 215 | $totalElapsed += $sleepTime; |
| 216 | + $x = "{$this->mServers[$serverIndex]['host']} $sleepTime [$serverIndex]"; |
| 217 | + wfProfileIn( "$fname-sleep $x" ); |
215 | 218 | usleep( $sleepTime ); |
| 219 | + wfProfileOut( "$fname-sleep $x" ); |
216 | 220 | } |
217 | 221 | } while ( count( $loads ) && !$done && $totalElapsed / 1e6 < $wgDBClusterTimeout ); |
218 | 222 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -29,7 +29,10 @@ |
30 | 30 | * (bug 3170) Page Title failed to obey MediaWiki:Pagetitle. |
31 | 31 | wikititlesuffix was removed |
32 | 32 | * (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. |
33 | 35 | |
| 36 | + |
34 | 37 | === Caveats === |
35 | 38 | |
36 | 39 | Some output, particularly involving user-supplied inline HTML, may not |