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