Skip to main content

Rotate logs with incremental generation numbers

Project description

JRotateLog

Rotate logs with incremental generation numbers. This is similar to the RotatingFileHandler but instead of max bytes as the rotate condition its when a new python program runs. For every run of the python code rotate the logs with the backed up files indexed start at 0.

Ex. Run python program 3 times creates 2 backups

app.log
app.log.0
app.log.1

backup_count can be used to limit how many logs are kept. Ex. Run python program 4 times with backupCount = 2

app.log   (from run 4)
app.log.0 (from run 3)
app.log.1 (from run 2)
app.log.2 (from run 1, deleted)

Install

pip install jrotatelog

Usage

from jrotatelog.handler import RotateFileHandler

logger = logging.getLogger("app")
fh = RotateFileHandler("app.log")
logger.addHandler(fh)

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

jrotatelog-0.1.0.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

jrotatelog-0.1.0-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

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