Skip to content

Python TimedRotatingFileHandler with cached rollover time

License

Notifications You must be signed in to change notification settings

manuelpepe/ATRFileHandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ATRFileHandler

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.

Diferences with TimedRotatingFileHandler

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.

Install

With pip:

pip install ATRFileHandler

Usage

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")

Running tests

pip install -e .
pytest --cov=ATRFileHandler/

About

Python TimedRotatingFileHandler with cached rollover time

Resources

License

Stars

Watchers

Forks

Packages

No packages published