diff options
author | Alan Conway <aconway@apache.org> | 2012-09-27 21:51:30 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2012-09-27 21:51:30 +0000 |
commit | 203d6d4c76fbb7f52c507318ef0e92b8d4dba0bf (patch) | |
tree | e210086d914489db14b8e06bb5b12d32731adf85 /cpp/src/tests/ha_test.py | |
parent | b59d102288a4d59d42eddd1361a3106cad264dd6 (diff) | |
download | qpid-python-203d6d4c76fbb7f52c507318ef0e92b8d4dba0bf.tar.gz |
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
Diffstat (limited to 'cpp/src/tests/ha_test.py')
-rwxr-xr-x | cpp/src/tests/ha_test.py | 13 |
1 files changed, 12 insertions, 1 deletions
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 |