php-censor/src/PHPCensor/Logging/OutputLogHandler.php

42 lines
897 B
PHP
Raw Normal View History

<?php
2016-07-19 20:28:11 +02:00
namespace PHPCensor\Logging;
use Monolog\Handler\AbstractProcessingHandler;
use Psr\Log\LogLevel;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class OutputLogHandler outputs the build log to the terminal.
*/
class OutputLogHandler extends AbstractProcessingHandler
{
2013-10-26 17:25:34 +02:00
/**
* @var OutputInterface
*/
protected $output;
/**
* @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;
}
/**
* 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
}