X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=multivimbroker%2Fmultivimbroker%2Fsettings.py;h=850694e912aa67767d9f846ed141654e93def64e;hb=HEAD;hp=4c6b08907869be90cebcdef66f20d1287a0e2190;hpb=2906f8863e3af3559a5ba288cbc2363f31c9f507;p=multicloud%2Fframework.git diff --git a/multivimbroker/multivimbroker/settings.py b/multivimbroker/multivimbroker/settings.py index 4c6b089..850694e 100644 --- a/multivimbroker/multivimbroker/settings.py +++ b/multivimbroker/multivimbroker/settings.py @@ -12,6 +12,9 @@ import os import sys +import platform +import yaml +from logging import config as log_config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -23,9 +26,9 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = '3o-wney!99y)^h3v)0$j16l9=fdjxcb+a8g+q3tfbahcnu2b0o' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +# DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['*'] # Application definition @@ -67,12 +70,6 @@ REST_FRAMEWORK = { ) } -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} # CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' % # (REDIS_PASSWD, REDIS_HOST, REDIS_PORT) @@ -84,46 +81,51 @@ TIME_ZONE = 'UTC' STATIC_URL = '/static/' -LOGGING = { - 'version': 1, - 'disable_existing_loggers': True, - 'formatters': { - 'standard': { - 'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] \ - [%(levelname)s]:%(message)s', +if platform.system() == 'Windows' or 'test' in sys.argv: + LOGGING = { + 'version': 1, + 'disable_existing_loggers': True, + 'formatters': { + 'standard': { + 'format': '%(asctime)s:[%(name)s]:[%(filename)s]' + + '-[%(lineno)d] [%(levelname)s]:%(message)s', + }, }, - }, - 'filters': { - }, - 'handlers': { - 'multivimbroker_handler': { - 'level': 'DEBUG', - 'class': 'logging.handlers.RotatingFileHandler', - 'filename': os.path.join(BASE_DIR, - 'logs/runtime_multivimbroker.log'), - 'formatter': 'standard', - 'maxBytes': 1024 * 1024 * 50, - 'backupCount': 5, + 'filters': { }, - }, - - 'loggers': { - 'multivimbroker': { - 'handlers': ['multivimbroker_handler'], - 'level': 'DEBUG', - 'propagate': False + 'handlers': { + 'file_handler': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': os.path.join(BASE_DIR, 'logs/test.log'), + 'formatter': 'standard', + 'maxBytes': 1024 * 1024 * 50, + 'backupCount': 5, + }, }, + + 'loggers': { + 'common': { + 'handlers': ['file_handler'], + 'level': 'DEBUG', + 'propagate': False + }, + } } -} +else: + log_path = "/var/log/onap/multicloud/multivimbroker" + if not os.path.exists(log_path): + os.makedirs(log_path) + + LOGGING_CONFIG = None + # yaml configuration of logging + LOGGING_FILE = os.path.join(BASE_DIR, 'multivimbroker/pub/config/log.yml') + with open(file=LOGGING_FILE, mode='r', encoding="utf-8")as file: + logging_yaml = yaml.load(stream=file, Loader=yaml.FullLoader) + log_config.dictConfig(config=logging_yaml) if 'test' in sys.argv: - from multivimbroker.pub.config import config - config.REG_TO_MSB_WHEN_START = False - DATABASES = {} - DATABASES['default'] = { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:', - } + # from multivimbroker.pub.config import config REST_FRAMEWORK = {} import platform