Skip to main content

ATRFileHandler

ATRFileHandler, or AbsoluteTimedRotatingFileHandler, is a file handler like TimedRotatingFileHandler that also caches the next rollover time for your logfiles, 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

The main difference is that instead of only using the handler creation time to calculate the next rollover, it also writes and reads it from a cache file. With TimeRotatingFileHandler, if you want to rotate logs daily but your process starts and ends in a couple of minutes, when you run it in one hour the logfile will not rotate, because the handler won't remember the last time it was used. ATRHandler will rotate it because it saves this data to a file cache.

This allows you to easily keep weekly logfiles for a periodic shot-lived process, without making that process into a service or long running process.

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/

Release files for ATRFileHandler 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ATRFileHandler 0.1.1
File Size Uploaded
ATRFileHandler-0.1.1.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ATRFileHandler 0.1.1
File Interpreter ABI Platform
ATRFileHandler-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / ATRFileHandler-0.1.1.tar.gz

Download URL ATRFileHandler-0.1.1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8fb63947a1e37c702fe90bea4e57fe2663bc385cd7ec05de7eb4f28978185161
BLAKE2b-256 checksum
How to use checksums
3983b7969301617b1076b61ea17fb96bdb4dc029066eaf1eb3a34374089af25a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

Release files / ATRFileHandler-0.1.1-py3-none-any.whl

Download URL ATRFileHandler-0.1.1-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e9eee7c204f884caecff073d45bacb6bc9af9b00fe5b3f4bfa81ba34d07d837
BLAKE2b-256 checksum
How to use checksums
72cb350c1a9dfa7d12013995b84b01037eeb7cd70b4564af79e963551585fd62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page