From 87b966a789b321a8fa3f9f2179d90ec4729f182b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 25 May 2011 22:01:08 +0000 Subject: [PATCH] * (bug 29140) FirePHP debugging assist extension FirePHP is an extension to Firebug, an awesome debugging extension to Firefox. It allows pulling debug log data in from your PHP script via HTTP headers, which then get displayed in Firebug's console along with errors, warnings, and AJAX hits from the web page. Added 'Debug' hook which gets called from wfDebug() and wfDebugLog() to take this; note that a few lines of output won't make it to FirePHP as they are output either before we've done all plugin initialization, or after we've flushed output and can no longer add HTTP headers. BSD-licensed FirePHPCore library from firephp-libs commit aff25803a3ff460b2797: https://github.com/cadorn/firephp-libs/blob/aff25803a3ff460b2797/packages/core/lib/FirePHPCore/FirePHP.class.php There's not a lot of fancy integration; everything's just output as a 'log' line. You can use $wgFirePHP global (or call FirePHP::getInstance() yourself) to get direct access to FirePHP's fancier features in test code. --- docs/hooks.txt | 4 ++++ includes/GlobalFunctions.php | 18 +++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 46900367cb..0c8cf92c9d 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -648,6 +648,10 @@ etc. 'DatabaseOraclePostInit': Called after initialising an Oracle database &$db: the DatabaseOracle object +'Debug': called when outputting a debug log line via wfDebug() or wfDebugLog() +$text: plaintext string to be output +$group: null or a string naming a logging group (as defined in $wgDebugLogGroups) + 'NewDifferenceEngine': Called when a new DifferenceEngine object is made $title: the diff page title (nullable) &$oldId: the actual old Id to use in the diff diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index ceda004745..0bff1d62a5 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -339,12 +339,14 @@ function wfDebug( $text, $logonly = false ) { $cache = array(); } } - if ( $wgDebugLogFile != '' && !$wgProfileOnly ) { - # Strip unprintables; they can switch terminal modes when binary data - # gets dumped, which is pretty annoying. - $text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1f]!', ' ', $text ); - $text = $wgDebugLogPrefix . $text; - wfErrorLog( $text, $wgDebugLogFile ); + if ( wfRunHooks( 'Debug', array( $text, null /* no log group */ ) ) ) { + if ( $wgDebugLogFile != '' && !$wgProfileOnly ) { + # Strip unprintables; they can switch terminal modes when binary data + # gets dumped, which is pretty annoying. + $text = preg_replace( '![\x00-\x08\x0b\x0c\x0e-\x1f]!', ' ', $text ); + $text = $wgDebugLogPrefix . $text; + wfErrorLog( $text, $wgDebugLogFile ); + } } } @@ -405,7 +407,9 @@ function wfDebugLog( $logGroup, $text, $public = true ) { } else { $host = ''; } - wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] ); + if ( wfRunHooks( 'Debug', array( $text, $logGroup ) ) ) { + wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] ); + } } elseif ( $public === true ) { wfDebug( $text, true ); } -- 2.20.1