|
36 | 36 | )
|
37 | 37 | RAVEN_MIDDLEWARE = ('raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
|
38 | 38 | 'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',)
|
39 |
| -MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + \ |
40 |
| - RAVEN_MIDDLEWARE + MIDDLEWARE_CLASSES |
41 | 39 |
|
| 40 | +if env.bool('USE_SENTRY', True): |
| 41 | + MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + RAVEN_MIDDLEWARE + MIDDLEWARE_CLASSES |
| 42 | +else: |
| 43 | + MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES |
42 | 44 |
|
43 | 45 | # set this to 60 seconds and then to 518400 when you can prove it works
|
44 | 46 | SECURE_HSTS_SECONDS = 60
|
|
85 | 87 |
|
86 | 88 |
|
87 | 89 | # Sentry Configuration
|
88 |
| -SENTRY_DSN = env('DJANGO_SENTRY_DSN') |
89 |
| -SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient') |
90 |
| -LOGGING = { |
91 |
| - 'version': 1, |
92 |
| - 'disable_existing_loggers': True, |
93 |
| - 'root': { |
94 |
| - 'level': 'WARNING', |
95 |
| - 'handlers': ['sentry'], |
96 |
| - }, |
97 |
| - 'formatters': { |
98 |
| - 'verbose': { |
99 |
| - 'format': '%(levelname)s %(asctime)s %(module)s ' |
100 |
| - '%(process)d %(thread)d %(message)s' |
| 90 | +if env.bool('USE_SENTRY', True): |
| 91 | + SENTRY_DSN = env('DJANGO_SENTRY_DSN') |
| 92 | + SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient') |
| 93 | + LOGGING = { |
| 94 | + 'version': 1, |
| 95 | + 'disable_existing_loggers': True, |
| 96 | + 'root': { |
| 97 | + 'level': 'WARNING', |
| 98 | + 'handlers': ['sentry'], |
101 | 99 | },
|
102 |
| - }, |
103 |
| - 'handlers': { |
104 |
| - 'sentry': { |
105 |
| - 'level': 'ERROR', |
106 |
| - 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', |
| 100 | + 'formatters': { |
| 101 | + 'verbose': { |
| 102 | + 'format': '%(levelname)s %(asctime)s %(module)s ' |
| 103 | + '%(process)d %(thread)d %(message)s' |
| 104 | + }, |
107 | 105 | },
|
108 |
| - 'console': { |
109 |
| - 'level': 'DEBUG', |
110 |
| - 'class': 'logging.StreamHandler', |
111 |
| - 'formatter': 'verbose' |
112 |
| - } |
113 |
| - }, |
114 |
| - 'loggers': { |
115 |
| - 'django.db.backends': { |
116 |
| - 'level': 'ERROR', |
117 |
| - 'handlers': ['console'], |
118 |
| - 'propagate': False, |
| 106 | + 'handlers': { |
| 107 | + 'sentry': { |
| 108 | + 'level': 'ERROR', |
| 109 | + 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', |
| 110 | + }, |
| 111 | + 'console': { |
| 112 | + 'level': 'DEBUG', |
| 113 | + 'class': 'logging.StreamHandler', |
| 114 | + 'formatter': 'verbose' |
| 115 | + } |
119 | 116 | },
|
120 |
| - 'raven': { |
121 |
| - 'level': 'DEBUG', |
122 |
| - 'handlers': ['console'], |
123 |
| - 'propagate': False, |
| 117 | + 'loggers': { |
| 118 | + 'django.db.backends': { |
| 119 | + 'level': 'ERROR', |
| 120 | + 'handlers': ['console'], |
| 121 | + 'propagate': False, |
| 122 | + }, |
| 123 | + 'raven': { |
| 124 | + 'level': 'DEBUG', |
| 125 | + 'handlers': ['console'], |
| 126 | + 'propagate': False, |
| 127 | + }, |
| 128 | + 'sentry.errors': { |
| 129 | + 'level': 'DEBUG', |
| 130 | + 'handlers': ['console'], |
| 131 | + 'propagate': False, |
| 132 | + }, |
| 133 | + 'django.security.DisallowedHost': { |
| 134 | + 'level': 'ERROR', |
| 135 | + 'handlers': ['console', 'sentry'], |
| 136 | + 'propagate': False, |
| 137 | + }, |
124 | 138 | },
|
125 |
| - 'sentry.errors': { |
126 |
| - 'level': 'DEBUG', |
127 |
| - 'handlers': ['console'], |
128 |
| - 'propagate': False, |
| 139 | + } |
| 140 | + SENTRY_CELERY_LOGLEVEL = env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO) |
| 141 | + RAVEN_CONFIG = { |
| 142 | + 'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO), |
| 143 | + 'DSN': SENTRY_DSN |
| 144 | + } |
| 145 | +else: |
| 146 | + LOGGING = { |
| 147 | + 'version': 1, |
| 148 | + 'disable_existing_loggers': False, |
| 149 | + 'handlers': { |
| 150 | + 'console': { |
| 151 | + 'class': 'logging.StreamHandler', |
| 152 | + }, |
129 | 153 | },
|
130 |
| - 'django.security.DisallowedHost': { |
131 |
| - 'level': 'ERROR', |
132 |
| - 'handlers': ['console', 'sentry'], |
133 |
| - 'propagate': False, |
| 154 | + 'loggers': { |
| 155 | + 'django': { |
| 156 | + 'handlers': ['console'], |
| 157 | + 'level': env('DJANGO_LOG_LEVEL', default='INFO'), |
| 158 | + }, |
134 | 159 | },
|
135 |
| - }, |
136 |
| -} |
137 |
| -SENTRY_CELERY_LOGLEVEL = env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO) |
138 |
| -RAVEN_CONFIG = { |
139 |
| - 'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO), |
140 |
| - 'DSN': SENTRY_DSN |
141 |
| -} |
| 160 | + } |
142 | 161 |
|
143 | 162 | # Custom Admin URL, use {% url 'admin:index' %}
|
144 | 163 | ADMIN_URL = env('DJANGO_ADMIN_URL')
|
|
0 commit comments