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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ConcurrentLogHandler-0.7.4.tar.gz.
File metadata
- Download URL: ConcurrentLogHandler-0.7.4.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d17bebae5d14daecfcdda84129352f2e331c9fae6910e6d710a936600905f9f6
|
|
| MD5 |
76437ce83df3f51fd7a2b4a4a3bc23cb
|
|
| BLAKE2b-256 |
9d2d48d53a7c1d69da75903c5bcb7e3a216f7b8ade73557756c748091b6abb3e
|
File details
Details for the file ConcurrentLogHandler-0.7.4-py2.5.egg.
File metadata
- Download URL: ConcurrentLogHandler-0.7.4-py2.5.egg
- Upload date:
- Size: 24.3 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
489fd808e048d639c939576c44097576731e83da96b49696c9b6ab0e799d71af
|
|
| MD5 |
2043a4f319c3d5202ce697216eb13014
|
|
| BLAKE2b-256 |
3d0db1828f90e52488746fb5bef15d7d49cb293c2768c0a1c11d8703690ae470
|
File details
Details for the file ConcurrentLogHandler-0.7.4-py2.4.egg.
File metadata
- Download URL: ConcurrentLogHandler-0.7.4-py2.4.egg
- Upload date:
- Size: 24.4 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
957fffc96fc50ed7533ad530d8d8f3268a02035f80885f69324baa5ab6778f8e
|
|
| MD5 |
75d0f6daf6ca5ce012184583971ae2b4
|
|
| BLAKE2b-256 |
342bdae97d8643bb57cf43b3a534f5d54ac21fe67cabd1358716c781f3fdb547
|