Handle web logs

This commit is contained in:
2023-07-13 00:23:57 +03:00
parent d44cff1116
commit 5a1cb8a133
3 changed files with 43 additions and 31 deletions

View File

@@ -28,8 +28,11 @@ if os.path.exists(log_file):
break
index += 1
with tarfile.open(gz_path % index, "w:gz") as tar:
tar.add(log_file, os.path.basename(log_file))
os.remove(log_file)
logs_files = [log_file, "./logs/web.log", "./logs/web_access.log"]
for file in logs_files:
if os.path.exists(file):
tar.add(file, os.path.basename(file))
os.remove(file)
fh = logging.FileHandler(log_file, encoding='utf-8')
fh.setFormatter(logging.Formatter(log_format))