jaraco.logging
raw JSON → 3.4.0 verified Fri May 01 auth: no python
A utility library for Python logging that provides additional log levels (like NOTICE and TRACE), a filtering handler, and a log suppression context manager. Current version is 3.4.0, supports Python >=3.9, and is maintained as part of the jaraco project. Releases are frequent.
pip install jaraco-logging Common errors
error AttributeError: module 'jaraco.logging' has no attribute 'LogSuppressor' ↓
cause LogSuppressor was renamed to suppress in v3.0.0.
fix
Use: from jaraco.logging import suppress
with suppress(): ...
error ImportError: cannot import name 'add_level' from 'jaraco_logging' ↓
cause Wrong import path: using hyphen instead of dot.
fix
Use: from jaraco.logging import add_level
Warnings
gotcha add_level modifies the logging module globally. It may conflict with other libraries that add the same level names. ↓
fix Use unique level names or only add levels in isolated modules.
deprecated The old 'LogSuppressor' class (used as a context manager) was renamed to 'suppress' in v3.0.0. ↓
fix Use 'from jaraco.logging import suppress' instead of 'LogSuppressor'.
Imports
- add_level wrong
from jaraco_logging import add_levelcorrectfrom jaraco.logging import add_level - FilteringHandler
from jaraco.logging.handlers import FilteringHandler
Quickstart
import logging
from jaraco.logging import add_level, suppress
# Add a custom TRACE level (value 5)
add_level('TRACE', 5)
logger = logging.getLogger(__name__)
logger.trace('This is a trace message')
# Suppress all logging for a block
with suppress():
logger.info('This will not appear')