コード例 #1
0
 def test_custom_exception_reporter_is_used(self):
     record = self.logger.makeRecord('name', logging.ERROR, 'function', 'lno', 'message', None, None)
     record.request = self.request_factory.get('/')
     handler = AdminEmailHandler(reporter_class='logging_tests.logconfig.CustomExceptionReporter')
     handler.emit(record)
     self.assertEqual(len(mail.outbox), 1)
     msg = mail.outbox[0]
     self.assertEqual(msg.body, 'message\n\ncustom traceback text')
コード例 #2
0
 def emit(self, record):
     try:
         count = new_email()
     except Exception:
         traceback.print_exc()
     else:
         if count >= self.throttle:
             return
     AdminEmailHandler.emit(self, record)
コード例 #3
0
ファイル: tests.py プロジェクト: thibaudcolas/django
 def test_custom_exception_reporter_is_used(self):
     record = self.logger.makeRecord("name", logging.ERROR, "function",
                                     "lno", "message", None, None)
     record.request = self.request_factory.get("/")
     handler = AdminEmailHandler(
         reporter_class="logging_tests.logconfig.CustomExceptionReporter")
     handler.emit(record)
     self.assertEqual(len(mail.outbox), 1)
     msg = mail.outbox[0]
     self.assertEqual(msg.body, "message\n\ncustom traceback text")
コード例 #4
0
 def test_emit_no_form_tag(self):
     """HTML email doesn't contain forms."""
     handler = AdminEmailHandler(include_html=True)
     record = self.logger.makeRecord(
         'name', logging.ERROR, 'function', 'lno', 'message', None, None,
     )
     handler.emit(record)
     self.assertEqual(len(mail.outbox), 1)
     msg = mail.outbox[0]
     self.assertEqual(msg.subject, '[Django] ERROR: message')
     self.assertEqual(len(msg.alternatives), 1)
     body_html = str(msg.alternatives[0][0])
     self.assertIn('<div id="traceback">', body_html)
     self.assertNotIn('<form', body_html)
コード例 #5
0
ファイル: log.py プロジェクト: rpatterson/django-jira
 def fire_email(self, record, exc_info=None):
     mail_handler = AdminEmailHandler(include_html=self.include_html)
     mail_handler.emit(record)
     mail_handler.emit(JiraRecord(record, exc_info))
コード例 #6
0
ファイル: log.py プロジェクト: cikorka/django-jira
 def fire_email(self, record, exc_info=None):
     mail_handler = AdminEmailHandler(include_html=self.include_html)
     mail_handler.emit(record)
     mail_handler.emit(JiraRecord(record, exc_info))