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,
|
||||
}
|
||||
|
||||
if self.log.getEffectiveLevel() == logging.DEBUG:
|
||||
self.env.update({'__cdist_debug': "yes"})
|
||||
self.env.update(
|
||||
{'__cdist_loglevel': str(self.log.getEffectiveLevel())})
|
||||
|
||||
def _open_logger(self):
|
||||
self.log = logging.getLogger(self.target_host[0])
|
||||
|
|
|
@ -104,10 +104,11 @@ class Emulator(object):
|
|||
def __init_log(self):
|
||||
"""Setup logging facility"""
|
||||
|
||||
if '__cdist_debug' in self.env:
|
||||
logging.root.setLevel(logging.DEBUG)
|
||||
if '__cdist_loglevel' in self.env:
|
||||
level = int(self.env['__cdist_loglevel'])
|
||||
else:
|
||||
logging.root.setLevel(logging.INFO)
|
||||
level = logging.OFF
|
||||
logging.root.setLevel(level)
|
||||
|
||||
self.log = logging.getLogger(self.target_host[0])
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ class ManifestTestCase(test.CdistTestCase):
|
|||
current_level = self.log.getEffectiveLevel()
|
||||
self.log.setLevel(logging.DEBUG)
|
||||
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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue