No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE.txt
README.md
burstlogging.py
demo.py
setup.py
test.py

README.md

BurstLoging

Intro

BurstLogging is a smart logging library that allows emitting detailed debug information in production environment without polluting the log file with unnecessary messages. During normal operation only informational messages are logged. However, when an error occurs, previously gathered debug messages are logged as well.

It works by temporarily keeping all log records in a buffer. It preserves their chronological order by dropping debug messages that are older than the recently logged message. There is no huge performance penalty because message is formatted only when it's emitted.

Installation

The package is on PyPI, to install it type:

pip install burstlogging

Usage

To use BurstLogging all you need to do is to create and configure a BurstHandler decorator (only target is necessary, other parameters are optional and their default values are shown below):

BurstHandler(target=handler, 
		level=logging.NOTSET, emitLevel=logging.INFO, burstLevel=logging.ERROR,
		capacity=1000, threshold=0.8)

Where:

  • target - actual handler that will format the logs; note that it will also filter them based on its own level
  • level - log level to be emitted only during burst
  • emitLevel - log level to be always emitted
  • burstLevel - log level to cause a burst
  • capacity - size of a log buffer; when it's too small then some debug logs may be lost, when it's too big logs will be emitted with a delay
  • threshold - part of buffer to be purged on overflow; smaller value increases performance, but may cause some debug logs to be lost

See a complete usage example in demo.py.

Ideas

This is a relatively new constantly evolving project. To see, propose and discuss ideas visit enhancements.