Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Log exceptions while logging web requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mkiwala committed Feb 2, 2015
1 parent de24825 commit c2355d0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ptero_common/logging_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ def wrapper(*args, **kwargs):
if 'logger' in kwargs:
del kwargs['logger']

response = target(*args, **kwargs)
try:
response = target(*args, **kwargs)
except Exception as e:
logger.exception(
"Unexpected exception while sending %s request\n"
"Args: %s\n"
"Keyword Args: %s\n"
"Exception: %s\n",
kind.upper(), pformat(args), pformat(kwargs), str(e))
raise

r = Request(kind.upper(), *args, **kwargs)
logger.info("%s from %s %s", response.status_code, kind.upper(), r.url)
Expand Down

0 comments on commit c2355d0

Please sign in to comment.