Skip to content

Commit

Permalink
feat: add log ctrl module
Browse files Browse the repository at this point in the history
  • Loading branch information
maksyuki committed Mar 9, 2024
1 parent 8e7a784 commit 62d59ea
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/log_ctrl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/python

import os
import glob
import config


def save_run_log():
# save_log_[xx]
file_list = glob.glob(f'{config.SAVE_LOG_PATH}*')
if len(file_list) == 0:
os.system(f'cp -rf {config.RUN_LOG_PATH} {config.SAVE_LOG_PATH}_0')

else:
max_idx = 0
for v in file_list:
idx = int(v.split('_')[-1])
if idx > max_idx:
max_idx = idx

os.system(
f'cp -rf {config.RUN_LOG_PATH} {config.SAVE_LOG_PATH}_{max_idx+1}')

os.system(f'echo "" > {config.RUN_LOG_PATH}')


def main():
if os.path.isfile(config.RUN_LOG_PATH):
file_size = os.path.getsize(config.RUN_LOG_PATH)
if file_size >= config.RUN_LOG_SIZE_LIMIT:
save_run_log()


if __name__ == '__main__':
main()

0 comments on commit 62d59ea

Please sign in to comment.