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 time
from logging import getLogger, INFO
from cotimelog import ConcurrentTimeRotatingFileHandler

# Use an absolute path to prevent file rotation trouble.
logfile = os.path.abspath("mylogfile.log")
# Rotate log after reaching 512K, keep 5 old copies.
rotateHandler = ConcurrentTimeRotatingFileHandler(logfile, mode="a", when="S")
log.addHandler(rotateHandler)
log.setLevel(INFO)

log.info("Here is a very exciting log message, just for you")
log.info("Here is one more very exciting log message, just for you")
time.sleep(1)
log.info("This should be in another file")

Project details


Download files

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

Files for cotimelog, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size cotimelog-0.1.1.tar.gz (7.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page