Cli: Configure logging properly but also offer customisations
This commit is contained in:
parent
da4387cecd
commit
be239b9a22
|
@ -47,16 +47,41 @@ class Cli extends ApplicationBootstrap
|
||||||
->loadSetupModuleIfNecessary();
|
->loadSetupModuleIfNecessary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
protected function setupLogging()
|
protected function setupLogging()
|
||||||
{
|
{
|
||||||
Logger::create(
|
Logger::create(
|
||||||
new ConfigObject(
|
new ConfigObject(
|
||||||
array(
|
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;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,10 @@ abstract class Command
|
||||||
*/
|
*/
|
||||||
protected $params;
|
protected $params;
|
||||||
protected $screen;
|
protected $screen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use Logger::debug() directly
|
||||||
|
*/
|
||||||
protected $isVerbose;
|
protected $isVerbose;
|
||||||
protected $isDebugging;
|
protected $isDebugging;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue