* @since 1.25 support for additional context data
*
* @param string $text
- * @param string|bool $dest Destination of the message:
- * - 'all': both to the log and HTML (debug toolbar or HTML comments)
- * - 'log': only to the log and not in HTML
- * For backward compatibility, it can also take a boolean:
- * - true: same as 'all'
- * - false: same as 'log'
+ * @param string|bool $dest Unused
* @param array $context Additional logging context data
*/
function wfDebug( $text, $dest = 'all', array $context = array() ) {
return;
}
- // Turn $dest into a string if it's a boolean (for b/c)
- if ( $dest === true ) {
- $dest = 'all';
- } elseif ( $dest === false ) {
- $dest = 'log';
- }
-
$text = trim( $text );
// Inline logic from deprecated wfDebugTimer()
);
}
- if ( $dest === 'all' ) {
- $prefix = '';
- if ( $wgDebugTimestamps ) {
- // Prepend elapsed request time and real memory usage with two
- // trailing spaces.
- $prefix = "{$context['seconds_elapsed']} {$context['memory_used']} ";
- }
- MWDebug::debugMsg( "{$prefix}{$text}" );
- }
-
if ( $wgDebugLogPrefix !== '' ) {
$context['prefix'] = $wgDebugLogPrefix;
}
$text = trim( $text );
- if ( $dest === 'all' ) {
- MWDebug::debugMsg( "[{$logGroup}] {$text}\n" );
- }
-
$logger = MWLoggerFactory::getInstance( $logGroup );
$context['private'] = ( $dest === 'private' );
$logger->info( $text, $context );
*
* @since 1.19
* @param string $str
+ * @param array $context
*/
- public static function debugMsg( $str ) {
+ public static function debugMsg( $str, $context = array() ) {
global $wgDebugComments, $wgShowDebug;
if ( self::$enabled || $wgDebugComments || $wgShowDebug ) {
+ if ( $context ) {
+ $prefix = '';
+ if ( isset( $context['prefix'] ) ) {
+ $prefix = $context['prefix'];
+ } elseif ( isset( $context['channel'] ) && $context['channel'] !== 'wfDebug' ) {
+ $prefix = "[{$context['channel']}] ";
+ }
+ if ( isset( $context['seconds_elapsed'] ) && isset( $context['memory_used'] ) ) {
+ $prefix .= "{$context['seconds_elapsed']} {$context['memory_used']} ";
+ }
+ $str = $prefix . $str;
+ }
self::$debug[] = rtrim( UtfNormal::cleanUp( $str ) );
}
}
$destination = self::destination( $this->channel, $message, $context );
self::emit( $text, $destination );
}
+ // Add to debug toolbar
+ MWDebug::debugMsg( $message, array( 'channel' => $this->channel ) + $context );
}