Respect cdist log level in emulator.

This commit is contained in:
Darko Poljak 2017-08-12 21:40:23 +02:00
parent 1fa37566cb
commit 314a931b84
3 changed files with 7 additions and 6 deletions

View file

@ -113,8 +113,8 @@ class Manifest(object):
'__target_host_tags': self.local.target_host_tags, '__target_host_tags': self.local.target_host_tags,
} }
if self.log.getEffectiveLevel() == logging.DEBUG: self.env.update(
self.env.update({'__cdist_debug': "yes"}) {'__cdist_loglevel': str(self.log.getEffectiveLevel())})
def _open_logger(self): def _open_logger(self):
self.log = logging.getLogger(self.target_host[0]) self.log = logging.getLogger(self.target_host[0])

View file

@ -104,10 +104,11 @@ class Emulator(object):
def __init_log(self): def __init_log(self):
"""Setup logging facility""" """Setup logging facility"""
if '__cdist_debug' in self.env: if '__cdist_loglevel' in self.env:
logging.root.setLevel(logging.DEBUG) level = int(self.env['__cdist_loglevel'])
else: else:
logging.root.setLevel(logging.INFO) level = logging.OFF
logging.root.setLevel(level)
self.log = logging.getLogger(self.target_host[0]) self.log = logging.getLogger(self.target_host[0])

View file

@ -136,7 +136,7 @@ class ManifestTestCase(test.CdistTestCase):
current_level = self.log.getEffectiveLevel() current_level = self.log.getEffectiveLevel()
self.log.setLevel(logging.DEBUG) self.log.setLevel(logging.DEBUG)
manifest = cdist.core.manifest.Manifest(self.target_host, self.local) manifest = cdist.core.manifest.Manifest(self.target_host, self.local)
self.assertTrue("__cdist_debug" in manifest.env) self.assertTrue("__cdist_loglevel" in manifest.env)
self.log.setLevel(current_level) self.log.setLevel(current_level)