2013-10-26 17:11:46 +02:00
|
|
|
<?php
|
2014-05-12 18:26:17 +02:00
|
|
|
/**
|
|
|
|
* PHPCI - Continuous Integration for PHP
|
|
|
|
*
|
|
|
|
* @copyright Copyright 2014, Block 8 Limited.
|
|
|
|
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
|
|
|
* @link https://www.phptesting.org/
|
|
|
|
*/
|
2013-10-26 17:11:46 +02:00
|
|
|
|
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.
|
2016-07-21 19:20:59 +02:00
|
|
|
* @package PHPCensor\Logging
|
2014-12-08 12:25:33 +01:00
|
|
|
*/
|
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
|
|
|
}
|