Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| OlzCommandOutputLogHandler | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| write | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getDefaultFormatter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /* |
| 6 | * This file is part of the Monolog package. |
| 7 | * |
| 8 | * (c) Jordi Boggiano <j.boggiano@seld.be> |
| 9 | * |
| 10 | * For the full copyright and license information, please view the LICENSE |
| 11 | * file that was distributed with this source code. |
| 12 | */ |
| 13 | |
| 14 | namespace Olz\Command\Common; |
| 15 | |
| 16 | use Monolog\Formatter\FormatterInterface; |
| 17 | use Monolog\Formatter\LineFormatter; |
| 18 | use Monolog\Handler\AbstractProcessingHandler; |
| 19 | use Monolog\Level; |
| 20 | use Monolog\LogRecord; |
| 21 | use Symfony\Component\Console\Output\OutputInterface; |
| 22 | |
| 23 | class OlzCommandOutputLogHandler extends AbstractProcessingHandler { |
| 24 | private OutputInterface $output; |
| 25 | |
| 26 | public function __construct(OutputInterface $output, int|string|Level $level = Level::Debug, bool $bubble = true) { |
| 27 | $this->output = $output; |
| 28 | parent::__construct($level, $bubble); |
| 29 | } |
| 30 | |
| 31 | protected function write(LogRecord $record): void { |
| 32 | $this->output->writeln($record->formatted); |
| 33 | } |
| 34 | |
| 35 | protected function getDefaultFormatter(): FormatterInterface { |
| 36 | return new LineFormatter("%level_name%: %message%"); |
| 37 | } |
| 38 | } |