Home Assistant Unofficial Reference 2024.12.1
util.py
Go to the documentation of this file.
1 """Utilities for MJPEG IP Camera."""
2 
3 import logging
4 
5 
6 class NoHeaderErrorFilter(logging.Filter):
7  """Filter out urllib3 Header Parsing Errors due to a urllib3 bug."""
8 
9  def filter(self, record: logging.LogRecord) -> bool:
10  """Filter out Header Parsing Errors."""
11  return "Failed to parse headers" not in record.getMessage()
12 
13 
14 def filter_urllib3_logging() -> None:
15  """Filter header errors from urllib3 due to a urllib3 bug."""
16  urllib3_logger = logging.getLogger("urllib3.connectionpool")
17  if not any(isinstance(x, NoHeaderErrorFilter) for x in urllib3_logger.filters):
18  urllib3_logger.addFilter(NoHeaderErrorFilter())
bool filter(self, logging.LogRecord record)
Definition: util.py:9