about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-08-07 16:49:12 -0500
committerFrederick Muriuki Muriithi2024-08-07 16:49:12 -0500
commit1ccbaf801a83b15c0a99bdfc2155869b26260226 (patch)
tree706437e035a20fd371c2ccdf25b7edbb03ab4763
parentba185a1f66590ccd79793357f0d21695189e7950 (diff)
downloadgn-auth-1ccbaf801a83b15c0a99bdfc2155869b26260226.tar.gz
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.
-rw-r--r--gn_auth/errors.py8
1 files changed, 4 insertions, 4 deletions
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__,