From: tierno Date: Fri, 7 Aug 2020 10:10:15 +0000 (+0000) Subject: adding capability to set log level at vimconnectors X-Git-Tag: release-v9.0-start~17 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F9572%2F1;p=osm%2FRO.git adding capability to set log level at vimconnectors at INFO level print http input content change date format Change-Id: I4a94ca6e41cad7b09e5630d7d98c7160a257173b Signed-off-by: tierno --- diff --git a/RO/osm_ro/http_tools/request_processing.py b/RO/osm_ro/http_tools/request_processing.py index 72851429..fe38cc82 100644 --- a/RO/osm_ro/http_tools/request_processing.py +++ b/RO/osm_ro/http_tools/request_processing.py @@ -131,10 +131,10 @@ def format_in(default_schema, version_fields=None, version_dict_schema=None, con # bottle.abort(httperrors.Bad_Request, "Content error, empty") # return if confidential_data: - logger.debug('IN: %s', remove_clear_passwd (yaml.safe_dump(client_data, explicit_start=True, indent=4, default_flow_style=False, + logger.info('IN: %s', remove_clear_passwd (yaml.safe_dump(client_data, explicit_start=True, indent=4, default_flow_style=False, tags=False, allow_unicode=True))) else: - logger.debug('IN: %s', yaml.safe_dump(client_data, explicit_start=True, indent=4, default_flow_style=False, + logger.info('IN: %s', yaml.safe_dump(client_data, explicit_start=True, indent=4, default_flow_style=False, tags=False, allow_unicode=True) ) # look for the client provider version error_text = "Invalid content " diff --git a/RO/osm_ro/openmanod.py b/RO/osm_ro/openmanod.py index 19f7788c..d53450dd 100755 --- a/RO/osm_ro/openmanod.py +++ b/RO/osm_ro/openmanod.py @@ -172,6 +172,7 @@ def _get_version(): if __name__ == "__main__": + log_modules = ("nfvo", "http", "vim", "wim", "db", "console", "ovim", "sdn", "sdnconn") # env2config contains environ variable names and the correspondence with configuration file openmanod.cfg keys. # If this environ is defined, this value is taken instead of the one at at configuration file env2config = { @@ -186,14 +187,16 @@ if __name__ == "__main__": 'RO_LOG_LEVEL': 'log_level', 'RO_LOG_FILE': 'log_file', } + for log_module in log_modules: + env2config['RO_LOG_LEVEL_' + log_module.upper()] = 'log_level_' + log_module ro_version = _get_version() # Configure logging step 1 hostname = socket.gethostname() log_formatter_str = '%(asctime)s.%(msecs)03d00Z[{host}@openmanod] %(filename)s:%(lineno)s severity:%(levelname)s logger:%(name)s log:%(message)s' log_formatter_complete = logging.Formatter(log_formatter_str.format(host=hostname), datefmt='%Y-%m-%dT%H:%M:%S') - log_format_simple = "%(asctime)s %(levelname)s %(name)s %(thread)d %(filename)s:%(lineno)s %(message)s" - log_formatter_simple = logging.Formatter(log_format_simple, datefmt='%Y-%m-%dT%H:%M:%S') - logging.basicConfig(format=log_format_simple, level=logging.DEBUG) + log_format_simple = "%(asctime)s %(levelname)s %(name)s %(thread)d %(filename)s:%(lineno)s %(message)s" + log_formatter_simple = logging.Formatter(log_format_simple, datefmt='%Y-%m-%dT%H:%M:%S.%03d') + logging.basicConfig(format=log_format_simple, level=logging.DEBUG, datefmt='%Y-%m-%dT%H:%M:%S.%03d') logger = logging.getLogger('openmano') logger.setLevel(logging.DEBUG) socket_handler = None @@ -263,7 +266,7 @@ if __name__ == "__main__": if env_k.endswith("PORT"): # convert to int, skip if not possible global_config[env2config[env_k]] = int(env_v) except Exception as e: - logger.warn("skipping environ '{}={}' because exception '{}'".format(env_k, env_v, e)) + logger.warning("skipping environ '{}={}' because exception '{}'".format(env_k, env_v, e)) global_config["console_port_iterator"] = console_port_iterator global_config["console_thread"] = {} @@ -292,7 +295,7 @@ if __name__ == "__main__": logger.critical("Starting openmano server version: '%s %s' command: '%s'", ro_version, version_date, " ".join(sys.argv)) - for log_module in ("nfvo", "http", "vim", "wim", "db", "console", "ovim", "sdn", "sdnconn"): + for log_module in log_modules: log_level_module = "log_level_" + log_module log_file_module = "log_file_" + log_module logger_module = logging.getLogger('openmano.' + log_module) diff --git a/RO/osm_ro/vim_thread.py b/RO/osm_ro/vim_thread.py index b8f6a376..7174fe67 100644 --- a/RO/osm_ro/vim_thread.py +++ b/RO/osm_ro/vim_thread.py @@ -811,10 +811,9 @@ class vim_thread(threading.Thread): return False def run(self): - self.logger.debug("Starting") + self.logger.info("Starting") while True: self.get_vim_sdn_connector() - self.logger.debug("Vimconnector loaded") reload_thread = False while True: