summaryrefslogtreecommitdiff
path: root/django/utils/log.py
diff options
context:
space:
mode:
authorHannes Struss <x@hannesstruss.de>2012-11-19 18:57:40 +0100
committerHannes Struss <x@hannesstruss.de>2012-11-20 11:23:12 +0100
commitf9891f20872e2a468c4910a968c5e2fae75d0e51 (patch)
tree1bddda217aa8a319b57801f84f560a658324ee1d /django/utils/log.py
parent1f1f60d12f78ee68d59b577fdb6a31857b1d0f44 (diff)
Fixed #19325 - Made email backend of AdminEmailHandler configurable
Diffstat (limited to 'django/utils/log.py')
-rw-r--r--django/utils/log.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/django/utils/log.py b/django/utils/log.py
index 4806527e84..736154a178 100644
--- a/django/utils/log.py
+++ b/django/utils/log.py
@@ -3,6 +3,7 @@ import traceback
from django.conf import settings
from django.core import mail
+from django.core.mail import get_connection
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
@@ -76,9 +77,10 @@ class AdminEmailHandler(logging.Handler):
request data will be provided in the email report.
"""
- def __init__(self, include_html=False):
+ def __init__(self, include_html=False, email_backend=None):
logging.Handler.__init__(self)
self.include_html = include_html
+ self.email_backend = email_backend
def emit(self, record):
try:
@@ -110,7 +112,12 @@ class AdminEmailHandler(logging.Handler):
message = "%s\n\n%s" % (stack_trace, request_repr)
reporter = ExceptionReporter(request, is_email=True, *exc_info)
html_message = self.include_html and reporter.get_traceback_html() or None
- mail.mail_admins(subject, message, fail_silently=True, html_message=html_message)
+ mail.mail_admins(subject, message, fail_silently=True,
+ html_message=html_message,
+ connection=self.connection())
+
+ def connection(self):
+ return get_connection(backend=self.email_backend)
def format_subject(self, subject):
"""