Gilles has uploaded a new change for review.
https://gerrit.wikimedia.org/r/201431
Change subject: Add optional per-request hash prefix to debug log entries
......................................................................
Add optional per-request hash prefix to debug log entries
Bug: T94812
Change-Id: I8ee2c2c314c63458f77c6a95306e36b96bc6e2cb
---
M includes/DefaultSettings.php
M includes/GlobalFunctions.php
2 files changed, 23 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/31/201431/1
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 5ab557e..f44a9b6 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -5227,6 +5227,15 @@
$wgDebugLogPrefix = '';
/**
+ * Adds a small hash to the beginning of each debug log entry. This hash is
+ * specific to the current request and is computed on-demand. This lets one
+ * differentiate overlapping requests in the logs.
+ *
+ * @since 1.25
+ */
+$wgDebugLogPerRequestPrefix = false;
+
+/**
* If true, instead of redirecting, show a page with a link to the redirect
* destination. This allows for the inspection of PHP error messages, and easy
* resubmission of form data. For developer use only.
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index bc3a46b..b7a9628 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -1026,7 +1026,7 @@
* @param array $context Additional logging context data
*/
function wfDebug( $text, $dest = 'all', array $context = array() ) {
- global $wgDebugRawPage, $wgDebugLogPrefix;
+ global $wgDebugRawPage, $wgDebugLogPrefix, $wgDebugLogPerRequestPrefix;
global $wgDebugTimestamps, $wgRequestTime;
if ( !$wgDebugRawPage && wfIsDebugRawPage() ) {
@@ -1047,8 +1047,20 @@
);
}
+ $context['prefix'] = '';
+
+ if ( $wgDebugLogPerRequestPrefix === true ) {
+ // Compute it on-demand, because it would be wasteful to
generate it in the config
+ // when debugging is turned off.
+ $wgDebugLogPerRequestPrefix = '[' . bin2hex(
openssl_random_pseudo_bytes( 3 ) ) . '] ';
+ }
+
+ if ( $wgDebugLogPerRequestPrefix ) {
+ $context['prefix'] .= $wgDebugLogPerRequestPrefix;
+ }
+
if ( $wgDebugLogPrefix !== '' ) {
- $context['prefix'] = $wgDebugLogPrefix;
+ $context['prefix'] .= $wgDebugLogPrefix;
}
$logger = MWLoggerFactory::getInstance( 'wfDebug' );
--
To view, visit https://gerrit.wikimedia.org/r/201431
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ee2c2c314c63458f77c6a95306e36b96bc6e2cb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits