Merge "Only add logging handlers if there currently aren't any"
This commit is contained in:
commit
c07f05ed33
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user