OutputLogHandler: send messages of severity ERROR or higher to stderr.

This commit is contained in:
Adirelle 2015-04-28 07:41:49 +02:00
commit dc431762d4

View file

@ -12,6 +12,7 @@ namespace PHPCI\Logging;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;
use Psr\Log\LogLevel;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
@ -52,6 +53,12 @@ class OutputLogHandler extends AbstractProcessingHandler
*/
protected function write(array $record)
{
$this->output->writeln((string)$record['formatted']);
if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) {
$output = $this->output->getErrorOutput();
} else {
$output = $this->output;
}
$output->write($record['formatted']);
}
}