OutputLogHandler: filter messages according to verbosity level.
This commit is contained in:
parent
8bf1d09afd
commit
16e4516415
2 changed files with 17 additions and 16 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue