A Python logging helper module that allows multiple levels of debug logging
Project description
tiered-debug
Table of Contents
Description
This module provides a way to enable multiple tiers of debug logging. It's not
doing anything fancy. It's just a wrapper around a standard logger.debug()
call that caps the highest tier of debug logging to a value which can be set via
the environment variable TIERED_DEBUG_LEVEL at runtime, which has a default of 1,
but can be set to any value between 1 and 5. It can also be set interactively via
the set_level() function.
Installation
pip install tiered-debug
Usage
import tiered_debugging as debug
# Set the debug level globally (optional if using environment variable)
debug.set_level(3)
# Log messages from any module
debug.lv1("This will log") # Logs because 1 <= 3
debug.lv3("This will log") # Logs because 3 <= 3
debug.lv4("This won't log") # Doesn't log because 4 > 3
Configuring stacklevel
The stacklevel parameter is passed to the logging.debug() function as the
stacklevel argument. The stacklevel parameter is the stack level to use for
the log message. The default value is 2, which means that the log message will
appear to come from the caller of the caller each lv# function. In other words,
if you call lv1() from a function, the log message will appear to come from the
caller of that function. If your log formatter is set up to include the module
name, function name, and/or line of code in the log message, having the stacklevel
properly set will ensure the correct data is displayed.
In the event that you use this module as part of another module or class, you may
need to increase the stacklevel to 3. This can be done using the
set_stacklevel() function. This will need to be done before any logging takes
place.
License
tiered-debug is distributed under the terms of the Apache license.
©Copyright 2025 Aaron Mildenstein
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
Built Distribution
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 tiered_debug-1.0.0.tar.gz.
File metadata
- Download URL: tiered_debug-1.0.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
619d117bcdca13158b213b465df804febe28e5534b0266f714ed57eee27e4432
|
|
| MD5 |
4f1fdaca9e0e9a46f247a94f5605e4ad
|
|
| BLAKE2b-256 |
1c127666bf28615de50612975e62d0634d6ccde2ee266d3a8a0846d335250694
|
File details
Details for the file tiered_debug-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tiered_debug-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfda54365fbcc99b44b561e33cef27ba8e26664e1cfb2fed9ef6159a7f91261b
|
|
| MD5 |
c7c9fd43b6ee1cbb328079c6fcd06f69
|
|
| BLAKE2b-256 |
859fe6d2e0fa2f49fb1f5b9da9d1e698cd2b246d4b7a157e3e478a501222e575
|