Filter which excludes log messages which match the provided log levels.
| 25 | |
| 26 | |
| 27 | class LogLevelFilter(logging.Filter): |
| 28 | """ |
| 29 | Filter which excludes log messages which match the provided log levels. |
| 30 | """ |
| 31 | |
| 32 | def __init__(self, log_levels): |
| 33 | self._log_levels = log_levels |
| 34 | |
| 35 | def filter(self, record): |
| 36 | level = record.levelno |
| 37 | if level in self._log_levels: |
| 38 | return False |
| 39 | |
| 40 | return True |
| 41 | |
| 42 | |
| 43 | def set_log_level_for_all_handlers(logger, level=logging.DEBUG): |