From: Timo Tijhof Date: Fri, 18 Aug 2017 23:47:35 +0000 (-0700) Subject: debug: Add cli_argv field to monolog WikiProcessor X-Git-Tag: 1.31.0-rc.0~2356^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/Category:Foo?a=commitdiff_plain;h=eca0936a64e9bdefd787a37ccb7657a0d8a7f8d5;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; }