cope without the request and don't even bother with arecibo at the moment (bug 745917)
This commit is contained in:
Родитель
a0c5e549bb
Коммит
8f1d3754b8
|
@ -84,8 +84,7 @@ loggers = {
|
|||
'propagate': True,
|
||||
},
|
||||
'z.celery': {
|
||||
'handlers': ['mail_admins', 'errortype_syslog',
|
||||
'statsd', 'arecibo'],
|
||||
'handlers': ['mail_admins', 'errortype_syslog', 'statsd'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True,
|
||||
},
|
||||
|
|
|
@ -57,7 +57,7 @@ class ErrorTypeHandler(logging.Handler):
|
|||
# other handlers to decide to use this information.
|
||||
|
||||
# If this has no exc_info or request, fail fast.
|
||||
if not record.exc_info or not record.request:
|
||||
if not record.exc_info:
|
||||
return False
|
||||
|
||||
tb = '\n'.join(traceback.format_exception(*record.exc_info))
|
||||
|
@ -88,7 +88,8 @@ class AreciboHandler(ErrorTypeHandler):
|
|||
|
||||
def emit(self, record):
|
||||
arecibo = getattr(settings, 'ARECIBO_SERVER_URL', '')
|
||||
if not self.should_email(record) or not arecibo:
|
||||
if (not self.should_email(record) or not arecibo
|
||||
or not getattr(record, 'request', None)):
|
||||
return
|
||||
|
||||
post(record.request, 500)
|
||||
|
@ -97,15 +98,16 @@ class AreciboHandler(ErrorTypeHandler):
|
|||
|
||||
class ErrorSyslogHandler(UnicodeHandler, ErrorTypeHandler):
|
||||
"""
|
||||
Send error to syslog, only if we aren't mailing it. This should only
|
||||
be used for errors that have a request attached.
|
||||
Send error to syslog, only if we aren't mailing it. If there is no
|
||||
request, cope.
|
||||
"""
|
||||
|
||||
def emit(self, record):
|
||||
if not getattr(record, 'request', None):
|
||||
return
|
||||
record.request_path = ''
|
||||
else:
|
||||
record.request_path = record.request.path
|
||||
|
||||
record.request_path = record.request.path
|
||||
UnicodeHandler.emit(self, record)
|
||||
self.emitted(self.__class__.__name__.lower())
|
||||
|
||||
|
|
|
@ -111,4 +111,21 @@ class TestErrorLog(amo.tests.TestCase):
|
|||
def test_no_exc_info_request(self, emitted):
|
||||
self.log.error('blargh!')
|
||||
eq_(set([n[0][0] for n in emitted.call_args_list]),
|
||||
set([]))
|
||||
set(['errorsysloghandler']))
|
||||
|
||||
@patch('lib.misc.admin_log.ErrorTypeHandler.emitted')
|
||||
@patch.object(settings, 'ARECIBO_SERVER_URL', 'something')
|
||||
def test_no_request(self, emitted):
|
||||
self.log.error('blargh!',
|
||||
exc_info=self.io_error())
|
||||
eq_(set([n[0][0] for n in emitted.call_args_list]),
|
||||
set(['errorsysloghandler', 'statsdhandler']))
|
||||
|
||||
@patch('lib.misc.admin_log.ErrorTypeHandler.emitted')
|
||||
@patch.object(settings, 'ARECIBO_SERVER_URL', 'something')
|
||||
def test_no_request(self, emitted):
|
||||
self.log.error('blargh!',
|
||||
exc_info=self.division_error())
|
||||
eq_(set([n[0][0] for n in emitted.call_args_list]),
|
||||
set(['errorsysloghandler', 'statsdhandler',
|
||||
'adminemailhandler']))
|
||||
|
|
Загрузка…
Ссылка в новой задаче