This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from typing import Set | |
# The global set of suppressed strings is used to avoid logging | |
_suppressed_strings: Set[str] = set() | |
class SuppressLogMessagesFilter(logging.Filter): | |
"""Filter that suppresses log records containing any of the target substrings.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########### | |
## Original taken from https://gist.github.com/schaumb/d557dabf0beced7dfaa1be7acc09b1e4 | |
## Modified and improved for better reliability | |
########### | |
import gc | |
import weakref | |
import logging | |
from typing import Optional, Callable, Union, Dict, Set | |
from collections import defaultdict |