Skip to main content

Concurrent logging handler (drop-in replacement for RotatingFileHandler)

Project description

Overview

This module provides an additional log handler for Python’s standard logging package (PEP 282). This handler will write a log entries to a set of files, which switches from one file to the next when the current file reaches a certain size. Multiple processes can write to the log file concurrently.

Details

The ConcurrentRotatingFileHandler class is a drop-in replacement for Python’s standard log handler RotatingFileHandler. This module uses file locking so that multiple processes can concurrently log to a single file without dropping or clobbering log records. This module provides a file rotation scheme like RotatingFileHanler, except that extra care is taken to ensure that logs can be safely rotated before the rotation process is started. (This module works around the file rename issue with RotatingFileHandler on Windows, where a rotation failure means that all subsequent logs are lost).

This module’s attempts to preserve log records at all cost. This means that log files will grow larger than the specified maximum (rotation) size. So if disk space is tight, you may want to stick with RotatingFileHandler, which will strictly adhere to the maximum file size.

Installation

Use the following command to install this package:

easy_install ConcurrentLogHandler

Simple example

Here is a example demonstrating how to use this module:

from logging import getLogger, INFO
from cloghandler import ConcurrentRotatingFileHandler
import os

log = getLogger()
# 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 = ConcurrentRotatingFileHandler(logfile, "a", 512*1024, 5)
log.addHandler(rotateHandler)
log.setLevel(INFO)

log.info("Here is a very exciting log message, just for you")

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

ConcurrentLogHandler-0.7.4.tar.gz (18.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ConcurrentLogHandler-0.7.4-py2.5.egg (24.3 kB view details)

Uploaded Egg

ConcurrentLogHandler-0.7.4-py2.4.egg (24.4 kB view details)

Uploaded Egg

File details

Details for the file ConcurrentLogHandler-0.7.4.tar.gz.

File metadata

File hashes

Hashes for ConcurrentLogHandler-0.7.4.tar.gz
Algorithm Hash digest
SHA256 d17bebae5d14daecfcdda84129352f2e331c9fae6910e6d710a936600905f9f6
MD5 76437ce83df3f51fd7a2b4a4a3bc23cb
BLAKE2b-256 9d2d48d53a7c1d69da75903c5bcb7e3a216f7b8ade73557756c748091b6abb3e

See more details on using hashes here.

File details

Details for the file ConcurrentLogHandler-0.7.4-py2.5.egg.

File metadata

File hashes

Hashes for ConcurrentLogHandler-0.7.4-py2.5.egg
Algorithm Hash digest
SHA256 489fd808e048d639c939576c44097576731e83da96b49696c9b6ab0e799d71af
MD5 2043a4f319c3d5202ce697216eb13014
BLAKE2b-256 3d0db1828f90e52488746fb5bef15d7d49cb293c2768c0a1c11d8703690ae470

See more details on using hashes here.

File details

Details for the file ConcurrentLogHandler-0.7.4-py2.4.egg.

File metadata

File hashes

Hashes for ConcurrentLogHandler-0.7.4-py2.4.egg
Algorithm Hash digest
SHA256 957fffc96fc50ed7533ad530d8d8f3268a02035f80885f69324baa5ab6778f8e
MD5 75d0f6daf6ca5ce012184583971ae2b4
BLAKE2b-256 342bdae97d8643bb57cf43b3a534f5d54ac21fe67cabd1358716c781f3fdb547

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