diff options
author | 2018-08-06 11:27:01 +0800 | |
---|---|---|
committer | 2018-08-06 11:27:01 +0800 | |
commit | 5c85f7dffa571f7005ecdd4910e4ebba60dfab1a (patch) | |
tree | d1922ca5c41057efc1f3b47d461fc4d004520b8f | |
parent | c9ca048cd28a62fd6df799ce7a70c6fbf6c2fe92 (diff) |
Fix log error when run gvnfmadapter in windows
Change-Id: I7eb0cde8053630561eaa1b53be65fac02ee0bb5a
Issue-ID: VFC-1014
Signed-off-by: biancunkang <bian.cunkang@zte.com.cn>
-rw-r--r-- | gvnfmadapter/driver/settings.py | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/gvnfmadapter/driver/settings.py b/gvnfmadapter/driver/settings.py index 912e78a..098e220 100644 --- a/gvnfmadapter/driver/settings.py +++ b/gvnfmadapter/driver/settings.py @@ -14,6 +14,7 @@ import os import sys +import platform from logging import config from onaplogging import monkey monkey.patch_all() @@ -108,44 +109,40 @@ 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': { -# 'driver_handler': { -# 'level': 'DEBUG', -# 'class': 'logging.handlers.RotatingFileHandler', -# 'filename': os.path.join(BASE_DIR, 'logs/runtime_driver.log'), -# 'formatter': 'standard', -# 'maxBytes': 1024 * 1024 * 50, -# 'backupCount': 5, }, }, -# -# 'loggers': { -# 'driver': { -# 'handlers': ['driver_handler'], -# 'level': 'DEBUG', -# 'propagate': False}, }} - -LOGGING_CONFIG = None -# yaml configuration of logging -LOGGING_FILE = os.path.join(BASE_DIR, 'driver/log.yml') -if 'test' in sys.argv: - os.system('sed -i "s|/var/log/onap/vfc/gvnfmdriver|/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': { + 'driver_handler': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': os.path.join(BASE_DIR, 'logs/runtime_driver.log'), + 'formatter': 'standard', + 'maxBytes': 1024 * 1024 * 50, + 'backupCount': 5, }, }, + + 'loggers': { + 'driver': { + 'handlers': ['driver_handler'], + 'level': 'DEBUG', + 'propagate': False}, }} +else: + LOGGING_CONFIG = None + LOGGING_FILE = os.path.join(BASE_DIR, 'driver/log.yml') + config.yamlConfig(filepath=LOGGING_FILE, watchDog=True) if 'test' in sys.argv: - os.system('sed -i "s|/tmp|/var/log/onap/vfc/gvnfmdriver|" %s' % LOGGING_FILE) from driver.pub.config import config config.REG_TO_MSB_WHEN_START = False - import platform if platform.system() == 'Linux': TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' TEST_OUTPUT_VERBOSE = True |