Skip to content

Commit

Permalink
Fix Tornado request logging
Browse files Browse the repository at this point in the history
- Fix requests getting logged twice.
- Fix API v2 HTTPErrors getting logged as warnings.
  • Loading branch information
sharkykh committed May 20, 2019
1 parent 609ca69 commit 489de95
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions medusa/server/api/v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,24 @@ def write_error(self, status_code, *args, **kwargs):

self.finish(response)

def log_exception(self, typ, value, tb):
"""
Customize logging of uncaught exceptions.
Only logs unhandled exceptions, as ``HTTPErrors`` are common for a RESTful API handler.
"""
if not app.WEB_LOG:
return

if isinstance(value, HTTPError):
return

log.error('Uncaught exception: {summary}\n{req!r}', {
'summary': self._request_summary(),
'req': self.request,
'exc_info': (typ, value, tb),
})

def options(self, *args, **kwargs):
"""OPTIONS HTTP method."""
self._no_content()
Expand Down

0 comments on commit 489de95

Please sign in to comment.