Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sentry configurations #428

Open
wants to merge 2 commits into
base: master-qgis_server
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ env:

branches:
only:
- master-qgis_server
- master
- 2.9.x
- 2.7.x
Expand Down
97 changes: 97 additions & 0 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@

INSTALLED_APPS = (

'raven.contrib.django.raven_compat', # enable Raven plugin
'modeltranslation',

# Boostrap admin theme
Expand Down Expand Up @@ -1339,3 +1340,99 @@
GEOTIFF_IO_BASE_URL = os.getenv(
'GEOTIFF_IO_BASE_URL', 'https://app.geotiff.io'
)

# Sentry Logging

LOGGING_MAIL_ADMINS = ast.literal_eval(
os.environ.get('LOGGING_MAIL_ADMINS', 'False'))
LOGGING_SENTRY = ast.literal_eval(
os.environ.get('LOGGING_SENTRY', 'False'))

LOGGING_DEFAULT_HANDLER = os.environ.get('LOGGING_DEFAULT_HANDLER', 'console')
LOGGING_DEFAULT_LOG_LEVEL = os.environ.get(
'LOGGING_DEFAULT_LOG_LEVEL', 'ERROR')

default_handlers = [LOGGING_DEFAULT_HANDLER]

if LOGGING_MAIL_ADMINS:
mail_admins_handler = 'mail_admins'
else:
mail_admins_handler = LOGGING_DEFAULT_HANDLER

if LOGGING_SENTRY:
sentry_handler = 'sentry'
default_handlers.append('sentry')
else:
sentry_handler = LOGGING_DEFAULT_HANDLER

if 'raven.contrib.django.raven_compat' in INSTALLED_APPS:
print '*********** Setting up sentry logging ************'
RAVEN_CONFIG = {
'dsn': 'http://4425a43d1ae2490bba0b7b397025fd49:'
'f60de041c1814ff79f3e510c0731cb3e@sentry.kartoza.com/17',
}

# MIDDLEWARE_CLASSES = (
# 'raven.contrib.django.middleware.SentryResponseErrorIdMiddleware',
# 'raven.contrib.django.middleware.SentryLogMiddleware',
# ) + MIDDLEWARE_CLASSES

#
# Sentry settings - logs exceptions to a database
LOGGING = {
# internal dictConfig version - DON'T CHANGE
'version': 1,
'disable_existing_loggers': False,
# default root logger
'root': {
'level': LOGGING_DEFAULT_LOG_LEVEL,
'handlers': default_handlers,
},
'handlers': {
# send email to mail_admins, if DEBUG=False
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
# sentry logger
'sentry': {
'level': 'WARNING',
'class': (
'raven.contrib.django.raven_compat.'
'handlers.SentryHandler'),
},
# file logger
'logfile': {
'class': 'logging.FileHandler',
'filename': '/var/log/django.log',
'level': 'DEBUG'
},
# console output
'console': {
'class': 'logging.StreamHandler',
'level': 'DEBUG',
},
},
'loggers': {
'django.db.backends': {
'level': 'ERROR',
'handlers': [sentry_handler],
'propagate': True
},
'raven': {
'level': 'ERROR',
'handlers': [mail_admins_handler],
'propagate': False
},
'sentry.errors': {
'level': 'ERROR',
'handlers': [mail_admins_handler],
'propagate': False
},
'django.request': {
'handlers': [mail_admins_handler],
'level': 'ERROR',
'propagate': True
}
}
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ python-mimeparse==1.6.0
python-openid==2.2.5
pytz==2018.3
PyYAML==3.12
raven==5.29.0
redis==2.10.5
regex==2016.7.21
requests==2.18.4
Expand Down