chore: refactor telemetry module with utility functions and modern typing (#3485)

Co-authored-by: Lucas Gomide <lucaslg200@gmail.com>
This commit is contained in:
Greyson LaLonde
2025-09-10 09:18:21 -04:00
committed by GitHub
parent 079cb72f6e
commit b126ab22dd
4 changed files with 367 additions and 215 deletions

View File

@@ -1,8 +1,9 @@
"""Logging utility functions for CrewAI."""
"""Logging and warning utility functions for CrewAI."""
import contextlib
import io
import logging
import warnings
from collections.abc import Generator
@@ -36,3 +37,20 @@ def suppress_logging(
):
yield
logger.setLevel(original_level)
@contextlib.contextmanager
def suppress_warnings() -> Generator[None, None, None]:
"""Context manager to suppress all warnings.
Yields:
None during the context execution.
Note:
There is a similar implementation in src/crewai/llm.py that also
suppresses a specific deprecation warning. That version may be
consolidated here in the future.
"""
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
yield