Updated base.py to check if ENABLE_LOGGING is True and in that case enable the logger to write DEBUG level logs to a file debug.log in project's root directory

This commit is contained in:
M.Ravi 2017-07-28 12:05:14 +02:00
parent 53fc982837
commit e8e7be7618

View file

@ -199,13 +199,11 @@ DATABASES = {
}
}
AUTHENTICATION_BACKENDS = (
'guardian.backends.ObjectPermissionBackend',
'django.contrib.auth.backends.ModelBackend',
)
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
@ -464,7 +462,6 @@ META_USE_SITES = True
PARLER_LANGUAGES = {1: ({'code': 'en-us'}, {'code': 'de'},)}
AUTH_USER_MODEL = 'membership.CustomUser'
# PAYMENT
STRIPE_DESCRIPTION_ON_PAYMENT = "Payment for ungleich GmbH services"
@ -481,7 +478,6 @@ STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY')
ANONYMOUS_USER_NAME = 'anonymous@ungleich.ch'
GUARDIAN_GET_INIT_ANONYMOUS_USER = 'membership.models.get_anonymous_user_instance'
#############################################
# configurations for opennebula-integration #
#############################################
@ -508,7 +504,6 @@ OPENNEBULA_PORT = env('OPENNEBULA_PORT')
# default value is /RPC2
OPENNEBULA_ENDPOINT = env('OPENNEBULA_ENDPOINT')
# dcl email configurations
DCL_TEXT = env('DCL_TEXT')
DCL_SUPPORT_FROM_ADDRESS = env('DCL_SUPPORT_FROM_ADDRESS')
@ -526,6 +521,28 @@ GOOGLE_ANALYTICS_PROPERTY_IDS = {
'dynamicweb-staging.ungleich.ch': 'staging'
}
ENABLE_LOGGING = bool_env('ENABLE_LOGGING')
if ENABLE_LOGGING:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': "{PROJECT_DIR}/debug.log".format(PROJECT_DIR=PROJECT_DIR),
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
DEBUG = bool_env('DEBUG')
if DEBUG: