Gitlab CSE Unil

Commit 375ae0c5 authored by Julien Furrer's avatar Julien Furrer
Browse files

Ajusté settings pour logging et email

parent 3f0682fe
......@@ -311,10 +311,20 @@ DJANGO_APPS = (
INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS
# ---------- END APPS CONFIGURATION
SERVER_EMAIL = 'julien.furrer@unil.ch'
EMAIL_HOST = "smtp.unil.ch"
# ========== LOGGING CONFIGURATION
#
def add_remote_info(record):
"""
Pour utiliser, utilisez le logger comme:
logger.debug("Coucou", extra={'request': request})
:param record:
:return:
"""
req = getattr(record, 'request', None)
record.remote_addr = req.META.get('REMOTE_ADDR', '-') if req else '-'
record.forwarded_for = req.META.get('HTTP_X_FORWARDED_FOR', '-') if req else '-'
......@@ -334,14 +344,19 @@ LOGGING = {
'add_remote_info': {
'()': 'django.utils.log.CallbackFilter',
'callback': add_remote_info,
},
'save_emails_to_disk': {
'()': 'django.utils.log.CallbackFilter',
'callback': lambda x: False,
}
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(name)s.%(funcName)s %(message)s',
'format': '%(levelname)s %(asctime)s %(name)s.%(funcName)s:%(lineno)d %(message)s',
},
'verbose_with_remote': {
'format': '%(levelname)s %(asctime)s %(name)s.%(funcName)s %(remote_addr)s %(forwarded_for)s %(message)s',
'format': '%(levelname)s %(asctime)s %(name)s.%(funcName)s:%(lineno)d %(remote_addr)s %(forwarded_for)s %(message)s',
},
'simple': {
'format': '%(levelname)s %(message)s'
......@@ -351,15 +366,24 @@ LOGGING = {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'include_html': False,
'class': 'django.utils.log.AdminEmailHandler'
},
'mail_admins_file': {
'level': 'ERROR',
'filters': ['require_debug_false', 'save_emails_to_disk'],
'include_html': False,
'class': 'django.utils.log.AdminEmailHandler',
'email_backend': 'django.core.mail.backends.filebased.EmailBackend'
},
'console': {
'filters': ['require_debug_true', ],
'class': 'logging.StreamHandler',
},
'file': {
'file_debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
# 'class': 'logging.FileHandler',
'class': 'logging.handlers.WatchedFileHandler',
'filters': ['add_remote_info', ],
'formatter': 'verbose_with_remote',
'filename': '{}/log/debug.log'.format(dirname(SITE_ROOT)),
......@@ -367,7 +391,7 @@ LOGGING = {
},
'loggers': {
'django.request': {
'handlers': ['mail_admins', 'file', ],
'handlers': ['mail_admins', 'mail_admins_file', 'file_debug', ],
'level': 'WARNING',
'propagate': True,
},
......@@ -377,17 +401,17 @@ LOGGING = {
'propagate': True,
},
'adim_app': {
'handlers': ['console', 'file'],
'handlers': ['console', 'file_debug'],
'level': 'DEBUG',
'propagate': True,
},
'adim_ttp': {
'handlers': ['console', 'file'],
'handlers': ['console', 'file_debug'],
'level': 'DEBUG',
'propagate': True,
},
'shibauth': {
'handlers': ['console', 'file'],
'handlers': ['console', 'file_debug'],
'level': 'DEBUG',
'propagate': True,
},
......
......@@ -25,6 +25,7 @@ DATABASES = {
}
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_FILE_PATH = '{}/log/emails/current'.format(dirname(SITE_ROOT))
SENDFILE_BACKEND = 'sendfile.backends.development'
......@@ -33,3 +34,5 @@ ADIM_DEBUG_JS = True
INSTALLED_APPS += ('django_trap', )
DJANGO_TRAP_STORE_PW = False
INTERNAL_IPS = ('127.0.0.1', '130.223.159.72')
......@@ -22,3 +22,6 @@ DATABASES = {
ADIM_PROD = True
ADIM_DEBUG_JS = False
# Only the ip listed here can access the admin interface
INTERNAL_IPS = ('130.223.159.72', )
......@@ -24,3 +24,6 @@ DATABASES = {
ADIM_PROD = False
ADIM_DEBUG_JS = False
# Only the ip listed here can access the admin interface
INTERNAL_IPS = ('130.223.159.72', )
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment