From 811db069bd81d687f3d3f7e27bfad9b819e6e0db Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Mon, 6 Aug 2018 09:24:57 +0800 Subject: [PATCH] Fix log error when run vnfmgr tests in windows Change-Id: I0a35f614f7ad3836f1ecb6fcb6898c3712746166 Issue-ID: VFC-1014 Signed-off-by: ying.yunlong --- mgr/mgr/settings.py | 75 +++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/mgr/mgr/settings.py b/mgr/mgr/settings.py index 5328a51..961c4fb 100644 --- a/mgr/mgr/settings.py +++ b/mgr/mgr/settings.py @@ -14,6 +14,7 @@ import os import sys +import platform import redisco @@ -123,48 +124,44 @@ TIME_ZONE = 'UTC' # https://docs.djangoproject.com/en/1.6/howto/static-files/ 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', -# }, -# }, -# 'filters': { -# }, -# 'handlers': { -# 'mgr_handler': { -# 'level': 'DEBUG', -# 'class': 'logging.handlers.RotatingFileHandler', -# 'filename': os.path.join(BASE_DIR, 'logs/runtime_mgr.log'), -# 'formatter': 'standard', -# 'maxBytes': 1024 * 1024 * 50, -# 'backupCount': 5, -# }, -# }, -# -# 'loggers': { -# 'mgr': { -# 'handlers': ['mgr_handler'], -# 'level': 'DEBUG', -# 'propagate': False -# }, -# } -# } - -LOGGING_CONFIG = None -# yaml configuration of logging -LOGGING_FILE = os.path.join(BASE_DIR, 'mgr/log.yml') -if 'test' in sys.argv: - os.system('sed -i "s|/var/log/onap/vfc/gvnfm-vnfmgr|/tmp|" %s' % LOGGING_FILE) -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': { + 'mgr_handler': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': os.path.join(BASE_DIR, 'logs/runtime_mgr.log'), + 'formatter': 'standard', + 'maxBytes': 1024 * 1024 * 50, + 'backupCount': 5, + }, + }, + + 'loggers': { + 'mgr': { + 'handlers': ['mgr_handler'], + 'level': 'DEBUG', + 'propagate': False + }, + } + } +else: + LOGGING_CONFIG = None + LOGGING_FILE = os.path.join(BASE_DIR, 'mgr/log.yml') + config.yamlConfig(filepath=LOGGING_FILE, watchDog=True) -if 'test' in sys.argv: - os.system('sed -i "s|/tmp|/var/log/onap/vfc/gvnfm-vnfmgr|" %s' % LOGGING_FILE) +if 'test' in sys.argv: from mgr.pub.config import config config.REG_TO_MSB_WHEN_START = False DATABASES = {} -- 2.16.6