Merge pull request #188 from ggozad/fix/logfire-production
Use logfire in production if available, disable console output only.
This commit is contained in:
commit
99176ba0a1
1 changed files with 13 additions and 9 deletions
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue