Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| BufferHandler | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| handle | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Logger\Monolog; |
| 8 | |
| 9 | use MediaWiki\Deferred\DeferredUpdates; |
| 10 | use Monolog\Handler\BufferHandler as BaseBufferHandler; |
| 11 | use Monolog\LogRecord; |
| 12 | |
| 13 | /** |
| 14 | * Helper class for the index.php entry point. |
| 15 | * |
| 16 | * Updates \Monolog\Handler\BufferHandler to use DeferredUpdates rather |
| 17 | * than register_shutdown_function. On supported platforms this will |
| 18 | * use register_postsend_function or fastcgi_finish_request() to delay |
| 19 | * until after the request has shutdown and we are no longer delaying |
| 20 | * the web request. |
| 21 | * |
| 22 | * TODO: shutdown is later than postsend. Is this class still useful? |
| 23 | * |
| 24 | * @since 1.26 |
| 25 | * @ingroup Debug |
| 26 | */ |
| 27 | class BufferHandler extends BaseBufferHandler { |
| 28 | /** |
| 29 | * @inheritDoc |
| 30 | */ |
| 31 | public function handle( LogRecord $record ): bool { |
| 32 | if ( !$this->initialized ) { |
| 33 | DeferredUpdates::addCallableUpdate( $this->close( ... ) ); |
| 34 | $this->initialized = true; |
| 35 | } |
| 36 | return parent::handle( $record ); |
| 37 | } |
| 38 | } |