Skip to main content

mixins for tornado

Project description

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

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

cotimelog-0.1.3.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file cotimelog-0.1.3.tar.gz.

File metadata

  • Download URL: cotimelog-0.1.3.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cotimelog-0.1.3.tar.gz
Algorithm Hash digest
SHA256 124fde62c543d0cd180e2c4c7d07a781e203c1891b96236abd3123163f00192e
MD5 53c671dced1fafba6337c3110bdc1752
BLAKE2b-256 e864a471beb1d49298ad5b4b600420e97b9256fa5a02ef342d288e5ab9f5051d

See more details on using hashes here.

Supported by

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