OutputLogHandler: send messages of severity ERROR or higher to stderr.
This commit is contained in:
parent
16e4516415
commit
dc431762d4
1 changed files with 8 additions and 1 deletions
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue