INNER CODE UNIT · Python
set_filters
br3ndonland/inboard · inboard/logging_conf.py:96
def set_filters(input_filters: str | None = None) -> set[str] | None:
"""Set log message filters.
Filters identify log messages to filter out, so that the logger does not
log messages containing any of the filters. The argument to this method
should be supplied as a comma-separated string. The string will be split
on commas and converted to a set of strings.
This method is provided as a `staticmethod`, instead of as part of `__init__`,
so that it only runs once when setting the `LOG_FILTERS` module-level constant.
In contrast, the `__init__` method runs each time a logger is instantiated.
"""
return (
{log_filter.strip() for log_filter in str(log_filters).split(sep=",")}
if (log_filters := input_filters or os.getenv("LOG_FILTERS"))
else None
)