# Copyright (c) 2017 Wind River Systems, Inc.
+# Copyright (c) 2017-2018 VMware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
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__)))
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
)
}
-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)
+# CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' %
+# (REDIS_PASSWD, REDIS_HOST, REDIS_PORT)
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