From 6dfa95e390abd490b8e80cf98f2e4b11b8e46e4e Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 28 Oct 2013 21:14:34 +0000 Subject: [PATCH] Include name/level in unit test log messages Use a more informative format than just the raw message string in log messages captured by fixtures.FakeLogger during unit testing. For example, this changes cryptic unit test output such as pythonlogging:'': {{{ 214 -> 215... done 215 -> 216... done }}} into: pythonlogging:'': {{{ INFO [migrate.versioning.api] 214 -> 215... INFO [migrate.versioning.api] done INFO [migrate.versioning.api] 215 -> 216... INFO [migrate.versioning.api] done }}} which instantly makes it clearer that these numbers come from database migrations. Change-Id: I56b6fa03892e6d865ccb036fdf75d2bb499b6c93 --- nova/test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/test.py b/nova/test.py index f32ca621f359..b602985f3e81 100644 --- a/nova/test.py +++ b/nova/test.py @@ -223,7 +223,8 @@ class TestCase(testtools.TestCase): stderr = self.useFixture(fixtures.StringStream('stderr')).stream self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) - self.log_fixture = self.useFixture(fixtures.FakeLogger()) + fs = '%(levelname)s [%(name)s] %(message)s' + self.log_fixture = self.useFixture(fixtures.FakeLogger(format=fs)) self.useFixture(conf_fixture.ConfFixture(CONF)) if self.USES_DB: