1
0

adds rotation and overwriting logging

I underestimated the amount of logs generated. This should keep it
within limits most of the time. Might still be a lot of logs, but at
least there's an upper limit now.
This commit is contained in:
2025-02-01 17:22:50 +01:00
parent c06eeda4f2
commit 892e89bdfd
+8 -3
View File
@@ -7,6 +7,7 @@ import sys
import argparse
import tempfile
import logging
from logging.handlers import RotatingFileHandler
import time
import psutil
from tqdm import tqdm
@@ -79,10 +80,14 @@ def setup_logging(verbose: bool) -> None:
console_handler.setLevel(log_level)
console_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
# Create file handler
file_handler = logging.FileHandler(log_file)
# Create rotating file handler
file_handler = RotatingFileHandler(
log_file,
backupCount=100
)
file_handler.setLevel(logging.DEBUG) # Always log everything to file
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
file_handler.doRollover()
# Set up root logger
root_logger = logging.getLogger()
@@ -176,7 +181,7 @@ def run(filepath: pathlib.Path, cmd: list[str], temp_path: pathlib.Path, file_in
ffmpeg_log_path = pathlib.Path(xdg_state_home) / 'vcmp' / 'ffmpeg.log'
ffmpeg_log_path.parent.mkdir(parents=True, exist_ok=True)
with open(ffmpeg_log_path, 'a') as log_file:
with open(ffmpeg_log_path, 'w') as log_file:
process = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,