X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=multivimbroker%2Fmultivimbroker%2Fsettings.py;h=850694e912aa67767d9f846ed141654e93def64e;hb=HEAD;hp=c1d31d0871e7564d3a18f06dbf2244df17d56ab8;hpb=84973dec870bbc33625dd641b5486afa2d8b1d4e;p=multicloud%2Fframework.git diff --git a/multivimbroker/multivimbroker/settings.py b/multivimbroker/multivimbroker/settings.py index c1d31d0..850694e 100644 --- a/multivimbroker/multivimbroker/settings.py +++ b/multivimbroker/multivimbroker/settings.py @@ -12,9 +12,9 @@ import os import sys -from logging import config -from onaplogging import monkey -monkey.patch_all() +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__))) @@ -51,7 +51,6 @@ MIDDLEWARE_CLASSES = [ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'multivimbroker.middleware.LogContextMiddleware', ] ROOT_URLCONF = 'multivimbroker.urls' @@ -71,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) @@ -88,20 +81,51 @@ TIME_ZONE = 'UTC' STATIC_URL = '/static/' - -LOGGING_CONFIG = None -# yaml configuration of logging -LOGGING_FILE = os.path.join(BASE_DIR, 'multivimbroker/pub/config/log.yml') -config.yamlConfig(filepath=LOGGING_FILE, watchDog=True) - +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': { + '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 - DATABASES = {} - DATABASES['default'] = { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': ':memory:', - } + # from multivimbroker.pub.config import config REST_FRAMEWORK = {} import platform