diff --git a/PHPCI/Logging/OutputLogHandler.php b/PHPCI/Logging/OutputLogHandler.php
index 0726a299..0493cfe7 100644
--- a/PHPCI/Logging/OutputLogHandler.php
+++ b/PHPCI/Logging/OutputLogHandler.php
@@ -39,13 +39,14 @@ class OutputLogHandler extends AbstractProcessingHandler
/**
* Map log levels to colors.
*
- * @var string[]
+ * @var array
*/
static protected $colors = array(
Logger::ERROR => 'red',
Logger::WARNING => 'yellow',
Logger::NOTICE => 'green',
- Logger::INFO => 'white'
+ // No color markup below NOTICE
+ Logger::INFO => false
);
/**
@@ -97,6 +98,8 @@ class OutputLogHandler extends AbstractProcessingHandler
*
* @param array $record
* @return array
+ *
+ * @internal Used as a Processor.
*/
public function addConsoleColor($record)
{
@@ -106,7 +109,10 @@ class OutputLogHandler extends AbstractProcessingHandler
}
}
- $record['message'] = sprintf('%s', $color, rtrim($record['message']), $color);
+ if ($color !== false) {
+ $record['message'] = sprintf('%s', $color, rtrim($record['message']), $color);
+ }
+
return $record;
}
}
diff --git a/Tests/PHPCI/Logging/OutputLogHandlerTest.php b/Tests/PHPCI/Logging/OutputLogHandlerTest.php
new file mode 100644
index 00000000..ce4b9518
--- /dev/null
+++ b/Tests/PHPCI/Logging/OutputLogHandlerTest.php
@@ -0,0 +1,77 @@
+prophesize('\Symfony\Component\Console\Output\OutputInterface');
+ $output->getVerbosity()->willReturn($verbosity);
+
+ $handler = new OutputLogHandler($output->reveal());
+
+ $this->assertEquals($level, $handler->getLevel());
+ }
+
+
+ public function getVerbosityLevelMap()
+ {
+ return array(
+ array(OutputInterface::VERBOSITY_QUIET, Logger::ERROR),
+ array(OutputInterface::VERBOSITY_NORMAL, Logger::WARNING),
+ array(OutputInterface::VERBOSITY_VERBOSE, Logger::NOTICE),
+ array(OutputInterface::VERBOSITY_VERY_VERBOSE, Logger::INFO),
+ array(OutputInterface::VERBOSITY_DEBUG, Logger::DEBUG),
+ );
+ }
+
+ public function testSendInfoToOutput()
+ {
+ $record = array('message' => 'FOO', 'level' => Logger::INFO);
+
+ $output = $this->prophesize('\Symfony\Component\Console\Output\ConsoleOutputInterface');
+ $output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_DEBUG);
+ $output->getErrorOutput()->shouldNotBeCalled();
+ $output->write('BAR')->shouldBeCalled();
+
+ $formatter = $this->prophesize('\Monolog\Formatter\FormatterInterface');
+ $formatter->format($record)->willReturn('BAR');
+
+ $handler = new OutputLogHandler($output->reveal());
+ $handler->setFormatter($formatter->reveal());
+
+ $handler->handle($record);
+ }
+
+ public function testSendErrorsToStderr()
+ {
+ $record = array('message' => 'FOO', 'level' => Logger::ERROR);
+
+ $error = $this->prophesize('\Symfony\Component\Console\Output\OutputInterface');
+ $error->write('BAR')->shouldBeCalled();
+
+ $output = $this->prophesize('\Symfony\Component\Console\Output\ConsoleOutputInterface');
+ $output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_DEBUG);
+ $output->getErrorOutput()->willReturn($error);
+
+ $formatter = $this->prophesize('\Monolog\Formatter\FormatterInterface');
+ $formatter->format(array('message' => 'FOO', 'level' => Logger::ERROR))->willReturn('BAR');
+
+ $handler = new OutputLogHandler($output->reveal());
+ $handler->setFormatter($formatter->reveal());
+
+ $handler->handle($record);
+ }
+}