def f_print_log_error(conn,perfor_or_infor,save_as):
title = "Log file Statistics"
style = {1: 'start & shutdown:,l'}
rows =[]
WarnLog = 0
ErrLog = 0
query = "SELECT variable_value FROM " + perfor_or_infor + ".global_variables where variable_name ='log_error'"
filename = f_get_query_value(conn, query)
if os.path.exists(filename):
with open(filename, 'r') as f:
for line in f:
if ('ready for connections' in line or 'Shutdown completed' in line):
rows.append([line])
if ('Warning' in line):
WarnLog += 1
if ('error' in line):
ErrLog += 1
else:
rows.append([filename + " not exists"])
rows.append(['Warning & Error Statistics:'])
rows.append([filename + ' contains ' + str(WarnLog) + ' warning(s).'])
rows.append([filename + ' contains ' + str(ErrLog) + ' error(s).'])
f_print_table(rows, title, style,save_as)
评论列表
文章目录