def view_logs(data): diag_logs = diagLogs(data) lookback_days = get_and_convert("How many days?", type_expected=int, default_value=7) attribute_dict = build_attribute_dict(diag_logs, lookback_days) log_item_list = diag_logs.get_log_items(attribute_dict=attribute_dict, lookback_days=lookback_days) print(log_item_list)
def get_last_run_or_heartbeat(data, attr_dict): log_data = diagLogs(data) last_run_or_heartbeat = log_data.find_last_entry_date(attr_dict) if last_run_or_heartbeat is missing_data: last_run_or_heartbeat = "00/00 Never run" else: last_run_or_heartbeat = last_run_or_heartbeat.strftime(short_date_string) return last_run_or_heartbeat
def view_errors(data): diag_logs = diagLogs(data) msg_levels = diag_logs.get_possible_log_level_mapping() print("This will get all log messages with a given level of criticality") print("Use view logs to filter by log attributes") lookback_days = get_and_convert("How many days?", type_expected=int, default_value=7) print("Which level of error/message?") log_level = print_menu_and_get_response(msg_levels) log_item_list = diag_logs.get_log_items_with_level(log_level, attribute_dict=dict(), lookback_days=lookback_days) print_log_items(log_item_list)
def get_last_run_or_heartbeat(data, attr_dict): #FIXME CAN BE REMOVED ONCE STRATEGY STUFF REFACTORED log_data = diagLogs(data) last_run_or_heartbeat = log_data.find_last_entry_date(attr_dict) if last_run_or_heartbeat is missing_data: last_run_or_heartbeat = "00/00 Never run" else: last_run_or_heartbeat = last_run_or_heartbeat.strftime( short_date_string) return last_run_or_heartbeat
def clean_log_files(self): mlog = diagLogs(self.data) self.data.log.msg("Deleting log items more than 30 days old") mlog.delete_log_items_from_before_n_days(days=30)