From 3ac4c445cdbad2ae5343579df4064169f8f39877 Mon Sep 17 00:00:00 2001 From: Marcos Prieto Date: Fri, 10 Nov 2023 10:59:37 +0100 Subject: [PATCH] Log unexpected exceptions in exception view A few of these don't produce any logging in local development making debugging them tricky. Added an explicit logging here. Not sure if this would duplicate logging in a production environment. If that the case we can change this from `exception` to `debug`. --- lms/views/exceptions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lms/views/exceptions.py b/lms/views/exceptions.py index 28422dcc7f..4378d59255 100644 --- a/lms/views/exceptions.py +++ b/lms/views/exceptions.py @@ -1,3 +1,5 @@ +import logging + from pyramid import i18n from pyramid.config import not_ from pyramid.httpexceptions import HTTPClientError @@ -14,6 +16,8 @@ _ = i18n.TranslationStringFactory(__package__) +LOG = logging.getLogger(__name__) + @view_defaults(path_info=not_("^/api/.*"), renderer="lms:templates/error.html.jinja2") class ExceptionViews: @@ -94,6 +98,7 @@ def serializable_error(self): @exception_view_config(context=Exception) def error(self): + LOG.exception("Unexpected error %s", type(self.exception)) return self.error_response( 500, _(