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_cli_logging()
if get_config().environment == "development":
# Lazy import logfire only in development
try:
import logfire # type: ignore
# Configure logfire (only sends data if token is present)
try:
import logfire
logfire.configure(send_to_logfire="if-token-present")
logfire.instrument_pydantic_ai()
except Exception:
pass
else:
is_production = get_config().environment != "development"
logfire.configure(
send_to_logfire="if-token-present",
console=False if is_production else None,
)
logfire.instrument_pydantic_ai()
except Exception:
pass
if get_config().environment != "development":
# Suppress warnings in production
warnings.filterwarnings("ignore")