jenkins-bot has submitted this change and it was merged.
Change subject: Exclude debug log events marked "private" from MWDebug
......................................................................
Exclude debug log events marked "private" from MWDebug
Respect the "private" context variable for debug log events when passing
events from MediaWiki\Logger\LegacyLogger to MWDebug::debugMsg. Passing
debug log events marked as private to MWDebug was a regression
introduced by the PSR-3 logging system.
Restore handling of $dest argument to wfDebug which was removed in 1.25
with the PSR-3 logging conversion. The documentation for $dest = 'log'
has also been removed. This third debug log event handling option was
not implemented in the PSR-3 logging conversion in 1.25. A follow up
change will remove known usage of $dest = 'log' in core.
Bug: T122644
Change-Id: Ib1d999b8b54e584e3944b46e9163a700f11c2e72
---
M includes/GlobalFunctions.php
M includes/debug/logger/LegacyLogger.php
2 files changed, 19 insertions(+), 12 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index e30b371..47d086b 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -1038,7 +1038,12 @@
* @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() ) {
@@ -1065,6 +1070,7 @@
if ( $wgDebugLogPrefix !== '' ) {
$context['prefix'] = $wgDebugLogPrefix;
}
+ $context['private'] = ( $dest === false || $dest === 'private' );
$logger = LoggerFactory::getInstance( 'wfDebug' );
$logger->debug( $text, $context );
@@ -1126,7 +1132,6 @@
* @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:
@@ -1137,17 +1142,10 @@
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 );
}
diff --git a/includes/debug/logger/LegacyLogger.php
b/includes/debug/logger/LegacyLogger.php
index ef7d819..34ea641 100644
--- a/includes/debug/logger/LegacyLogger.php
+++ b/includes/debug/logger/LegacyLogger.php
@@ -90,8 +90,10 @@
$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 );
+ }
}
/**
@@ -116,6 +118,13 @@
// 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];
--
To view, visit https://gerrit.wikimedia.org/r/261641
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1d999b8b54e584e3944b46e9163a700f11c2e72
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits