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

@ -109,9 +109,9 @@ class Emulator(object):
def __init_log(self):
"""Setup logging facility"""
if '__cdist_loglevel' in self.env:
if '__cdist_log_level' in self.env:
try:
loglevel = self.env['__cdist_loglevel']
loglevel = self.env['__cdist_log_level']
# For a text level it returns its numerical value.
level = logging.getLevelName(loglevel)
except ValueError:
@ -121,7 +121,7 @@ class Emulator(object):
try:
logging.root.setLevel(level)
except (ValueError, TypeError):
# if invalid __cdist_loglevel value
# if invalid __cdist_log_level value
logging.root.setLevel(logging.WARNING)
self.log = logging.getLogger(self.target_host[0])