Skip to content
Snippets Groups Projects
Unverified Commit d65238e1 authored by Fredrik Jonsson's avatar Fredrik Jonsson Committed by GitHub
Browse files

Merge pull request #605 from OpenTechFund/feature/improve-settings-dev-local

Add local logging option, activate debug toolbar etc.
parents ddcbaa60 019dc6c4
No related branches found
No related tags found
No related merge requests found
......@@ -375,6 +375,7 @@ ESI_ENABLED = False
# Custom settings
ENABLE_STYLEGUIDE = False
DEBUGTOOLBAR = False
# Social Auth
SOCIAL_AUTH_URL_NAMESPACE = 'social'
......
......@@ -22,7 +22,90 @@ INSTALLED_APPS = INSTALLED_APPS + [
SECURE_SSL_REDIRECT = False
# Change these in local.py.
LOCAL_FILE_LOGGING = False
LOCAL_FILE_EMAIL = False
try:
from .local import * # noqa
except ImportError:
pass
# We add these here so they can react on settings made in local.py.
# E-mail to local files.
if LOCAL_FILE_EMAIL:
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = BASE_DIR + '/var/mail'
# Local logging to file.
if LOCAL_FILE_LOGGING:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt': "%Y-%m-%d %H:%M:%S"
},
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'logfile': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': BASE_DIR + '/var/log/debug.log',
'maxBytes': 1000000,
'backupCount': 2,
'formatter': 'standard',
},
},
'loggers': {
'django': {
'handlers': ['logfile'],
'level': 'INFO',
'propagate': True,
},
'django.db.backends': {
'handlers': ['logfile'],
'level': 'INFO',
'propagate': False,
},
'django.request': {
'handlers': ['logfile'],
'level': 'DEBUG',
'propagate': False,
},
'django.template': {
'handlers': ['logfile'],
'level': 'INFO',
'propagate': False,
},
'django.security': {
'handlers': ['logfile'],
'level': 'DEBUG',
'propagate': False,
},
'wagtail': {
'handlers': ['logfile'],
'level': 'DEBUG',
},
'opentech': {
'handlers': ['logfile'],
'level': 'DEBUG',
},
}
}
# Set up the Django debug toolbar. See also root urls.py.
if DEBUGTOOLBAR:
INSTALLED_APPS += [
'debug_toolbar',
]
MIDDLEWARE = [
'debug_toolbar.middleware.DebugToolbarMiddleware',
] + MIDDLEWARE
......@@ -4,10 +4,21 @@ CACHES = {
}
}
# Use the Django debug toolbar. First install via pip.
# pip install django-debug-toolbar
# DEBUGTOOLBAR = True
# Write log to local file.
# LOCAL_FILE_LOGGING = True
# Write e-mails to local files.
# LOCAL_FILE_EMAIL = True
# On staging, uncomment the following to enable the styleguide
# ENABLE_STYLEGUIDE = True
# DO NOT use on production
RECAPTCHA_PUBLIC_KEY = '6LelrggUAAAAANL1b4NcQpJxjgoWQEugpoGqeq2q'
RECAPTCHA_PRIVATE_KEY = '6LelrggUAAAAAD2gDgs43P9NSa9ScvkU6ZmBAW_F'
NOCAPTCHA = True
# ALLOWED_HOSTS = ['apply.otf.test', 'otf.test', '127.0.0.1']
# BASE_URL = 'http://otf.test'
# SECRET_KEY = 'CHANGEME!!!'
......@@ -61,3 +61,9 @@ if cache_length:
urlpatterns,
cache_control(max_age=cache_length)
)
if settings.DEBUG and settings.DEBUGTOOLBAR:
import debug_toolbar
urlpatterns = [
path('__debug__/', include(debug_toolbar.urls)),
] + urlpatterns
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment