forked from ungleich-public/cdist
Merge pull request #552 from darko-poljak/emulator-logging
Respect cdist log level in emulator.
This commit is contained in:
commit
7361353497
3 changed files with 7 additions and 6 deletions
|
@ -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])
|
||||||
|
|
|
@ -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])
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue