Skip to content

Commit

Permalink
Logging: add referer info only to top level errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Valsecchi committed Aug 9, 2017
1 parent 17a3e5a commit 91e3fc2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 4 additions & 2 deletions c2cwsgiutils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def _add_cors(request):
@view_config(context=HTTPException, renderer="json", http_cache=0)
def http_error(exception, request):
LOG.warning("%s %s returned status code %s: %s",
request.method, request.url, exception.status_code, str(exception))
request.method, request.url, exception.status_code, str(exception),
extra={'referer': request.referer})
if request.method != 'OPTIONS':
request.response.status_code = exception.status_code
_add_cors(request)
Expand All @@ -58,7 +59,8 @@ def other_error(exception, request):

def _do_error(request, status, exception):
LOG.error("%s %s returned status code %s: %s",
request.method, request.url, status, str(exception), exc_info=True)
request.method, request.url, status, str(exception),
extra={'referer': request.referer}, exc_info=True)
request.response.status_code = status
_add_cors(request)
response = {"message": str(exception), "status": status}
Expand Down
2 changes: 0 additions & 2 deletions c2cwsgiutils/pyramid_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def filter(self, record):
record.matched_route = request.matched_route.name
record.path = request.path
record.request_id = request.c2c_request_id
if request.referer is not None:
record.referer = request.referer
record.level_name = record.levelname
return True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages


VERSION = '0.19.1'
VERSION = '0.19.2'
HERE = os.path.abspath(os.path.dirname(__file__))
INSTALL_REQUIRES = open(os.path.join(HERE, 'requirements.txt')).read().splitlines()

Expand Down

0 comments on commit 91e3fc2

Please sign in to comment.