Skip to main content

cotimelog, inspired from [ConcurrentLogHandler](https://pypi.python.org/pypi/ConcurrentLogHandler/0.9.1). To be honest, it is almost the same code. Just edit to make the log file rotated by time.

Installation

pip install cotimelog

ConcurrentTimeRotatingFileHandler

This class is a log handler which is a drop-in replacement for the python standard log handler TimedRotatingFileHandler. The TimedRotatingFileHandler will failed to rotate when multiple processes are trying to write into the same file. You will meet this issue when you use uwsgi. This ConcurrentTimeRotatingFileHandler class is mainly developed to fix this issue.

Usage

Using ConcurrentTimeRotatingFileHandler

import os
import time
from logging import getLogger, INFO
from cotimelog import ConcurrentTimeRotatingFileHandler

# Use an absolute path to prevent file rotation trouble.
log = getLogger()
logfile = os.path.abspath("mylogfile.log")
# Rotate log after 1 second
rotateHandler = ConcurrentTimeRotatingFileHandler(logfile, mode="a", when="S", backupCount=5)
log.addHandler(rotateHandler)
log.setLevel(INFO)

[log.info(str(i)) for i in range(10)]
time.sleep(1)
[log.info(str(i)) for i in range(10, 100)]
License

Apache License, Version 2.0

Metadata

Release files for cotimelog 0.2.0

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

Source distribution (sdist)

Source distribution for cotimelog 0.2.0
File Size Uploaded Provenance
cotimelog-0.2.0.tar.gz 7.6 kB Without provenance Details

Release files / cotimelog-0.2.0.tar.gz

Download URL cotimelog-0.2.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
564dc33e214d0df859a075e8346cadb8a7aaf47de1059a4447c05673d3590b56
BLAKE2b-256 checksum
How to use checksums
b865431666effdd0fddfcd78e937a7205e715b125096f7c90ab3d8882d4177b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cotimelog 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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