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}. "