Skip to content

Commit c07f05e

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Only add logging handlers if there currently aren't any"
2 parents 3f06551 + e8e7a0e commit c07f05e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

novaclient/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(self, user, password, projectid, auth_url=None,
9191
self.auth_plugin = auth_plugin
9292

9393
self._logger = logging.getLogger(__name__)
94-
if self.http_log_debug:
94+
if self.http_log_debug and not self._logger.handlers:
9595
# Logging level is already set on the root logger
9696
ch = logging.StreamHandler()
9797
self._logger.addHandler(ch)

tests/test_http.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,12 @@ def test_refused_call():
111111
self.assertRaises(exceptions.BadRequest, cl.get, "/hi")
112112

113113
test_refused_call()
114+
115+
def test_client_logger(self):
116+
cl1 = client.HTTPClient("username", "password", "project_id",
117+
"auth_test", http_log_debug=True)
118+
self.assertEquals(len(cl1._logger.handlers), 1)
119+
120+
cl2 = client.HTTPClient("username", "password", "project_id",
121+
"auth_test", http_log_debug=True)
122+
self.assertEquals(len(cl2._logger.handlers), 1)

0 commit comments

Comments
 (0)