diff --git a/novaclient/client.py b/novaclient/client.py index 0cf595b99..bb963ce70 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -91,7 +91,7 @@ class HTTPClient(object): self.auth_plugin = auth_plugin self._logger = logging.getLogger(__name__) - if self.http_log_debug: + if self.http_log_debug and not self._logger.handlers: # Logging level is already set on the root logger ch = logging.StreamHandler() self._logger.addHandler(ch) diff --git a/tests/test_http.py b/tests/test_http.py index e89ad3fba..7925a91f0 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -111,3 +111,12 @@ class ClientTest(utils.TestCase): self.assertRaises(exceptions.BadRequest, cl.get, "/hi") test_refused_call() + + def test_client_logger(self): + cl1 = client.HTTPClient("username", "password", "project_id", + "auth_test", http_log_debug=True) + self.assertEquals(len(cl1._logger.handlers), 1) + + cl2 = client.HTTPClient("username", "password", "project_id", + "auth_test", http_log_debug=True) + self.assertEquals(len(cl2._logger.handlers), 1)