Skip to content

Commit

Permalink
Changed log message formating to use %
Browse files Browse the repository at this point in the history
=> So that it does not format the
string before checking the log level and eventually does not log the
message...
Have set the root logger to ERROR level as well.
  • Loading branch information
vince committed Jan 12, 2018
1 parent 14eca20 commit 2371341
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bottle_oauthlib/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,22 @@ def set_response(bottle_request, bottle_response, status, headers, body, force_j
if not isinstance(body, str):
raise TypeError("a str-like object is required, not {0}".format(type(body)))

log.debug(f"Creating bottle response from string body {body}...")
log.debug("Creating bottle response from string body %s...", body)

try:
values = json.loads(body)
except json.decoder.JSONDecodeError:
# consider body as string but not JSON, we stop here.
bottle_response.body = body
log.debug(f"Body Bottle response body created as is :{bottle_response.body}")
log.debug("Body Bottle response body created as is: %", bottle_response.body)
else: # consider body as JSON
# request want a json as response
if force_json is True or (
"Accept" in bottle_request.headers and
"application/json" == bottle_request.headers["Accept"]):
bottle_response["Content-Type"] = "application/json;charset=UTF-8"
bottle_response.body = body
log.debug(f"Body Bottle response body created as json:{bottle_response.body}")
log.debug("Body Bottle response body created as json: %r", bottle_response.body)
else:
from urllib.parse import quote

Expand All @@ -116,7 +116,7 @@ def set_response(bottle_request, bottle_response, status, headers, body, force_j
quote(v) if isinstance(v, str) else v
) for k, v in values.items()
])
log.debug(f"Body Bottle response body created as form-urlencoded:{bottle_response.body}")
log.debug("Body Bottle response body created as form-urlencoded: %r", bottle_response.body)


class BottleOAuth2(object):
Expand Down

0 comments on commit 2371341

Please sign in to comment.