Gitlab CSE Unil
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
M. Chardon
ADIM
Commits
375ae0c5
Commit
375ae0c5
authored
Aug 06, 2015
by
Julien Furrer
Browse files
Ajusté settings pour logging et email
parent
3f0682fe
Changes
4
Hide whitespace changes
Inline
Side-by-side
adim_project/adim_project/settings/base.py
View file @
375ae0c5
...
...
@@ -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
,
},
...
...
adim_project/adim_project/settings/local.py
View file @
375ae0c5
...
...
@@ -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'
)
adim_project/adim_project/settings/production.py
View file @
375ae0c5
...
...
@@ -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'
,
)
adim_project/adim_project/settings/staging.py
View file @
375ae0c5
...
...
@@ -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'
,
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment