MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / log_sqlit_by_copy

Function log_sqlit_by_copy

script/pythonprojectlog_cut.py:71–89  ·  view source on GitHub ↗
(log_path, log_name, num)

Source from the content-addressed store, hash-verified

69
70
71def log_sqlit_by_copy(log_path, log_name, num):
72 _del_surplus_log(log_path, log_name, num)
73 his_date = time.strftime("%Y-%m-%d_%H%M%S")
74
75 history_log_path = log_path + '/history_logs'
76 if not os.path.exists(history_log_path):
77 os.makedirs(history_log_path, mode=0o755)
78
79 log_file = os.path.join(log_path, log_name + '.log')
80 if os.path.exists(log_file):
81 history_log_file = history_log_path + '/' + log_name +'_'+ his_date + '_log.log'
82 if not os.path.exists(history_log_file):
83 with open(history_log_file, 'w', encoding='utf-8') as hf:
84 with open(log_file, 'r+', encoding='utf-8') as lf:
85 logs = lf.read()
86 lf.seek(0)
87 lf.truncate()
88 hf.write(logs)
89 print('|---已切割日志到:'+history_log_file)
90
91
92

Callers 1

mainFunction · 0.85

Calls 7

_del_surplus_logFunction · 0.85
openFunction · 0.85
seekMethod · 0.80
existsMethod · 0.45
joinMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected