Skip to content
Snippets Groups Projects
Commit 20f89d1e authored by Jan Mach's avatar Jan Mach
Browse files

Added logging or request.path_full to enable better debugging of BAD REQUEST...

Added logging or request.path_full to enable better debugging of BAD REQUEST and INTERNAL SERVER ERROR errors.
parent f4d19fdd
No related branches found
No related tags found
No related merge requests found
......@@ -191,7 +191,8 @@ def _setup_app_core(app):
def eh_badrequest(err): # pylint: disable=locally-disabled,unused-variable
"""Flask error handler to be called to service HTTP 400 error."""
flask.current_app.logger.critical(
"Bad Request Error:\n%s",
"BAD REQUEST\n\nRequest: %s\nTraceback:\n%s",
flask.request.full_path,
''.join(
traceback.TracebackException(
*sys.exc_info()
......@@ -224,12 +225,13 @@ def _setup_app_core(app):
def eh_internal_server_error(err): # pylint: disable=locally-disabled,unused-variable
"""Flask error handler to be called to service HTTP 500 error."""
flask.current_app.logger.critical(
"Internal Server Error:\n%s",
"INTERNAL SERVER ERROR\n\nRequest: %s\nTraceback:\n%s",
flask.request.full_path,
''.join(
traceback.TracebackException(
*sys.exc_info()
).format()
)
),
)
return hawat.errors.error_handler_switch(500, err)
......
......@@ -302,6 +302,14 @@ class HawatApp(flask.Flask):
else:
raise HawatAppException("Invalid blueprint module '{}', does not provide the 'get_blueprint' factory method.".format(name))
def log_exception(self, exc_info):
"""
Reimplementation of :py:func:`flask.Flask.log_exception` method.
"""
self.logger.error(
"Exception on %s [%s]" % (flask.request.path_full, request.method), exc_info=exc_info
)
def log_exception_with_label(self, tbexc, label = ''):
"""
Log given exception traceback into application logger.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment