jorgebastida / django-dajax

Easy to use library to create asynchronous presentation logic with django and dajaxice
http://dajaxproject.com/
BSD 3-Clause "New" or "Revised" License
346 stars 99 forks source link

Sentry support #58

Open dbrgn opened 11 years ago

dbrgn commented 11 years ago

Is it possible to integrate dajax/dajaxice with Sentry/Raven? I tried to add a logger, but nothing seems to get sent to my server, even though I triggered an error in the ajax view in production mode.

My logging config:

LOGGING['root'] = {
    'level': 'WARNING',
    'handlers': ['sentry'],
}
LOGGING['handlers']['sentry'] = {
    'level': 'ERROR',
    'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
}
LOGGING['loggers']['sentry.errors'] = {
    'level': 'DEBUG',
    'handlers': ['console'],
    'propagate': False,
}
LOGGING['loggers']['raven'] = {
    'level': 'DEBUG',
    'handlers': ['console'],
    'propagate': False,
}
LOGGING['loggers']['dajaxice'] = {
    'handlers': ['sentry'],
    'level': 'WARNING',
    'propagate': False,
}
h3 commented 11 years ago

I managed to make it work, but for some reasons it doesn't seem to work once deployed in production..

Here's my config:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        },
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'sentry': {
            'level': 'ERROR',
            'class': 'raven.contrib.django.handlers.SentryHandler',
        },
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'console':{
            'level':'DEBUG',
            'class':'logging.StreamHandler',
            'formatter': 'simple'
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins', 'console', 'sentry'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'dajaxice': {
            'handlers': ['console', 'sentry'],
            'level': 'WARNING',
            'propagate': False,
        },
        'sentry.errors': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
    }
}
h3 commented 11 years ago

Ok .. after much more digging I found out what's going on.

This is a problem with dajaxice, not sentry :)

This is caused by dajaxice not logging the traceback. An issue about this problem is open since 4 months ..

https://github.com/jorgebastida/django-dajaxice/issues/88

I forked it and will make a pull request, but the development of dajaxice seems quite slow.. I don't know if it will ever get merged.

Meanwhile my fixed repo is available here:

https://github.com/h3/django-dajaxice/tree/88_logging_traceback_fix