|
11 | 11 | """ |
12 | 12 | import sys |
13 | 13 | import os |
| 14 | +import raven |
14 | 15 |
|
15 | 16 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
16 | 17 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
|
30 | 31 | ALLOWED_HOSTS = ['*', 'www.lylinux.net', '127.0.0.1', 'example.com'] |
31 | 32 | # Application definition |
32 | 33 |
|
| 34 | + |
| 35 | +SITE_ROOT = os.path.dirname(os.path.abspath(__file__)) |
| 36 | +SITE_ROOT = os.path.abspath(os.path.join(SITE_ROOT, '../')) |
| 37 | + |
| 38 | +RAVEN_CONFIG = { |
| 39 | + 'dsn': os.environ.get('SENTRY_DSN'), |
| 40 | + # If you are using git, you can also automatically configure the |
| 41 | + # release based on the git info. |
| 42 | + 'release': raven.fetch_git_sha(os.path.abspath(SITE_ROOT)), |
| 43 | +} |
| 44 | + |
33 | 45 | INSTALLED_APPS = [ |
34 | 46 | # 'django.contrib.admin', |
35 | 47 | 'django.contrib.admin.apps.SimpleAdminConfig', |
|
40 | 52 | 'django.contrib.staticfiles', |
41 | 53 | 'django.contrib.sites', |
42 | 54 | 'django.contrib.sitemaps', |
| 55 | + 'raven.contrib.django.raven_compat', |
43 | 56 | 'pagedown', |
44 | 57 | 'haystack', |
45 | 58 | 'blog', |
|
138 | 151 | # https://docs.djangoproject.com/en/1.10/howto/static-files/ |
139 | 152 |
|
140 | 153 |
|
141 | | -SITE_ROOT = os.path.dirname(os.path.abspath(__file__)) |
142 | | -SITE_ROOT = os.path.abspath(os.path.join(SITE_ROOT, '../')) |
143 | | - |
144 | 154 | HAYSTACK_CONNECTIONS = { |
145 | 155 | 'default': { |
146 | 156 | 'ENGINE': 'DjangoBlog.whoosh_cn_backend.WhooshEngine', |
|
193 | 203 | # Emial: |
194 | 204 | EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' |
195 | 205 |
|
196 | | -#EMAIL_USE_TLS = True |
| 206 | +# EMAIL_USE_TLS = True |
197 | 207 | EMAIL_USE_SSL = True |
198 | 208 |
|
199 | 209 | EMAIL_HOST = 'smtp.mxhichina.com' |
|
206 | 216 | ADMINS = [('liangliang', 'liangliangyy@gmail.com')] |
207 | 217 | # 微信管理员密码(两次md5获得) |
208 | 218 | WXADMIN = '995F03AC401D6CABABAEF756FC4D43C7' |
| 219 | + |
209 | 220 | LOGGING = { |
210 | 221 | 'version': 1, |
211 | 222 | 'disable_existing_loggers': False, |
| 223 | + 'root': { |
| 224 | + 'level': 'WARNING', |
| 225 | + 'handlers': ['sentry', 'console', 'log_file'], |
| 226 | + }, |
212 | 227 | 'formatters': { |
213 | 228 | 'verbose': { |
214 | 229 | 'format': '[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s', |
215 | 230 | }, |
216 | 231 | 'simple': { |
217 | | - 'format': '%(levelname)s %(asctime)s %(message)s' |
| 232 | + 'format': '[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s', |
218 | 233 | }, |
219 | 234 | }, |
220 | 235 | 'filters': { |
|
229 | 244 | 'log_file': { |
230 | 245 | 'level': 'INFO', |
231 | 246 | 'class': 'logging.handlers.RotatingFileHandler', |
232 | | - 'filename': 'djangoblog.log', |
| 247 | + 'filename': 'xiaobiaobai.log', |
233 | 248 | 'maxBytes': 16777216, # 16 MB |
234 | 249 | 'formatter': 'verbose' |
235 | 250 | }, |
|
246 | 261 | 'level': 'ERROR', |
247 | 262 | 'filters': ['require_debug_false'], |
248 | 263 | 'class': 'django.utils.log.AdminEmailHandler' |
249 | | - } |
| 264 | + }, |
| 265 | + 'sentry': { |
| 266 | + 'level': 'ERROR', # To capture more than ERROR, change to WARNING, INFO, etc. |
| 267 | + 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', |
| 268 | + 'tags': {'custom-tag': 'x'}, |
| 269 | + }, |
250 | 270 | }, |
251 | 271 | 'loggers': { |
252 | | - 'djangoblog': { |
| 272 | + 'xiaobiaobai': { |
253 | 273 | 'handlers': ['log_file', 'console'], |
254 | 274 | 'level': 'INFO', |
255 | 275 | 'propagate': True, |
256 | 276 | }, |
257 | 277 | 'django.request': { |
258 | | - 'handlers': ['mail_admins'], |
| 278 | + 'handlers': ['mail_admins', 'sentry'], |
259 | 279 | 'level': 'ERROR', |
260 | 280 | 'propagate': False, |
261 | 281 | }, |
| 282 | + 'raven': { |
| 283 | + 'level': 'DEBUG', |
| 284 | + 'handlers': ['console'], |
| 285 | + 'propagate': False, |
| 286 | + }, |
| 287 | + 'sentry.errors': { |
| 288 | + 'level': 'DEBUG', |
| 289 | + 'handlers': ['console'], |
| 290 | + 'propagate': False, |
| 291 | + }, |
262 | 292 | } |
263 | 293 | } |
264 | 294 |
|
|
0 commit comments