Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| WikiProcessor | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| __invoke | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Logger\Monolog; |
| 8 | |
| 9 | use MediaWiki\Http\Telemetry; |
| 10 | use MediaWiki\WikiMap\WikiMap; |
| 11 | use Monolog\LogRecord; |
| 12 | |
| 13 | /** |
| 14 | * Annotate log records with request-global metadata, such as the hostname, |
| 15 | * wiki / request ID, and MediaWiki version. |
| 16 | * |
| 17 | * @since 1.25 |
| 18 | * @ingroup Debug |
| 19 | * @copyright © 2013 Wikimedia Foundation and contributors |
| 20 | */ |
| 21 | class WikiProcessor { |
| 22 | |
| 23 | public function __invoke( LogRecord $record ): LogRecord { |
| 24 | $telemetry = Telemetry::getInstance(); |
| 25 | $record->extra['host'] = wfHostname(); |
| 26 | $record->extra['wiki'] = WikiMap::getCurrentWikiId(); |
| 27 | $record->extra['mwversion'] = MW_VERSION; |
| 28 | $record->extra['reqId'] = $telemetry->getRequestId(); |
| 29 | if ( wfIsCLI() && isset( $_SERVER['argv'] ) ) { |
| 30 | $record->extra['cli_argv'] = implode( ' ', $_SERVER['argv'] ); |
| 31 | } |
| 32 | return $record; |
| 33 | } |
| 34 | |
| 35 | } |