def main_test_routine(): """ Main test routine. * Get args from CLI * Setup Logging * Execute data generation :return: """ args = parse_cli() log = Logger(set_root=True, default_level=Logger.DEBUG if args.debug else Logger.INFO) log.debug("DEBUG enabled.") execute(num_data_sets=args.num_data_sets, max_records=args.max_records, cfg_file=args.cfg)
def configure_logging(cls, app_cfg_obj: PdlConfig) -> Logger: """ Sets up the root logger (format, location) and updates the existing the handlers :param app_cfg_obj: (PdlConfig): Contains the required location, etc., for the logger :return: Instantiated, updated root logger """ # Set log level (CLI overrides the config file) # --------------------------------------------- # Get the config-file specified value log_level = app_cfg_obj.app_cfg.get( AppCfgFileSections.LOGGING, AppCfgFileSectionKeys.LOG_LEVEL.lower()) if app_cfg_obj.cli_args.debug: log_level = 'debug' # Determine and store the log file name, create directory if needed. log_dir = os.path.abspath( os.path.sep.join( app_cfg_obj.logfile_name.split(os.path.sep)[0:-1])) utils.check_if_location_exists(location=log_dir, create_dir=True) # Setup the root logger for the app logger = Logger(filename=app_cfg_obj.logfile_name, default_level=Logger.STR_TO_VAL[log_level], project=app_cfg_obj.app_cfg.get( AppCfgFileSections.PROJECT, AppCfgFileSectionKeys.NAME), set_root=True) # Show defined loggers and log levels logger.debug(f"Log File: {app_cfg_obj.logfile_name}") for line in logger.list_loggers().split('\n'): logger.debug(line) return logger