cli: Polish log handling
* Reintroduced Command::$isDebugging, now without typo * Removed @deprecated from Command::$isVerbose * Changed default log level to WARNING * Adjusted --verbose and --debug to activate log level INFO and DEBUG, respectively
This commit is contained in:
parent
2cf8471a00
commit
9240d1b4e0
|
@ -70,16 +70,18 @@ class Cli extends ApplicationBootstrap
|
||||||
{
|
{
|
||||||
$config = new ConfigObject();
|
$config = new ConfigObject();
|
||||||
$config->log = $this->params->shift('log', 'stdout');
|
$config->log = $this->params->shift('log', 'stdout');
|
||||||
$config->level = $this->params->shift('log-level', Logger::INFO);
|
|
||||||
if ($config->log === 'file') {
|
if ($config->log === 'file') {
|
||||||
$config->file = $this->params->shiftRequired('log-path');
|
$config->file = $this->params->shiftRequired('log-path');
|
||||||
} elseif ($config->log === 'syslog') {
|
} elseif ($config->log === 'syslog') {
|
||||||
$config->application = 'icingacli';
|
$config->application = 'icingacli';
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use shift() instead once Command::$isVerbose has been dropped
|
|
||||||
if ($this->params->get('verbose', false)) {
|
if ($this->params->get('verbose', false)) {
|
||||||
|
$config->level = Logger::INFO;
|
||||||
|
} elseif ($this->params->get('debug', false)) {
|
||||||
$config->level = Logger::DEBUG;
|
$config->level = Logger::DEBUG;
|
||||||
|
} else {
|
||||||
|
$config->level = Logger::WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::create($config);
|
Logger::create($config);
|
||||||
|
|
|
@ -8,7 +8,6 @@ use Icinga\Util\Translator;
|
||||||
use Icinga\Cli\Params;
|
use Icinga\Cli\Params;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Application\ApplicationBootstrap as App;
|
use Icinga\Application\ApplicationBootstrap as App;
|
||||||
use Exception;
|
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
|
||||||
abstract class Command
|
abstract class Command
|
||||||
|
@ -23,10 +22,19 @@ abstract class Command
|
||||||
protected $screen;
|
protected $screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use Logger::debug() directly
|
* Whether the --verbose switch is given and thus the set log level INFO is
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $isVerbose;
|
protected $isVerbose;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the --debug switch is given and thus the set log level DEBUG is
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $isDebugging;
|
||||||
|
|
||||||
protected $moduleName;
|
protected $moduleName;
|
||||||
protected $commandName;
|
protected $commandName;
|
||||||
protected $actionName;
|
protected $actionName;
|
||||||
|
@ -47,6 +55,7 @@ abstract class Command
|
||||||
$this->screen = Screen::instance($app);
|
$this->screen = Screen::instance($app);
|
||||||
$this->trace = $this->params->shift('trace', false);
|
$this->trace = $this->params->shift('trace', false);
|
||||||
$this->isVerbose = $this->params->shift('verbose', false);
|
$this->isVerbose = $this->params->shift('verbose', false);
|
||||||
|
$this->isDebugging = $this->params->shift('debug', false);
|
||||||
if ($initialize) {
|
if ($initialize) {
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,11 +50,13 @@ class Documentation
|
||||||
$d .= ' ' . $module . "\n";
|
$d .= ' ' . $module . "\n";
|
||||||
}
|
}
|
||||||
$d .= "\nGlobal options:\n\n"
|
$d .= "\nGlobal options:\n\n"
|
||||||
. " --verbose Be verbose\n"
|
. " --log [t] Log to <t>, either stdout, file or syslog (default: stdout)\n"
|
||||||
. " --debug Show debug output\n"
|
. " --log-path <f> Which file to log into in case of --log file\n"
|
||||||
. " --help Show help\n"
|
. " --verbose Be verbose\n"
|
||||||
. " --benchmark Show benchmark summary\n"
|
. " --debug Show debug output\n"
|
||||||
. " --watch [s] Refresh output every <s> seconds (default: 5)\n"
|
. " --help Show help\n"
|
||||||
|
. " --benchmark Show benchmark summary\n"
|
||||||
|
. " --watch [s] Refresh output every <s> seconds (default: 5)\n"
|
||||||
;
|
;
|
||||||
$d .= "\nShow help on a specific command : icingacli help <command>"
|
$d .= "\nShow help on a specific command : icingacli help <command>"
|
||||||
. "\nShow help on a specific module : icingacli help <module>"
|
. "\nShow help on a specific module : icingacli help <module>"
|
||||||
|
|
Loading…
Reference in New Issue