Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ProfilerOutput | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| canUse | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| logsToOutput | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| log | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Profiler\Output; |
| 8 | |
| 9 | use MediaWiki\Logger\LoggerFactory; |
| 10 | use MediaWiki\Profiler\Profiler; |
| 11 | use Psr\Log\LoggerInterface; |
| 12 | |
| 13 | /** |
| 14 | * Base class for profiling output. |
| 15 | * |
| 16 | * @ingroup Profiler |
| 17 | * @since 1.25 |
| 18 | */ |
| 19 | abstract class ProfilerOutput { |
| 20 | /** @var Profiler */ |
| 21 | protected $collector; |
| 22 | /** @var LoggerInterface */ |
| 23 | protected $logger; |
| 24 | /** @var array Configuration of $wgProfiler */ |
| 25 | protected $params; |
| 26 | |
| 27 | /** |
| 28 | * @param Profiler $collector The actual profiler |
| 29 | * @param array $params Configuration array, passed down from $wgProfiler |
| 30 | */ |
| 31 | public function __construct( Profiler $collector, array $params ) { |
| 32 | $this->collector = $collector; |
| 33 | $this->params = $params; |
| 34 | $this->logger = LoggerFactory::getInstance( 'profiler' ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Can this output type be used? |
| 39 | * @return bool |
| 40 | */ |
| 41 | public function canUse() { |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * May the log() try to write to standard output? |
| 47 | * @return bool |
| 48 | * @since 1.33 |
| 49 | */ |
| 50 | public function logsToOutput() { |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Log MediaWiki-style profiling data. |
| 56 | * |
| 57 | * For classes that enable logsToOutput(), this must not |
| 58 | * be called unless Profiler::setAllowOutput is enabled. |
| 59 | * |
| 60 | * @param array $stats Result of Profiler::getFunctionStats() |
| 61 | */ |
| 62 | abstract public function log( array $stats ); |
| 63 | } |
| 64 | |
| 65 | /** @deprecated class alias since 1.46 */ |
| 66 | class_alias( ProfilerOutput::class, 'ProfilerOutput' ); |