Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| LegacyFormatter | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| format | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Logger\Monolog; |
| 8 | |
| 9 | use MediaWiki\Logger\LegacyLogger; |
| 10 | use Monolog\Formatter\NormalizerFormatter; |
| 11 | use Monolog\LogRecord; |
| 12 | |
| 13 | /** |
| 14 | * Log message formatter that mimics the legacy log message formatting of `wfDebug`, `wfDebugLog`, |
| 15 | * `wfLogDBError` and the former `wfErrorLog` global functions by delegating the formatting to |
| 16 | * \MediaWiki\Logger\LegacyLogger. |
| 17 | * |
| 18 | * @deprecated since 1.32 |
| 19 | * @since 1.25 |
| 20 | * @ingroup Debug |
| 21 | * @copyright © 2013 Wikimedia Foundation and contributors |
| 22 | */ |
| 23 | class LegacyFormatter extends NormalizerFormatter { |
| 24 | |
| 25 | public function __construct() { |
| 26 | parent::__construct( 'c' ); |
| 27 | } |
| 28 | |
| 29 | public function format( LogRecord $record ): string { |
| 30 | $normalized = parent::format( $record ); |
| 31 | return LegacyLogger::format( |
| 32 | $normalized['channel'], $normalized['message'], $normalized |
| 33 | ); |
| 34 | } |
| 35 | } |