Cleanup more logs

This commit is contained in:
Nicolas Mowen 2025-06-26 07:02:26 -06:00
parent 22cf475f4a
commit 4870fd2f0b
2 changed files with 4 additions and 2 deletions

View File

@ -13,6 +13,7 @@ from frigate.comms.event_metadata_updater import (
) )
from frigate.config import FrigateConfig from frigate.config import FrigateConfig
from frigate.const import MODEL_CACHE_DIR from frigate.const import MODEL_CACHE_DIR
from frigate.log import redirect_output_to_logger
from frigate.util.object import calculate_region from frigate.util.object import calculate_region
from ..types import DataProcessorMetrics from ..types import DataProcessorMetrics
@ -76,6 +77,7 @@ class BirdRealTimeProcessor(RealTimeProcessorApi):
except Exception as e: except Exception as e:
logger.error(f"Failed to download {path}: {e}") logger.error(f"Failed to download {path}: {e}")
@redirect_output_to_logger(logger, logging.DEBUG)
def __build_detector(self) -> None: def __build_detector(self) -> None:
self.interpreter = Interpreter( self.interpreter = Interpreter(
model_path=os.path.join(MODEL_CACHE_DIR, "bird/bird.tflite"), model_path=os.path.join(MODEL_CACHE_DIR, "bird/bird.tflite"),

View File

@ -193,7 +193,7 @@ class LogRedirect(io.StringIO):
@contextmanager @contextmanager
def redirect_fd_to_queue(queue: Queue[str]) -> Generator[None, None, None]: def __redirect_fd_to_queue(queue: Queue[str]) -> Generator[None, None, None]:
"""Redirect file descriptor 1 (stdout) to a pipe and capture output in a queue.""" """Redirect file descriptor 1 (stdout) to a pipe and capture output in a queue."""
stdout_fd = os.dup(1) stdout_fd = os.dup(1)
read_fd, write_fd = os.pipe() read_fd, write_fd = os.pipe()
@ -249,7 +249,7 @@ def redirect_output_to_logger(logger: logging.Logger, level: int) -> Any:
try: try:
# Redirect C-level stdout # Redirect C-level stdout
with redirect_fd_to_queue(queue): with __redirect_fd_to_queue(queue):
result = func(*args, **kwargs) result = func(*args, **kwargs)
finally: finally:
# Restore Python stdout/stderr # Restore Python stdout/stderr