thinlog.filters package#
Log filters for whitelisting, blocklisting, and conditional attribute assignment.
- class thinlog.filters.AssignerFilter(assignments: dict[str, Any], **kwargs: Any)[source]#
Bases:
WhitelistFilterAssign attributes to matching records without blocking any.
Extends
WhitelistFilter– if a record matches the whitelist criteria, the assignments dict is applied to the record as attributes. The filter always returnsTrueso no records are dropped.- Parameters:
assignments – Mapping of attribute names to values that will be set on matching records via
setattr().
- class thinlog.filters.BlocklistFilter(by_name: list[str] | None = None, by_msg: list[str] | None = None, by_attr: dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
FilterBlock records whose name, message, or attributes match a blocklist.
This is the inverse of
WhitelistFilter. Any record that matches is rejected; all others pass through.- Parameters:
by_name – Logger names to block.
by_msg – Messages to block.
by_attr – Mapping of attribute names to values that trigger blocking. Use
"_any_"to block on any value for a given attribute.
- class thinlog.filters.WhitelistFilter(by_name: list[str] | None = None, by_msg: list[str] | None = None, by_attr: dict[str, Any] | None = None, **kwargs: Any)[source]#
Bases:
FilterAllow records whose name, message, or attributes match a whitelist.
Records are checked against three criteria (any match is sufficient):
by_name – the record’s logger name.
by_msg – the record’s message (also checked inside JSON-encoded messages).
by_attr – arbitrary record attributes; use the special value
"_any_"to match any value for a given attribute.
- Parameters:
by_name – Logger names to allow.
by_msg – Messages to allow.
by_attr – Mapping of attribute names to expected values.