Filters module
Implementations of logging.Filter
.
FilterWithContextVar
Bases: Filter
Add the values from the current context to all the log messages as extra
keys.
This class is not meant to be used directly, instead it's used by the
global_context
module.
Source code in src/logging_with_context/filters.py
__init__(context_var)
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context_var
|
ContextVar[dict[str, Any]]
|
The context storage to use. |
required |
filter(record)
Add the context values to the log message.
Returns:
Type | Description |
---|---|
bool
|
Always returns |