Tiered Debug is a Python logging helper module that provides multiple, configurable levels of debug logging. It wraps standard Python `logging.debug()` calls, allowing developers to set a maximum debug tier that will be logged at runtime. The library is actively maintained, with version 1.4.0 released recently, and shows a consistent release cadence with several updates in the past year.
pip install tiered-debugVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate `TieredDebug`, set its debug level, and log messages using the `lvX()` methods or the generic `log()` method. It also shows how to temporarily adjust the logging level using the `log_level_context` context manager and how to pass standard `logging` keyword arguments like `exc_info`.
Refactor code to instantiate `TieredDebug` and use its instance methods (`lv1`, `lv2`, `log`, `set_level`, etc.) instead of the old module-level functions. The `debug_level` argument in the constructor replaces the environment variable for instance-specific control.
Always explicitly pass `False`, `True`, or an appropriate value for `exc_info`, `stack_info`, `stacklevel`, and `extra` if you require specific behavior, rather than relying on the method's default `None` (which defers to the `logging` module's default) or specific boolean defaults.
Ensure that the `logging` module is properly configured with at least one handler (e.g., `logging.basicConfig()` or `td.add_handler(logging.StreamHandler())`) and that the logger's level is set to `logging.DEBUG` or lower to capture debug messages.
Change your import statement from `import debug` or `from debug import ...` to `from tiered_debug import TieredDebug`.
Before instantiating `TieredDebug` or using its methods, ensure `logging.basicConfig(level=logging.DEBUG)` is called, or explicitly add a handler to the `TieredDebug` instance's logger using `td.add_handler(my_handler)` and set the logger's level to `logging.DEBUG`.
To have an instance respect the environment variable, initialize it without the `debug_level` argument: `td = TieredDebug()`. Alternatively, explicitly set the `debug_level` in the constructor: `td = TieredDebug(debug_level=int(os.getenv('TIERED_DEBUG_LEVEL', '1')))`.No dependency data recorded yet.