Ticket #15603: logger.diff
File logger.diff, 2.8 KB (added by , 14 years ago) |
---|
-
docs/topics/logging.txt
327 327 message to stdout. This handler uses the `simple` output 328 328 format. 329 329 330 * ``mail_admins``, an AdminEmailHandler, which will e mail any330 * ``mail_admins``, an AdminEmailHandler, which will e-mail any 331 331 ``ERROR`` level message to the site admins. This handler uses 332 332 the ``special`` filter. 333 333 … … 468 468 Django provides one log handler in addition to those provided by the 469 469 Python logging module. 470 470 471 .. class:: AdminEmailHandler( )471 .. class:: AdminEmailHandler([include_html=False]) 472 472 473 This handler sends an e mail to the site admins for each log473 This handler sends an e-mail to the site admins for each log 474 474 message it receives. 475 475 476 476 If the log record contains a 'request' attribute, the full details 477 of the request will be included in the e mail.477 of the request will be included in the e-mail. 478 478 479 479 If the log record contains stack trace information, that stack 480 trace will be included in the email. 480 trace will be included in the e-mail. 481 482 The ``include_html`` argument of ``AdminEmailHandler`` is used to 483 control whether traceback e-mail sent includes an HTML attachment 484 containing the full content of the debug page that would be produced 485 if ``DEBUG`` was enabled. To set this value in your configuration, include 486 it in the handler definition for ``django.utils.log.AdminEmailHandler``, 487 for example:: 488 489 'handlers': { 490 'mail_admins': { 491 'level': 'ERROR', 492 'class': 'django.utils.log.AdminEmailHandler', 493 'include_html': True, 494 } 495 }, 496 -
django/utils/log.py
48 48 logger.addHandler(NullHandler()) 49 49 50 50 class AdminEmailHandler(logging.Handler): 51 def __init__(self, include_html=False): 52 logging.Handler.__init__(self) 53 self.include_html = include_html 54 51 55 """An exception log handler that emails log entries to site admins 52 56 53 57 If the request is passed as the first argument to the log record, … … 88 92 89 93 message = "%s\n\n%s" % (stack_trace, request_repr) 90 94 reporter = ExceptionReporter(request, is_email=True, *exc_info) 91 html_message = reporter.get_traceback_html()95 html_message = self.include_html and reporter.get_traceback_html() or None 92 96 mail.mail_admins(subject, message, fail_silently=True, 93 97 html_message=html_message)