Cli: Configure logging properly but also offer customisations

This commit is contained in:
Johannes Meyer 2016-01-19 15:07:17 +01:00
parent da4387cecd
commit be239b9a22
2 changed files with 31 additions and 2 deletions

View File

@ -47,16 +47,41 @@ class Cli extends ApplicationBootstrap
->loadSetupModuleIfNecessary();
}
/**
* {@inheritdoc}
*/
protected function setupLogging()
{
Logger::create(
new ConfigObject(
array(
'level' => Logger::INFO,
'log' => 'stdout',
'log' => 'stdout'
)
)
);
return $this;
}
/**
* {@inheritdoc}
*/
protected function setupLogger()
{
$config = new ConfigObject();
$config->log = $this->params->shift('log', 'stdout');
$config->level = $this->params->shift('log-level', Logger::INFO);
if ($config->log === 'file') {
$config->file = $this->params->shiftRequired('log-path');
} elseif ($config->log === 'syslog') {
$config->application = 'icingacli';
}
if ($this->params->shift('verbose', false)) {
$config->level = Logger::DEBUG;
}
Logger::create($config);
return $this;
}

View File

@ -21,6 +21,10 @@ abstract class Command
*/
protected $params;
protected $screen;
/**
* @deprecated Use Logger::debug() directly
*/
protected $isVerbose;
protected $isDebugging;