String interpolation should be delayed

From [1], string interpolation should be delayed to be handled by
the logging code, rather than being done at the point
of the logging call.

[1] https://docs.openstack.org/oslo.i18n/latest/user/
    guidelines.html#adding-variables-to-log-messages

Change-Id: I58ee3e1b4b04ce895a4922491f22094aab0d16d9
Closes-Bug: #1705634
This commit is contained in:
Sharat Sharma 2017-07-21 15:11:05 +05:30
parent d94b82b3bc
commit fec9664699
2 changed files with 4 additions and 6 deletions

View File

@ -50,8 +50,8 @@ LOG = logging.getLogger(__name__)
def log_request(func):
def decorator(self, *args, **kwargs):
resp = func(self, *args, **kwargs)
LOG.debug("HTTP %s %s %d" % (resp.request.method, resp.url,
resp.status_code))
LOG.debug("HTTP %s %s %d", resp.request.method, resp.url,
resp.status_code)
return resp
return decorator

View File

@ -145,10 +145,8 @@ class KeycloakAuthHandler(auth.AuthHandler):
except Exception as e:
raise Exception("Failed to get access token:\n %s" % str(e))
LOG.debug(
"HTTP response from OIDC provider: %s" %
pprint.pformat(resp.json())
)
LOG.debug("HTTP response from OIDC provider: %s",
pprint.pformat(resp.json()))
return resp.json()['access_token']