Add -l/--log-level option. Honor __cdist_loglevel env var. (#572)

Add -l/--log-level option, __cdist_loglevel -> __cdist_log_level; honor __cdist_log_level env var
This commit is contained in:
Darko Poljak 2017-09-09 21:17:29 +02:00 committed by GitHub
commit 3454da076f
23 changed files with 152 additions and 69 deletions

View file

@ -198,10 +198,11 @@ Environment variables (for reading)
-----------------------------------
The following environment variables are exported by cdist:
__cdist_loglevel
__cdist_log_level
String value of cdist log level. One of OFF, ERROR, WARNING, INFO,
VERBOSE, DEBUG and TRACE.
Available for: initial manifest, type manifest, type gencode.
Available for: initial manifest, explorer, type manifest, type explorer,
type gencode.
__explorer
Directory that contains all global explorers.
Available for: initial manifest, explorer, type explorer, shell.
@ -264,6 +265,13 @@ The following environment variables influence the behaviour of cdist:
require
Setup dependencies between objects (see \`cdist manifest <cdist-manifest.html>\`_).
__cdist_log_level
String value of cdist log level. One of OFF, ERROR, WARNING, INFO,
VERBOSE, DEBUG and TRACE. If set cdist will set this log level in
accordance with configuration rules. If cdist invokation is used
in types then nested cdist will honor this specified log level if
not specified otherwise while invoking it.
CDIST_PATH
Colon delimited list of config directories.

View file

@ -333,9 +333,10 @@ So when you generate a script with the following content, it will work:
Log level in types
------------------
cdist log level can be accessed from __cdist_loglevel variable.
cdist log level can be accessed from __cdist_log_level variable.
Value is a string, one of OFF, ERROR, WARNING, INFO, VERBOSE, DEBUG and
TRACE. It is available for initial manifest, type manifest and type gencode.
TRACE. It is available for initial manifest, explorer, type manifest,
type explorer, type gencode.
Hints for typewriters

View file

@ -11,11 +11,12 @@ SYNOPSIS
::
cdist [-h] [-q] [-v] [-V] {banner,config,install,inventory,shell} ...
cdist [-h] [-l LOGLEVEL] [-q] [-v] [-V]
{banner,config,install,inventory,shell} ...
cdist banner [-h] [-q] [-v]
cdist banner [-h] [-l LOGLEVEL] [-q] [-v]
cdist config [-h] [-q] [-v] [-b] [-g CONFIG_FILE]
cdist config [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE]
[-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST]
[-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]]
[-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY]
@ -23,7 +24,7 @@ SYNOPSIS
[-f HOSTFILE] [-p [HOST_MAX]] [-s] [-t]
[host [host ...]]
cdist install [-h] [-q] [-v] [-b] [-g CONFIG_FILE]
cdist install [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE]
[-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST]
[-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]]
[-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY]
@ -31,32 +32,35 @@ SYNOPSIS
[-f HOSTFILE] [-p [HOST_MAX]] [-s] [-t]
[host [host ...]]
cdist inventory [-h] [-q] [-v] [-b] [-g CONFIG_FILE] [-I INVENTORY_DIR]
cdist inventory [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE]
[-I INVENTORY_DIR]
{add-host,add-tag,del-host,del-tag,list} ...
cdist inventory add-host [-h] [-q] [-v] [-b] [-g CONFIG_FILE]
[-I INVENTORY_DIR] [-f HOSTFILE]
cdist inventory add-host [-h] [-l LOGLEVEL] [-q] [-v] [-b]
[-g CONFIG_FILE] [-I INVENTORY_DIR]
[-f HOSTFILE]
[host [host ...]]
cdist inventory add-tag [-h] [-q] [-v] [-b] [-g CONFIG_FILE]
[-I INVENTORY_DIR] [-f HOSTFILE] [-T TAGFILE]
[-t TAGLIST]
cdist inventory add-tag [-h] [-l LOGLEVEL] [-q] [-v] [-b]
[-g CONFIG_FILE] [-I INVENTORY_DIR]
[-f HOSTFILE] [-T TAGFILE] [-t TAGLIST]
[host [host ...]]
cdist inventory del-host [-h] [-q] [-v] [-b] [-g CONFIG_FILE]
[-I INVENTORY_DIR] [-a] [-f HOSTFILE]
cdist inventory del-host [-h] [-l LOGLEVEL] [-q] [-v] [-b]
[-g CONFIG_FILE] [-I INVENTORY_DIR] [-a]
[-f HOSTFILE]
[host [host ...]]
cdist inventory del-tag [-h] [-q] [-v] [-b] [-g CONFIG_FILE]
[-I INVENTORY_DIR] [-a] [-f HOSTFILE]
[-T TAGFILE] [-t TAGLIST]
cdist inventory del-tag [-h] [-l LOGLEVEL] [-q] [-v] [-b]
[-g CONFIG_FILE] [-I INVENTORY_DIR] [-a]
[-f HOSTFILE] [-T TAGFILE] [-t TAGLIST]
[host [host ...]]
cdist inventory list [-h] [-q] [-v] [-b] [-g CONFIG_FILE]
cdist inventory list [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE]
[-I INVENTORY_DIR] [-a] [-f HOSTFILE] [-H] [-t]
[host [host ...]]
cdist shell [-h] [-q] [-v] [-s SHELL]
cdist shell [-h] [-l LOGLEVEL] [-q] [-v] [-s SHELL]
DESCRIPTION
@ -75,16 +79,28 @@ All commands accept the following options:
Show the help screen.
.. option:: -l LOGLEVEL, --log-level LOGLEVEL
Set the specified verbosity level. The levels, in
order from the lowest to the highest, are: ERROR (-1),
WARNING (0), INFO (1), VERBOSE (2), DEBUG (3) TRACE (4
or higher). If used along with -v then -v increases
last set value and -l overwrites last set value.
.. option:: -q, --quiet
Quiet mode: disables logging, including WARNING and ERROR.
.. option:: -v, --verbose
Increase the verbosity level. Every instance of -v increments the verbosity
level by one. Its default value is 0 which includes ERROR and WARNING levels.
The levels, in order from the lowest to the highest, are:
ERROR (-1), WARNING (0), INFO (1), VERBOSE (2), DEBUG (3) TRACE (4 or higher).
Increase the verbosity level. Every instance of -v
increments the verbosity level by one. Its default
value is 0 which includes ERROR and WARNING levels.
The levels, in order from the lowest to the highest,
are: ERROR (-1), WARNING (0), INFO (1), VERBOSE (2),
DEBUG (3) TRACE (4 or higher). If used along with -l
then -l overwrites last set value and -v increases
last set value.
.. option:: -V, --version