pastlogging 1.0a1

Last updated:

0 purchases

pastlogging 1.0a1 Image
pastlogging 1.0a1 Images
Add to Cart

Description:

pastlogging 1.0a1

pastlogging — Logging extension for Python
Source code: https://github.com/jimstraus/pastlogging
This module extends the built in logging module in Python. It supports both Python 2.3 and greater and Python 3.X.
The key benefit is to provide a mechanism where logs are not cluttered with info and debug messages, but when a warning or error occurs, you get all the previous info and debug messages. Because it is based on the standard logging module, all the usual flexibility in terms of handlers, filters, name spaces, etc. are available.
Please read the Python Standard Library documentation for logging to understand all the normal options and mechanisms for logging.
PastLogger Objects
PastLoggers are extended with the following methods. Not that PastLoggers are generated and retrieved using the same mechanism as the normal logger.
logging.getLogger()

PastLogger.setLevel(level)
Sets the threshold for this logger to level. Logging messages which are less severe than level will be held (up to a maximum number, see below). If a message equals or is greater than the threshold, then all held messages and the current message are sent to the log(s).
PastLogger.setMinLevel(level)
Sets the minimum level of messages to be held. No messages below the minimum level will be held.
PastLogger.setMax(number)
Sets the number of messages to be held. The default is 1000 and if set to -1 there is no limit.
PastLogger.reset()
Resets the buffer holding messages. This can be used when entering code where the previous operations completed either successfully or unsuccessfully.
PastLogger Usage
To minimize the changes to existing code, you may
import pastlogging as logging

At that point, all code using logging should work as expected.
Since the previous log messages are sent to the logs at the same time, the timestamp stored in the LogRecords themselves. This can be configured using
logging.basicConfig(format='%(asctime)s %(message)s')

Or see the builtin logging documentation for further formatting optinos.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.