Skip to content

Commit

Permalink
add kartoza sentry configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
myarjunar committed Jun 4, 2018
1 parent b48e347 commit efb4e37
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
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:'
'[email protected]/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

0 comments on commit efb4e37

Please sign in to comment.