From 20263a65ff9432ae5dc9a4c5bdbb7f29916e5d04 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Fri, 10 Oct 2014 12:07:22 +1000 Subject: [PATCH] Bring the fakelogging closer to olsotest - use the same log fomat - honor the OS_DEBUG environment variable (off now by default) - quiten sqlalchemy down to warning Change-Id: I828e3bb81b1f97457db3ff8b85db7b23b73a005e --- heat/tests/common.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/heat/tests/common.py b/heat/tests/common.py index c4b3ab381..ff4f79a27 100644 --- a/heat/tests/common.py +++ b/heat/tests/common.py @@ -36,25 +36,32 @@ from heat.tests import fakes from heat.tests import utils -TEST_DEFAULT_LOGLEVELS = {'migrate': logging.WARN} +TEST_DEFAULT_LOGLEVELS = {'migrate': logging.WARN, + 'sqlalchemy': logging.WARN} +_LOG_FORMAT = "%(levelname)8s [%(name)s] %(message)s" +_TRUE_VALUES = ('True', 'true', '1', 'yes') class FakeLogMixin(object): def setup_logging(self): # Assign default logs to self.LOG so we can still # assert on heat logs. + default_level = logging.INFO + if os.environ.get('OS_DEBUG') in _TRUE_VALUES: + default_level = logging.DEBUG + self.LOG = self.useFixture( - fixtures.FakeLogger(level=logging.DEBUG)) + fixtures.FakeLogger(level=default_level, format=_LOG_FORMAT)) base_list = set([nlog.split('.')[0] for nlog in logging.Logger.manager.loggerDict]) for base in base_list: if base in TEST_DEFAULT_LOGLEVELS: self.useFixture(fixtures.FakeLogger( level=TEST_DEFAULT_LOGLEVELS[base], - name=base)) + name=base, format=_LOG_FORMAT)) elif base != 'heat': self.useFixture(fixtures.FakeLogger( - name=base)) + name=base, format=_LOG_FORMAT)) class HeatTestCase(testscenarios.WithScenarios,