Merge pull request #188 from ggozad/fix/logfire-production

Use logfire in production if available, disable console output only.
This commit is contained in:
Yiorgis Gozadinos 2025-12-11 10:48:39 +02:00 committed by GitHub
commit 99176ba0a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -84,16 +84,20 @@ def main(
# Configure logging for CLI context # Configure logging for CLI context
configure_cli_logging() configure_cli_logging()
if get_config().environment == "development": # Configure logfire (only sends data if token is present)
# Lazy import logfire only in development try:
try: import logfire
import logfire # type: ignore
logfire.configure(send_to_logfire="if-token-present") is_production = get_config().environment != "development"
logfire.instrument_pydantic_ai() logfire.configure(
except Exception: send_to_logfire="if-token-present",
pass console=False if is_production else None,
else: )
logfire.instrument_pydantic_ai()
except Exception:
pass
if get_config().environment != "development":
# Suppress warnings in production # Suppress warnings in production
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")