Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1222,6 +1222,16 @@ |
1223 | 1223 | $wgShowDebug = false; |
1224 | 1224 | |
1225 | 1225 | /** |
| 1226 | + * Prefix debug messages with relative timestamp. Very-poor man's profiler. |
| 1227 | + */ |
| 1228 | +$wgDebugTimestamps = false; |
| 1229 | + |
| 1230 | +/** |
| 1231 | + * Print HTTP headers for every request in the debug information. |
| 1232 | + */ |
| 1233 | +$wgDebugPrintHttpHeaders = true; |
| 1234 | + |
| 1235 | +/** |
1226 | 1236 | * Show the contents of $wgHooks in Special:Version |
1227 | 1237 | */ |
1228 | 1238 | $wgSpecialVersionShowHooks = false; |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -343,6 +343,7 @@ |
344 | 344 | static $recursion = 0; |
345 | 345 | |
346 | 346 | static $cache = array(); // Cache of unoutputted messages |
| 347 | + $text = wfDebugTimer() . $text; |
347 | 348 | |
348 | 349 | # Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet |
349 | 350 | if ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' && !$wgDebugRawPage ) { |
— | — | @@ -377,6 +378,21 @@ |
378 | 379 | } |
379 | 380 | } |
380 | 381 | |
| 382 | +function wfDebugTimer() { |
| 383 | + global $wgDebugTimestamps; |
| 384 | + if ( !$wgDebugTimestamps ) return ''; |
| 385 | + static $start = null; |
| 386 | + |
| 387 | + if ( $start === null ) { |
| 388 | + $start = microtime( true ); |
| 389 | + $prefix = "\n$start"; |
| 390 | + } else { |
| 391 | + $prefix = sprintf( "%6.4f", microtime( true ) - $start ); |
| 392 | + } |
| 393 | + |
| 394 | + return $prefix . ' '; |
| 395 | +} |
| 396 | + |
381 | 397 | /** |
382 | 398 | * Send a line giving PHP memory usage. |
383 | 399 | * @param $exact Bool: print exact values instead of kilobytes (default: false) |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -180,24 +180,28 @@ |
181 | 181 | # Useful debug output |
182 | 182 | if ( $wgCommandLineMode ) { |
183 | 183 | wfDebug( "\n\nStart command line script $self\n" ); |
184 | | -} elseif ( function_exists( 'getallheaders' ) ) { |
185 | | - wfDebug( "\n\nStart request\n" ); |
| 184 | +} else { |
| 185 | + wfDebug( "Start request\n\n" ); |
186 | 186 | wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" ); |
187 | | - $headers = getallheaders(); |
188 | | - foreach ($headers as $name => $value) { |
189 | | - wfDebug( "$name: $value\n" ); |
190 | | - } |
191 | | - wfDebug( "\n" ); |
192 | | -} elseif( isset( $_SERVER['REQUEST_URI'] ) ) { |
193 | | - wfDebug( "\n\nStart request\n" ); |
194 | | - wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" ); |
195 | | - foreach ( $_SERVER as $name => $value ) { |
196 | | - if ( substr( $name, 0, 5 ) == 'HTTP_' ) { |
| 187 | + $header_out = "HTTP HEADERS:\n"; |
| 188 | + |
| 189 | + if ( function_exists( 'getallheaders' ) ) { |
| 190 | + $headers = getallheaders(); |
| 191 | + foreach ( $headers as $name => $value ) { |
| 192 | + $header_out .= "$name: $value\n"; |
| 193 | + } |
| 194 | + } else { |
| 195 | + $headers = $_SERVER; |
| 196 | + foreach ( $headers as $name => $value ) { |
| 197 | + if ( substr( $name, 0, 5 ) !== 'HTTP_' ) continue; |
197 | 198 | $name = substr( $name, 5 ); |
198 | | - wfDebug( "$name: $value\n" ); |
| 199 | + $header_out .= "$name: $value\n"; |
199 | 200 | } |
200 | 201 | } |
201 | | - wfDebug( "\n" ); |
| 202 | + |
| 203 | + if ( $wgDebugPrintHttpHeaders ) { |
| 204 | + wfDebug( "$header_out\n" ); |
| 205 | + } |
202 | 206 | } |
203 | 207 | |
204 | 208 | if( $wgRCFilterByAge ) { |
— | — | @@ -255,9 +259,9 @@ |
256 | 260 | $messageMemc =& wfGetMessageCacheStorage(); |
257 | 261 | $parserMemc =& wfGetParserCacheStorage(); |
258 | 262 | |
259 | | -wfDebug( 'Main cache: ' . get_class( $wgMemc ) . |
260 | | - "\nMessage cache: " . get_class( $messageMemc ) . |
261 | | - "\nParser cache: " . get_class( $parserMemc ) . "\n" ); |
| 263 | +wfDebug( 'CACHES: ' . get_class( $wgMemc ) . '[main] ' . |
| 264 | + get_class( $messageMemc ) . '[message] ' . |
| 265 | + get_class( $parserMemc ) . "[parser]\n" ); |
262 | 266 | |
263 | 267 | wfProfileOut( $fname.'-memcached' ); |
264 | 268 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -96,6 +96,8 @@ |
97 | 97 | longer advertised by default (but it still works). |
98 | 98 | * Added $wgMemCachedTimeout to configure connection timeouts for communicating |
99 | 99 | with a memcached server |
| 100 | +* New configuration variables $wgDebugTimestamps and $wgDebugPrintHttpHeaders |
| 101 | + for controlling debug output. |
100 | 102 | |
101 | 103 | === New features in 1.16 === |
102 | 104 | |