[FDE-360] Add stdlib JSON formatter and configure_logging to pylogtracer#158
[FDE-360] Add stdlib JSON formatter and configure_logging to pylogtracer#158
Conversation
…gtracer - Add JSONLogFormatter: stdlib-only structured JSON formatter matching Go zap logger schema (timestamp, level, msg, caller, logger, stacktrace) - Add configure_logging(): one-call root logger setup with dev/prod dual mode via DEVELOPMENT_MODE env var, langfuse suppression, log level control - Make loguru and opentelemetry optional extras — core has zero dependencies - Fix pyproject.toml packages config and lower requires-python to >=3.11 - Extract OpenTelemetry init into tracing_setup.py, lazy-load via __getattr__ - Use single-arg traceback.format_exception() (Python 3.14 compatible) - Add 21 tests (formatter + config) and CI workflow + Makefile targets Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace __getattr__ magic with explicit get_structured_logger() and get_tracer() functions - Replace getattr(logging, ...) with logging.getLevelNamesMapping() - Add boto3 to [tracing] optional dependency - Rename get_secret_from_param_store to private _get_secret_from_param_store - Replace print() with logging.exception() for proper error visibility - Rename create_exporter to private _create_exporter - Remove module-level tracer initialization (callers use get_tracer()) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Addressed all review comments:
|
Summary
JSONLogFormatter— stdlib-onlylogging.Formatterthat outputs one JSON object per line matching the Go zap logger schema (timestamp,level,msg,caller,logger,stacktrace)configure_logging()— one-call root logger setup with dev/prod dual mode viaDEVELOPMENT_MODEenv varpyproject.tomlpackages config (was["agents", "models_python"]) and lowersrequires-pythonto>=3.11tracing_setup.py, lazy-loads optional modules via__getattr__traceback.format_exception()for Python 3.14 compatibilityAddresses reviewer feedback from Hyperdrive PR #1953 to move the JSON log formatter into pylogtracer.
Test plan
make lint-pythonpasses (ruff format + check)make test-pythonpasses (21 tests)🤖 Generated with Claude Code