New configuration variables $wgDebugTimestamps and $wgDebugPrintHttpHeaders for controlling debug output.
I find these useful, maybe someone else will too.
This commit is contained in:
parent
9bdedcc2aa
commit
b1e2b87b95
4 changed files with 49 additions and 17 deletions
|
|
@ -96,6 +96,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
|
|||
longer advertised by default (but it still works).
|
||||
* Added $wgMemCachedTimeout to configure connection timeouts for communicating
|
||||
with a memcached server
|
||||
* New configuration variables $wgDebugTimestamps and $wgDebugPrintHttpHeaders
|
||||
for controlling debug output.
|
||||
|
||||
=== New features in 1.16 ===
|
||||
|
||||
|
|
|
|||
|
|
@ -1221,6 +1221,16 @@ $wgDebugLogGroups = array();
|
|||
*/
|
||||
$wgShowDebug = false;
|
||||
|
||||
/**
|
||||
* Prefix debug messages with relative timestamp. Very-poor man's profiler.
|
||||
*/
|
||||
$wgDebugTimestamps = false;
|
||||
|
||||
/**
|
||||
* Print HTTP headers for every request in the debug information.
|
||||
*/
|
||||
$wgDebugPrintHttpHeaders = true;
|
||||
|
||||
/**
|
||||
* Show the contents of $wgHooks in Special:Version
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -343,6 +343,7 @@ function wfDebug( $text, $logonly = false ) {
|
|||
static $recursion = 0;
|
||||
|
||||
static $cache = array(); // Cache of unoutputted messages
|
||||
$text = wfDebugTimer() . $text;
|
||||
|
||||
# Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet
|
||||
if ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' && !$wgDebugRawPage ) {
|
||||
|
|
@ -377,6 +378,21 @@ function wfDebug( $text, $logonly = false ) {
|
|||
}
|
||||
}
|
||||
|
||||
function wfDebugTimer() {
|
||||
global $wgDebugTimestamps;
|
||||
if ( !$wgDebugTimestamps ) return '';
|
||||
static $start = null;
|
||||
|
||||
if ( $start === null ) {
|
||||
$start = microtime( true );
|
||||
$prefix = "\n$start";
|
||||
} else {
|
||||
$prefix = sprintf( "%6.4f", microtime( true ) - $start );
|
||||
}
|
||||
|
||||
return $prefix . ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a line giving PHP memory usage.
|
||||
* @param $exact Bool: print exact values instead of kilobytes (default: false)
|
||||
|
|
|
|||
|
|
@ -180,24 +180,28 @@ $wgRequest = new WebRequest;
|
|||
# Useful debug output
|
||||
if ( $wgCommandLineMode ) {
|
||||
wfDebug( "\n\nStart command line script $self\n" );
|
||||
} elseif ( function_exists( 'getallheaders' ) ) {
|
||||
wfDebug( "\n\nStart request\n" );
|
||||
} else {
|
||||
wfDebug( "Start request\n\n" );
|
||||
wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
|
||||
$headers = getallheaders();
|
||||
foreach ($headers as $name => $value) {
|
||||
wfDebug( "$name: $value\n" );
|
||||
}
|
||||
wfDebug( "\n" );
|
||||
} elseif( isset( $_SERVER['REQUEST_URI'] ) ) {
|
||||
wfDebug( "\n\nStart request\n" );
|
||||
wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
|
||||
foreach ( $_SERVER as $name => $value ) {
|
||||
if ( substr( $name, 0, 5 ) == 'HTTP_' ) {
|
||||
$header_out = "HTTP HEADERS:\n";
|
||||
|
||||
if ( function_exists( 'getallheaders' ) ) {
|
||||
$headers = getallheaders();
|
||||
foreach ( $headers as $name => $value ) {
|
||||
$header_out .= "$name: $value\n";
|
||||
}
|
||||
} else {
|
||||
$headers = $_SERVER;
|
||||
foreach ( $headers as $name => $value ) {
|
||||
if ( substr( $name, 0, 5 ) !== 'HTTP_' ) continue;
|
||||
$name = substr( $name, 5 );
|
||||
wfDebug( "$name: $value\n" );
|
||||
$header_out .= "$name: $value\n";
|
||||
}
|
||||
}
|
||||
wfDebug( "\n" );
|
||||
|
||||
if ( $wgDebugPrintHttpHeaders ) {
|
||||
wfDebug( "$header_out\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if( $wgRCFilterByAge ) {
|
||||
|
|
@ -255,9 +259,9 @@ $wgMemc =& wfGetMainCache();
|
|||
$messageMemc =& wfGetMessageCacheStorage();
|
||||
$parserMemc =& wfGetParserCacheStorage();
|
||||
|
||||
wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
|
||||
"\nMessage cache: " . get_class( $messageMemc ) .
|
||||
"\nParser cache: " . get_class( $parserMemc ) . "\n" );
|
||||
wfDebug( 'CACHES: ' . get_class( $wgMemc ) . '[main] ' .
|
||||
get_class( $messageMemc ) . '[message] ' .
|
||||
get_class( $parserMemc ) . "[parser]\n" );
|
||||
|
||||
wfProfileOut( $fname.'-memcached' );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue