diff options
author | Gábor Antal <antal@inf.u-szeged.hu> | 2017-02-07 17:54:11 +0100 |
---|---|---|
committer | jiansong <jian.song@easystack.cn> | 2017-03-08 10:00:34 -0800 |
commit | ccceffa7f56bfcc2ff42f98a6272ace866993d09 (patch) | |
tree | 882ec2c0a2410f1f44bda4c62fc14b0726a0b666 /troveclient/client.py | |
parent | 4139774157f960c9ce8786b980473853d6bb7815 (diff) | |
download | python-troveclient-ccceffa7f56bfcc2ff42f98a6272ace866993d09.tar.gz |
Handle log message interpolation by the logger
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.
Also, upgraded hacking requirement, to enable H904 check.
[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Co-Authored-By: jiansong <jian.song@easystack.cn>
Change-Id: I3f020b6bcb1b9bf6d18a3b4f738c13cccd1bbff8
Closes-Bug: #1596829
Diffstat (limited to 'troveclient/client.py')
-rw-r--r-- | troveclient/client.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/troveclient/client.py b/troveclient/client.py index a0a67ae..a6f97ea 100644 --- a/troveclient/client.py +++ b/troveclient/client.py @@ -119,11 +119,11 @@ class HTTPClient(TroveClientMixin): self.auth_system = auth_system self.auth_plugin = auth_plugin - self._logger = logging.getLogger(__name__) - if self.http_log_debug and not self._logger.handlers: + self.LOG = logging.getLogger(__name__) + if self.http_log_debug and not self.LOG.handlers: ch = logging.StreamHandler() - self._logger.setLevel(logging.DEBUG) - self._logger.addHandler(ch) + self.LOG.setLevel(logging.DEBUG) + self.LOG.addHandler(ch) if hasattr(requests, 'logging'): requests.logging.getLogger(requests.__name__).addHandler(ch) @@ -144,12 +144,12 @@ class HTTPClient(TroveClientMixin): if 'data' in kwargs: string_parts.append(" -d '%s'" % (kwargs['data'])) - self._logger.debug("\nREQ: %s\n" % "".join(string_parts)) + self.LOG.debug("\nREQ: %s\n", "".join(string_parts)) def http_log_resp(self, resp): if not self.http_log_debug: return - self._logger.debug( + self.LOG.debug( "RESP: [%s] %s\nRESP BODY: %s\n", resp.status_code, resp.headers, @@ -211,7 +211,7 @@ class HTTPClient(TroveClientMixin): except exceptions.Unauthorized: if auth_attempts > 0: raise - self._logger.debug("Unauthorized, reauthenticating.") + self.LOG.debug("Unauthorized, reauthenticating.") self.management_url = self.auth_token = None # First reauth. Discount this attempt. attempts -= 1 @@ -226,12 +226,12 @@ class HTTPClient(TroveClientMixin): raise except requests.exceptions.ConnectionError as e: # Catch a connection refused from requests.request - self._logger.debug("Connection refused: %s" % e) + self.LOG.debug("Connection refused: %s", e) msg = 'Unable to establish connection: %s' % e raise exceptions.ConnectionRefused(msg) - self._logger.debug( - "Failed attempt(%s of %s), retrying in %s seconds" % - (attempts, self.retries, backoff)) + self.LOG.debug( + "Failed attempt(%s of %s), retrying in %s seconds", + attempts, self.retries, backoff) sleep_lib.sleep(backoff) backoff *= 2 @@ -303,7 +303,7 @@ class HTTPClient(TroveClientMixin): # GET ...:5001/v2.0/tokens/#####/endpoints url = '/'.join([url, 'tokens', '%s?belongsTo=%s' % (self.proxy_token, self.proxy_tenant_id)]) - self._logger.debug("Using Endpoint URL: %s" % url) + self.LOG.debug("Using Endpoint URL: %s", url) resp, body = self.request(url, "GET", headers={'X-Auth-Token': self.auth_token}) return self._extract_service_catalog(url, resp, body, |