aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaili <lai.li@zte.com.cn>2018-08-06 11:30:37 +0800
committerlaili <lai.li@zte.com.cn>2018-08-06 14:34:19 +0800
commit7e2d2c4593e42813dc1693ab57a6725ce4e22ce1 (patch)
treeb3a4cd877c453084acc225cab389d98bd2541d2a
parent1304d89f0f5cfadd508443566f4011dccd2532e3 (diff)
Fix log error when run unit tests in windows
Fix log error when run lcm tests in windows Change-Id: If67c9849d200e030aaf5b738c808a370b09e250f Issue-ID: VFC-1014 Signed-off-by: laili <lai.li@zte.com.cn>
-rw-r--r--lcm/settings.py75
1 files changed, 37 insertions, 38 deletions
diff --git a/lcm/settings.py b/lcm/settings.py
index e0aca0a3..67711bb9 100644
--- a/lcm/settings.py
+++ b/lcm/settings.py
@@ -14,6 +14,7 @@
import os
import sys
+import platform
import redisco
@@ -132,45 +133,44 @@ pub_config.CATALOG_ROOT_PATH = os.path.join(STATICFILES_DIRS[0], "catalog")
pub_config.CATALOG_URL_PATH = "static/catalog"
pub_config.AAI_BASE_URL = "http://%s:%s/aai/v11" % (pub_config.MSB_SERVICE_IP, pub_config.MSB_SERVICE_PORT)
pub_config.SDC_BASE_URL = "http://%s:%s/api" % (pub_config.MSB_SERVICE_IP, pub_config.MSB_SERVICE_PORT)
-#
-# LOGGING = {
-# 'version': 1,
-# 'disable_existing_loggers': True,
-# 'formatters': {
-# 'standard': {
-# 'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s',
-# },
-# },
-# 'filters': {
-# },
-# 'handlers': {
-# 'lcm_handler': {
-# 'level': 'DEBUG',
-# 'class': 'logging.handlers.RotatingFileHandler',
-# 'filename': os.path.join(BASE_DIR, 'logs/runtime_lcm.log'),
-# 'formatter': 'standard',
-# 'maxBytes': 1024 * 1024 * 50,
-# 'backupCount': 5,
-# },
-# },
-#
-# 'loggers': {
-# 'lcm': {
-# 'handlers': ['lcm_handler'],
-# 'level': 'DEBUG',
-# 'propagate': False
-# },
-# }
-# }
-LOGGING_CONFIG = None
-# yaml configuration of logging
-LOGGING_FILE = os.path.join(BASE_DIR, 'lcm/log.yml')
-if 'test' in sys.argv:
- os.system('sed -i "s|/var/log/onap/vfc/nslcm|/tmp|" %s' % LOGGING_FILE)
-log_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': {
+ 'lcm_handler': {
+ 'level': 'DEBUG',
+ 'class': 'logging.handlers.RotatingFileHandler',
+ 'filename': os.path.join(BASE_DIR, 'logs/runtime_lcm.log'),
+ 'formatter': 'standard',
+ 'maxBytes': 1024 * 1024 * 50,
+ 'backupCount': 5,
+ },
+ },
+
+ 'loggers': {
+ 'lcm': {
+ 'handlers': ['lcm_handler'],
+ 'level': 'DEBUG',
+ 'propagate': False
+ },
+ }
+ }
+else:
+ LOGGING_CONFIG = None
+ # yaml configuration of logging
+ LOGGING_FILE = os.path.join(BASE_DIR, 'lcm/log.yml')
+ log_config.yamlConfig(filepath=LOGGING_FILE, watchDog=True)
if 'test' in sys.argv:
- os.system('sed -i "s|/tmp|/var/log/onap/vfc/nslcm|" %s' % LOGGING_FILE)
pub_config.REG_TO_MSB_WHEN_START = False
pub_config.DEPLOY_WORKFLOW_WHEN_START = False
DATABASES = {}
@@ -179,7 +179,6 @@ if 'test' in sys.argv:
'NAME': ':memory:',
}
REST_FRAMEWORK = {}
- import platform
if platform.system() == 'Linux':
TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'