caosadvancedtools.suppressKnown module#
- class caosadvancedtools.suppressKnown.SuppressKnown(db_file: str | Path | None = None)#
Bases:
FilterThis filter allows to suppress log messages that were shown before.
The python logging module can be used as normal. This Filter needs to be added to the appropriate Logger and logging calls (e.g. to warning, info etc.) need to have an additional extra argument. This argument should be a dict that contains an identifier and a category.
Example:
extra={"identifier":"<Record>something</Record>", category="entities"}
The identifier is used to check whether a message was shown before and should be a string. The category can be used to remove a specific group of messages from memory and the logger would show those messages again even when they are known.
- create_cache()#
- filter(record)#
Return whether the record shall be logged.
If either identifier of category is missing 1 is returned (logging enabled). If the record has both attributes, it is checked whether the combination was shown before (was_tagged). If so 0 is returned. Otherwise the combination is saved and 1 is returned
- hash(txt, identifier)#
- reset(category)#
- tag_msg(txt, identifier, category)#
- was_tagged(digest)#