* @since 1.25 support for additional context data
*
* @param string $text
- * @param string|bool $dest Unused
+ * @param string|bool $dest Destination of the message:
+ * - 'all': both to the log and HTML (debug toolbar or HTML comments)
+ * - 'private': excluded from HTML output
+ * For backward compatibility, it can also take a boolean:
+ * - true: same as 'all'
+ * - false: same as 'private'
* @param array $context Additional logging context data
*/
function wfDebug( $text, $dest = 'all', array $context = array() ) {
if ( $wgDebugLogPrefix !== '' ) {
$context['prefix'] = $wgDebugLogPrefix;
}
+ $context['private'] = ( $dest === false || $dest === 'private' );
$logger = LoggerFactory::getInstance( 'wfDebug' );
$logger->debug( $text, $context );
* @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
* - 'private': only to the specific log if set in $wgDebugLogGroups and
* discarded otherwise
* For backward compatibility, it can also take a boolean:
function wfDebugLog(
$logGroup, $text, $dest = 'all', array $context = array()
) {
- // Turn $dest into a string if it's a boolean (for b/c)
- if ( $dest === true ) {
- $dest = 'all';
- } elseif ( $dest === false ) {
- $dest = 'private';
- }
-
$text = trim( $text );
$logger = LoggerFactory::getInstance( $logGroup );
- $context['private'] = ( $dest === 'private' );
+ $context['private'] = ( $dest === false || $dest === 'private' );
$logger->info( $text, $context );
}
$destination = self::destination( $this->channel, $message, $context );
self::emit( $text, $destination );
}
- // Add to debug toolbar
- MWDebug::debugMsg( $message, array( 'channel' => $this->channel ) + $context );
+ if ( !isset( $context['private'] ) || !$context['private'] ) {
+ // Add to debug toolbar if not marked as "private"
+ MWDebug::debugMsg( $message, array( 'channel' => $this->channel ) + $context );
+ }
}
/**
// All messages on the wfErrorLog channel should be emitted.
$shouldEmit = true;
+ } elseif ( $channel === 'wfDebug' ) {
+ // wfDebug messages are emitted if a catch all logging file has
+ // been specified. Checked explicitly so that 'private' flagged
+ // messages are not discarded by unset $wgDebugLogGroups channel
+ // handling below.
+ $shouldEmit = $wgDebugLogFile != '';
+
} elseif ( isset( $wgDebugLogGroups[$channel] ) ) {
$logConfig = $wgDebugLogGroups[$channel];