From 203d6d4c76fbb7f52c507318ef0e92b8d4dba0bf Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 27 Sep 2012 21:51:30 +0000 Subject: NO-JIRA: Fix logging in ha_tests.py In order to suppress unwanted warnings from certain test, the ha_test framework was actually turning off all python logging. This patch selectively turns off wanrnings in specific code regions and then restores the configured logging level. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1391232 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/ha_test.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'cpp/src/tests/ha_test.py') diff --git a/cpp/src/tests/ha_test.py b/cpp/src/tests/ha_test.py index 18a969a07b..2f9d9a1211 100755 --- a/cpp/src/tests/ha_test.py +++ b/cpp/src/tests/ha_test.py @@ -30,6 +30,18 @@ from uuid import UUID log = getLogger(__name__) +class LogLevel: + """ + Temporarily change the log settings on the root logger. + Used to suppress expected WARN messages from the python client. + """ + def __init__(self, level): + self.save_level = getLogger().getEffectiveLevel() + getLogger().setLevel(level) + + def restore(self): + getLogger().setLevel(self.save_level) + class QmfAgent(object): """Access to a QMF broker agent.""" def __init__(self, address, **kwargs): @@ -73,7 +85,6 @@ class HaBroker(Broker): assert os.path.exists(self.qpid_ha_path) self.qpid_config_path=os.path.join(os.getenv("PYTHON_COMMANDS"), "qpid-config") assert os.path.exists(self.qpid_config_path) - getLogger().setLevel(ERROR) # Hide expected WARNING log messages from failover. self.qpid_ha_script=import_script(self.qpid_ha_path) self._agent = None self.client_credentials = client_credentials -- cgit v1.2.1