From 1ccbaf801a83b15c0a99bdfc2155869b26260226 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 7 Aug 2024 16:49:12 -0500 Subject: Log out exceptions at the `ERROR` log level Log out any unhandled exceptions at the `ERROR` log level to ensure that any and all unhandled errors show up in the logs under normal running of the application. --- gn_auth/errors.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gn_auth') diff --git a/gn_auth/errors.py b/gn_auth/errors.py index ea1a60e..496b85c 100644 --- a/gn_auth/errors.py +++ b/gn_auth/errors.py @@ -8,7 +8,7 @@ from gn_auth.auth.errors import AuthorisationError def add_trace(exc: Exception, errobj: dict) -> dict: """Add the traceback to the error handling object.""" - current_app.logger.debug("Endpoint: %s\n%s", + current_app.logger.error("Endpoint: %s\n%s", request.url, traceback.format_exception(exc)) return { @@ -18,7 +18,7 @@ def add_trace(exc: Exception, errobj: dict) -> dict: def page_not_found(exc): """404 handler.""" - current_app.logger.debug(f"Page '{request.url}' was not found.", exc_info=True) + current_app.logger.error(f"Page '{request.url}' was not found.", exc_info=True) content_type = request.content_type if bool(content_type) and content_type.lower() == "application/json": return jsonify(add_trace(exc, { @@ -32,7 +32,7 @@ def page_not_found(exc): def handle_general_exception(exc: Exception): """Handle generic unhandled exceptions.""" - current_app.logger.debug("Error occurred!", exc_info=True) + current_app.logger.error("Error occurred!", exc_info=True) content_type = request.content_type if bool(content_type) and content_type.lower() == "application/json": msg = ("The following exception was raised while attempting to access " @@ -50,7 +50,7 @@ def handle_general_exception(exc: Exception): def handle_authorisation_error(exc: AuthorisationError): """Handle AuthorisationError if not handled anywhere else.""" - current_app.logger.debug("Error occurred!", exc_info=True) + current_app.logger.error("Error occurred!", exc_info=True) current_app.logger.error(exc) return jsonify(add_trace(exc, { "error": type(exc).__name__, -- cgit v1.2.3