add sentry

This commit is contained in:
virusdefender 2017-12-22 23:32:23 +08:00
parent abf2950e6f
commit 3c70ecbd19
2 changed files with 17 additions and 3 deletions

View File

@ -16,3 +16,4 @@ psycopg2
gunicorn gunicorn
jsonfield jsonfield
XlsxWriter XlsxWriter
raven

View File

@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/ https://docs.djangoproject.com/en/1.8/ref/settings/
""" """
import os import os
import raven
from copy import deepcopy from copy import deepcopy
if os.environ.get("OJ_ENV") == "production": if os.environ.get("OJ_ENV") == "production":
@ -29,6 +30,7 @@ VENDOR_APPS = (
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'rest_framework', 'rest_framework',
'raven.contrib.django.raven_compat'
) )
LOCAL_APPS = ( LOCAL_APPS = (
'account', 'account',
@ -125,6 +127,8 @@ UPLOAD_DIR = f"{DATA_DIR}{UPLOAD_PREFIX}"
STATICFILES_DIRS = [os.path.join(DATA_DIR, "public")] STATICFILES_DIRS = [os.path.join(DATA_DIR, "public")]
LOGGING_HANDLERS = ['console'] if DEBUG else ['console', 'sentry']
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
@ -139,21 +143,26 @@ LOGGING = {
'level': 'DEBUG', 'level': 'DEBUG',
'class': 'logging.StreamHandler', 'class': 'logging.StreamHandler',
'formatter': 'standard' 'formatter': 'standard'
},
'sentry': {
'level': 'ERROR',
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
'formatter': 'standard'
} }
}, },
'loggers': { 'loggers': {
'django.request': { 'django.request': {
'handlers': ['console'], 'handlers': LOGGING_HANDLERS,
'level': 'ERROR', 'level': 'ERROR',
'propagate': True, 'propagate': True,
}, },
'django.db.backends': { 'django.db.backends': {
'handlers': ['console'], 'handlers': LOGGING_HANDLERS,
'level': 'ERROR', 'level': 'ERROR',
'propagate': True, 'propagate': True,
}, },
'': { '': {
'handlers': ['console'], 'handlers': LOGGING_HANDLERS,
'level': 'WARNING', 'level': 'WARNING',
'propagate': True, 'propagate': True,
} }
@ -201,3 +210,7 @@ TOKEN_BUCKET_DEFAULT_CAPACITY = 10
# 单位:每分钟 # 单位:每分钟
TOKEN_BUCKET_FILL_RATE = 2 TOKEN_BUCKET_FILL_RATE = 2
RAVEN_CONFIG = {
'dsn': 'https://b200023b8aed4d708fb593c5e0a6ad3d:1fddaba168f84fcf97e0d549faaeaff0@sentry.io/263057'
}