Skip to main content

mixins for tornado

Project description

pip install timelog

timelog, 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.

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 TimedRotatingFileHandler

import time
from logging import getLogger, INFO
from timelog 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")

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.0.tar.gz (7.2 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for cotimelog-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7618c33947b115fbb7cf20b0d158b3e72a963d732a4567cd8c2754d3a6b90eae
MD5 5a978dce172cb72055b074940ee2361e
BLAKE2b-256 8296ac48c009d386fe0fe1be808faa98f11daf2209ab9e6f151aaeb4433fadbb

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