From eca0936a64e9bdefd787a37ccb7657a0d8a7f8d5 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 18 Aug 2017 16:47:35 -0700 Subject: [PATCH] debug: Add cli_argv field to monolog WikiProcessor Follows investigation from T172559, where we found that there is no explicit way to find what script triggered particular error messages when the script was run from the command-line (as opposed to a web request, where the built-in WebProcessor adds fields like http_method and url). Change-Id: Ia9641274a164137dcc30324578d750cc662976ee --- includes/debug/logger/monolog/WikiProcessor.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/includes/debug/logger/monolog/WikiProcessor.php b/includes/debug/logger/monolog/WikiProcessor.php index 5e32887a17..e39a2c300a 100644 --- a/includes/debug/logger/monolog/WikiProcessor.php +++ b/includes/debug/logger/monolog/WikiProcessor.php @@ -35,15 +35,13 @@ class WikiProcessor { */ public function __invoke( array $record ) { global $wgVersion; - $record['extra'] = array_merge( - $record['extra'], - [ - 'host' => wfHostname(), - 'wiki' => wfWikiID(), - 'mwversion' => $wgVersion, - 'reqId' => \WebRequest::getRequestId(), - ] - ); + $record['extra']['host'] = wfHostname(); + $record['extra']['wiki'] = wfWikiID(); + $record['extra']['mwversion'] = $wgVersion; + $record['extra']['reqId'] = \WebRequest::getRequestId(); + if ( PHP_SAPI === 'cli' && isset( $_SERVER['argv'] ) ) { + $record['extra']['cli_argv'] = implode( ' ', $_SERVER['argv'] ); + } return $record; } -- 2.20.1