From dc431762d4e59fb65bc65c3a325ff30b8508edec Mon Sep 17 00:00:00 2001 From: Adirelle Date: Tue, 28 Apr 2015 07:41:49 +0200 Subject: [PATCH] OutputLogHandler: send messages of severity ERROR or higher to stderr. --- PHPCI/Logging/OutputLogHandler.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PHPCI/Logging/OutputLogHandler.php b/PHPCI/Logging/OutputLogHandler.php index 43735c1a..3990e84b 100644 --- a/PHPCI/Logging/OutputLogHandler.php +++ b/PHPCI/Logging/OutputLogHandler.php @@ -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']); } }