[cdist.emulator] Fix setting of log level (tests OK)

This commit is contained in:
Dennis Camera 2020-11-11 15:16:33 +01:00
parent 0ee3fda94d
commit c39eb1dbce

View file

@ -120,17 +120,18 @@ class Emulator:
level = logging.WARNING
else:
level = logging.WARNING
self.log = logging.getLogger(self.target_host[0])
try:
logging.root.setLevel(level)
self.log.setLevel(level)
except (ValueError, TypeError):
# if invalid __cdist_log_level value
logging.root.setLevel(logging.WARNING)
self.log.setLevel(logging.WARNING)
colored_log = self.env.get('__cdist_colored_log', 'false')
cdist.log.CdistFormatter.USE_COLORS = colored_log == 'true'
self.log = logging.getLogger(self.target_host[0])
def commandline(self):
"""Parse command line"""