From 01cb4bda05061929000a3784555e64526b2f4770 Mon Sep 17 00:00:00 2001 From: Jared Fagel Date: Wed, 2 Mar 2022 15:40:20 -0600 Subject: [PATCH] Update program.py RotatingFileHandler is necessary to prevent the duologsync.log file from increasing in size indefinitely until the disk fills. Requires testing prior to merge, I have not tested this. --- duologsync/program.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/duologsync/program.py b/duologsync/program.py index b359f32..ff1916a 100644 --- a/duologsync/program.py +++ b/duologsync/program.py @@ -3,6 +3,8 @@ """ import logging +from logging.handlers import RotatingFileHandler + class ProgramShutdownError(Exception): """ @@ -75,6 +77,11 @@ def setup_logging(cls, log_filepath): # Date format to use with logs datefmt='%Y-%m-%d %H:%M:%S' ) + + # Log rotation, allows for 3 rotations, each at 25MB. + logger = logging.getLogger() + handler = RotatingFileHandler(log_filepath, maxBytes=26214400, backupCount=3) + logger.addHandler(handler) except FileNotFoundError as file_not_found_error: cls.log(f"DuoLogSync: Could not follow the path {log_filepath}. "