diff --git a/PHPCI/Command/RunCommand.php b/PHPCI/Command/RunCommand.php index c2c352e6..99d895dd 100644 --- a/PHPCI/Command/RunCommand.php +++ b/PHPCI/Command/RunCommand.php @@ -74,14 +74,7 @@ class RunCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; - - // For verbose mode we want to output all informational and above - // messages to the symphony output interface. - if ($input->hasOption('verbose') && $input->getOption('verbose')) { - $this->logger->pushHandler( - new OutputLogHandler($this->output, Logger::INFO) - ); - } + $this->logger->pushHandler(new OutputLogHandler($output)); $running = $this->validateRunningBuilds(); diff --git a/PHPCI/Logging/OutputLogHandler.php b/PHPCI/Logging/OutputLogHandler.php index 4b4c81a4..43735c1a 100644 --- a/PHPCI/Logging/OutputLogHandler.php +++ b/PHPCI/Logging/OutputLogHandler.php @@ -10,6 +10,7 @@ namespace PHPCI\Logging; use Monolog\Handler\AbstractProcessingHandler; +use Monolog\Logger; use Psr\Log\LogLevel; use Symfony\Component\Console\Output\OutputInterface; @@ -20,21 +21,28 @@ use Symfony\Component\Console\Output\OutputInterface; class OutputLogHandler extends AbstractProcessingHandler { /** + * Map verbosity levels to log levels. + * + * @var int[] + */ + static protected $levels = array( + OutputInterface::VERBOSITY_QUIET => Logger::ERROR, + OutputInterface::VERBOSITY_NORMAL => Logger::WARNING, + OutputInterface::VERBOSITY_VERBOSE => Logger::NOTICE, + OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::INFO, + OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG, + ); + * @var OutputInterface */ protected $output; /** * @param OutputInterface $output - * @param bool|string $level - * @param bool $bubble */ - public function __construct( - OutputInterface $output, - $level = LogLevel::INFO, - $bubble = true - ) { - parent::__construct($level, $bubble); + public function __construct(OutputInterface $output) + { + parent::__construct(static::$levels[$output->getVerbosity()]); $this->output = $output; }