+
+
+def set_logging_file(log_file):
+ try:
+ file_handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=100e6, backupCount=9, delay=0)
+ file_handler.setFormatter(log_formatter_simple)
+ logger.addHandler(file_handler)
+ # remove initial stream handler
+ logging.root.removeHandler(logging.root.handlers[0])
+ print ("logging on '{}'".format(log_file))
+ except IOError as e:
+ raise LoadConfigurationException(
+ "Cannot open logging file '{}': {}. Check folder exist and permissions".format(log_file, e))
+
+
+if __name__ == "__main__":
+ # 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 = {
+ 'RO_DB_HOST': 'db_host',
+ 'RO_DB_NAME': 'db_name',
+ 'RO_DB_USER': 'db_user',
+ 'RO_DB_PASSWORD': 'db_passwd',
+ 'RO_DB_OVIM_HOST': 'db_ovim_host',
+ 'RO_DB_OVIM_NAME': 'db_ovim_name',
+ 'RO_DB_OVIM_USER': 'db_ovim_user',
+ 'RO_DB_OVIM_PASSWORD': 'db_ovim_passwd',
+ 'RO_LOG_LEVEL': 'log_level',
+ 'RO_LOG_FILE': 'log_file',
+ }
+ # Configure logging step 1