Add sentry support (fixes #5258)
This commit is contained in:
parent
b2ee01b583
commit
8437ef501b
|
@ -202,6 +202,17 @@ else:
|
|||
SECRET_KEY = os.environ.get('SECRET_KEY', '0!=(1kc6kri-ui+tmj@mr+*0bvj!(p*r0duu2n=)7@!p=pvf9n')
|
||||
CSRF_COOKIE_SECURE = os.environ.get('CSRF_COOKIE_SECURE') == 'yes'
|
||||
|
||||
# add sentry handler if environment contains SENTRY_DSN
|
||||
if 'SENTRY_DSN' in os.environ:
|
||||
try:
|
||||
import raven
|
||||
except ImportError:
|
||||
raise ImproperlyConfigured('SENTRY_DSN environment variable is set but raven is not installed.')
|
||||
SENTRY_DSN = os.environ['SENTRY_DSN']
|
||||
|
||||
else:
|
||||
SENTRY_DSN = None
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
|
@ -346,3 +357,18 @@ if os.environ.get('MULTITENANT_MODE', 'no') == 'yes':
|
|||
from tenant_settings import *
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if SENTRY_DSN is not None:
|
||||
try:
|
||||
import raven
|
||||
except ImportError:
|
||||
raise ImproperlyConfigured('SENTRY_DSN present but raven is not installed')
|
||||
RAVEN_CONFIG = {
|
||||
'dsn': SENTRY_DSN,
|
||||
}
|
||||
INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
|
||||
LOGGING['handlers']['sentry'] = {
|
||||
'level': 'ERROR',
|
||||
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
|
||||
}
|
||||
LOGGING['loggers']['']['handlers'].append('sentry')
|
||||
|
|
Reference in New Issue