Log handlers: Provide the actual error message on errors.

Previously when we logged errors using logging.error() but didn't
throw an exception, we would send these totally useless error
humbugs/emails that look like this:

Error generated by Anonymous user (not logged in)
No stack trace available

This change makes those messages include the actual text passed to
logging.error(), which is substantially more useful.

(imported from commit 76a8220ffe66d19cb0ca8ba9d1b42d5ecc4fd511)
This commit is contained in:
Tim Abbott 2013-03-15 12:00:28 -04:00
parent 722918aa61
commit d42e8ecb11
1 changed files with 2 additions and 2 deletions

View File

@ -60,7 +60,7 @@ class AdminHumbugHandler(logging.Handler):
request_repr += "- %s: \"%s\"\n" % (field, request.META.get(field, "(None)"))
request_repr += "~~~~"
except Exception:
request_repr = "Request repr() unavailable."
request_repr = "Log record message:\n%s" % (record.getMessage(),)
subject, stack_trace, user_info = format_record(record)
@ -95,7 +95,7 @@ class HumbugAdminEmailHandler(AdminEmailHandler):
request_repr = filter.get_request_repr(request)
except Exception:
request = None
request_repr = "Request repr() unavailable."
request_repr = "Log record message:\n%s" % (record.getMessage(),)
subject, stack_trace, user_info = format_record(record)
message = "Error generated by %s\n\n%s\n\n%s" % (user_info, stack_trace,