thinlog.filters.blocklist module

thinlog.filters.blocklist module#

Blocklist filter – reject log records that match specific criteria.

class thinlog.filters.blocklist.BlocklistFilter(by_name: list[str] | None = None, by_msg: list[str] | None = None, by_attr: dict[str, Any] | None = None, **kwargs: Any)[source]#

Bases: Filter

Block 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.

filter(record: LogRecord) bool[source]#

Return False if the record matches any blocklist criterion.