| 69 | |
| 70 | |
| 71 | def 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 | |