Refactored logging of internal server errors. Can now be customized

This commit is contained in:
Armin Ronacher 2011-08-26 21:30:41 +02:00
parent c0f42a0978
commit 2e4c39199d

View file

@ -1216,14 +1216,24 @@ class Flask(_PackageBoundObject):
else: else:
raise e raise e
self.logger.exception('Exception on %s [%s]' % ( self.log_exception((exc_type, exc_value, tb))
request.path,
request.method
))
if handler is None: if handler is None:
return InternalServerError() return InternalServerError()
return handler(e) return handler(e)
def log_exception(self, exc_info):
"""Logs an exception. This is called by :meth:`handle_exception`
if debugging is disabled and right before the handler is called.
The default implementation logs the exception as error on the
:attr:`logger`.
.. versionadded:: 0.8
"""
self.logger.error('Exception on %s [%s]' % (
request.path,
request.method
), exc_info=exc_info)
def raise_routing_exception(self, request): def raise_routing_exception(self, request):
"""Exceptions that are recording during routing are reraised with """Exceptions that are recording during routing are reraised with
this method. During debug we are not reraising redirect requests this method. During debug we are not reraising redirect requests