ATRFileHandler, or AbsoluteTimedRotatingFileHandler, is a file handler like TimedRotatingFileHandler that caches rollover time for your logfiles across executions, allowing future instances of your application to rotate the logfile in schedule, avoiding surprices of large logfiles that haven't rotated as you expected.
Python's built-in logging.TimedRotatingFileHanndler
calculates the initial rollover time at instantiation, meaning that it's lost when the program exits. ATRFileHandler
catches the next rollover time in a file on the same parent directory as your log files, and loads it at instantiation.
With pip:
pip install ATRFileHandler
It can be used exactly as the TimedRotatingFileHandler from the builting logging
module.
Example:
import logging
from ATRFileHandler import ATRFileHandler
logger = logging.getLogger()
handler = ATRFileHandler("test.log", when="D", interval=3, backupCount=3)
logger.addHandler(handler)
logger.error("too much rythm")
pip install -e .
pytest --cov=ATRFileHandler/