Skip to main content

Time handler for repetitive short-duration processes.

Project description

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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ATRFileHandler-0.1.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

ATRFileHandler-0.1.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file ATRFileHandler-0.1.1.tar.gz.

File metadata

  • Download URL: ATRFileHandler-0.1.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for ATRFileHandler-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8fb63947a1e37c702fe90bea4e57fe2663bc385cd7ec05de7eb4f28978185161
MD5 98deff47cd303e5da8966ee969d96718
BLAKE2b-256 3983b7969301617b1076b61ea17fb96bdb4dc029066eaf1eb3a34374089af25a

See more details on using hashes here.

File details

Details for the file ATRFileHandler-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ATRFileHandler-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for ATRFileHandler-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e9eee7c204f884caecff073d45bacb6bc9af9b00fe5b3f4bfa81ba34d07d837
MD5 d76b1f295484c431ebb4294e5c164cfc
BLAKE2b-256 72cb350c1a9dfa7d12013995b84b01037eeb7cd70b4564af79e963551585fd62

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page