2013-10-26 17:11:46 +02:00
|
|
|
<?php
|
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
namespace PHPCensor\Logging;
|
2013-10-26 17:11:46 +02:00
|
|
|
|
|
|
|
use Monolog\Handler\AbstractProcessingHandler;
|
|
|
|
use Psr\Log\LogLevel;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
2014-12-08 12:25:33 +01:00
|
|
|
/**
|
|
|
|
* Class OutputLogHandler outputs the build log to the terminal.
|
|
|
|
*/
|
2013-10-26 17:11:46 +02:00
|
|
|
class OutputLogHandler extends AbstractProcessingHandler
|
|
|
|
{
|
2013-10-26 17:25:34 +02:00
|
|
|
/**
|
|
|
|
* @var OutputInterface
|
|
|
|
*/
|
|
|
|
protected $output;
|
|
|
|
|
2014-12-08 12:25:33 +01:00
|
|
|
/**
|
|
|
|
* @param OutputInterface $output
|
|
|
|
* @param bool|string $level
|
|
|
|
* @param bool $bubble
|
|
|
|
*/
|
2014-02-27 15:23:51 +01:00
|
|
|
public function __construct(
|
2013-10-26 17:25:34 +02:00
|
|
|
OutputInterface $output,
|
|
|
|
$level = LogLevel::INFO,
|
|
|
|
$bubble = true
|
|
|
|
) {
|
|
|
|
parent::__construct($level, $bubble);
|
|
|
|
$this->output = $output;
|
|
|
|
}
|
|
|
|
|
2014-12-08 12:25:33 +01:00
|
|
|
/**
|
|
|
|
* Write a log entry to the terminal.
|
|
|
|
* @param array $record
|
|
|
|
*/
|
2013-10-26 17:25:34 +02:00
|
|
|
protected function write(array $record)
|
|
|
|
{
|
|
|
|
$this->output->writeln((string)$record['formatted']);
|
|
|
|
}
|
2014-02-27 15:23:51 +01:00
|
|
|
}
|