+ if not global_config["http_console_host"]:
+ global_config["http_console_host"] = global_config["http_host"]
+ if global_config["http_host"]=="0.0.0.0":
+ global_config["http_console_host"] = socket.gethostname()
+
+ #Configure logging STEP 2
+ if "log_host" in global_config:
+ socket_handler= log_handlers.SocketHandler(global_config["log_socket_host"], global_config["log_socket_port"])
+ socket_handler.setFormatter(log_formatter_complete)
+ if global_config.get("log_socket_level") and global_config["log_socket_level"] != global_config["log_level"]:
+ socket_handler.setLevel(global_config["log_socket_level"])
+ logger.addHandler(socket_handler)
+ #logger.addHandler(log_handlers.SysLogHandler())
+ if "log_file" in global_config:
+ try:
+ file_handler= logging.handlers.RotatingFileHandler(global_config["log_file"], maxBytes=100e6, backupCount=9, delay=0)
+ file_handler.setFormatter(log_formatter_simple)
+ logger.addHandler(file_handler)
+ #logger.debug("moving logs to '%s'", global_config["log_file"])
+ #remove initial stream handler
+ logging.root.removeHandler(logging.root.handlers[0])
+ print ("logging on '{}'".format(global_config["log_file"]))
+ except IOError as e:
+ raise LoadConfigurationException("Cannot open logging file '{}': {}. Check folder exist and permissions".format(global_config["log_file"], str(e)) )
+ #logging.basicConfig(level = getattr(logging, global_config.get('log_level',"debug")))
+ logger.setLevel(getattr(logging, global_config['log_level']))
+ logger.critical("Starting openmano server version: '%s %s' command: '%s'",
+ __version__, version_date, " ".join(sys.argv))
+
+ for log_module in ("nfvo", "http", "vim", "db", "console"):
+ log_level_module = "log_level_" + log_module
+ log_file_module = "log_file_" + log_module
+ logger_module = logging.getLogger('openmano.' + log_module)
+ if log_level_module in global_config:
+ logger_module.setLevel(global_config[log_level_module])
+ if log_file_module in global_config:
+ try:
+ file_handler= logging.handlers.RotatingFileHandler(global_config[log_file_module], maxBytes=100e6, backupCount=9, delay=0)
+ file_handler.setFormatter(log_formatter_simple)
+ logger_module.addHandler(file_handler)
+ except IOError as e:
+ raise LoadConfigurationException("Cannot open logging file '{}': {}. Check folder exist and permissions".format(global_config[log_file_module], str(e)) )
+ global_config["logger_"+log_module] = logger_module
+ #httpserver.logger = global_config["logger_http"]
+ #nfvo.logger = global_config["logger_nfvo"]
+