move statsd error handler over to django_statsd this admin_log will soon be pointless...

This commit is contained in:
Andy McKay 2012-04-27 16:03:57 -07:00
Родитель 0bbdcd3ff4
Коммит 7ba1ebb43b
4 изменённых файлов: 6 добавлений и 22 удалений

Просмотреть файл

@ -57,7 +57,7 @@ handlers = {
},
'statsd': {
'level': 'ERROR',
'class': 'lib.misc.admin_log.StatsdHandler',
'class': 'django_statsd.loggers.errors.StatsdHandler',
},
'errortype_syslog': {
'class': 'lib.misc.admin_log.ErrorSyslogHandler',

Просмотреть файл

@ -26,7 +26,6 @@ import logging
import traceback
from django.conf import settings
from django_statsd.clients import statsd
from unicode_log import UnicodeHandler
getLogger = logging.getLogger
@ -69,17 +68,6 @@ class ErrorTypeHandler(logging.Handler):
pass
class StatsdHandler(ErrorTypeHandler):
"""Send error to statsd, we'll send this every time."""
def emit(self, record):
if not record.exc_info:
return
statsd.incr('error.%s' % record.exc_info[0].__name__.lower())
self.emitted(self.__class__.__name__.lower())
class ErrorSyslogHandler(UnicodeHandler, ErrorTypeHandler):
"""
Send error to syslog, only if we aren't mailing it. If there is no

Просмотреть файл

@ -28,14 +28,10 @@ cfg = {
'class': 'lib.misc.admin_log.ErrorSyslogHandler',
'formatter': 'error',
},
'test_statsd_handler': {
'class': 'lib.misc.admin_log.StatsdHandler',
},
},
'loggers': {
'test.lib.misc.logging': {
'handlers': ['test_syslog',
'test_statsd_handler'],
'handlers': ['test_syslog'],
'level': 'ERROR',
'propagate': False,
},
@ -84,7 +80,7 @@ class TestErrorLog(amo.tests.TestCase):
exc_info=self.division_error(),
extra={'request': self.request})
eq_(set([n[0][0] for n in emitted.call_args_list]),
set(['statsdhandler', 'errorsysloghandler']))
set(['errorsysloghandler']))
@patch('lib.misc.admin_log.ErrorTypeHandler.emitted')
def test_called_no_email(self, emitted):
@ -92,7 +88,7 @@ class TestErrorLog(amo.tests.TestCase):
exc_info=self.io_error(),
extra={'request': self.request})
eq_(set([n[0][0] for n in emitted.call_args_list]),
set(['errorsysloghandler', 'statsdhandler']))
set(['errorsysloghandler']))
@patch('lib.misc.admin_log.ErrorTypeHandler.emitted')
def test_no_exc_info_request(self, emitted):
@ -105,4 +101,4 @@ class TestErrorLog(amo.tests.TestCase):
self.log.error('blargh!',
exc_info=self.io_error())
eq_(set([n[0][0] for n in emitted.call_args_list]),
set(['errorsysloghandler', 'statsdhandler']))
set(['errorsysloghandler']))

2
vendor

@ -1 +1 @@
Subproject commit 608f16070668949497efae4fdefae4ae36e1df5b
Subproject commit 65d220fca50f6130541c5258a478cab868741eee