Skip to main content

Logging extension to emit full logs when a threshold is reached

Project description

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.

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

pastlogging-1.0a1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

pastlogging-1.0a1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pastlogging-1.0a1.tar.gz.

File metadata

  • Download URL: pastlogging-1.0a1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

File hashes

Hashes for pastlogging-1.0a1.tar.gz
Algorithm Hash digest
SHA256 37f6e26e8e2fbe4ca3e9df8af8f02aa3041f178cbded47233d31f11c5670d319
MD5 cbdc05d22881dd25af91b153feb037cc
BLAKE2b-256 5dd91d805e3b46384792ef9ae70b72084a21cea3479d02c83006f617b787e522

See more details on using hashes here.

File details

Details for the file pastlogging-1.0a1-py3-none-any.whl.

File metadata

  • Download URL: pastlogging-1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

File hashes

Hashes for pastlogging-1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 91723600245865a745c838671b646534178d909c9ebf50531a613b7ee5eec108
MD5 1fcd45a5e55dfafd49d8a2c4268ef138
BLAKE2b-256 6730b1434003079fd3ddba6d2acba99f0838b0043cfb96d8d1ddcf7f62f51220

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