Skip to content

Standardize logging config#191

Open
fahe1em1 wants to merge 1 commit intodotimplement:mainfrom
fahe1em1:fix/standardize-logging-config
Open

Standardize logging config#191
fahe1em1 wants to merge 1 commit intodotimplement:mainfrom
fahe1em1:fix/standardize-logging-config

Conversation

@fahe1em1
Copy link

Summary

Closes #124

  • Enhances healthchain/utils/logger.py with a centralized get_logger() function that configures a single console handler on the root healthchain logger
  • All child loggers inherit this handler via standard library propagation — no per-module handler setup needed
  • Log level is configurable via HEALTHCHAIN_LOG_LEVEL environment variable (defaults to INFO)
  • Migrates all 50 modules from raw import logging + logging.getLogger(__name__) to the centralized get_logger(__name__)
  • Existing add_handlers() function preserved for backward compatibility

Changes

  • healthchain/utils/logger.py: Added get_logger(), _configure_root_healthchain_logger(), env var support
  • healthchain/utils/__init__.py: Export get_logger
  • healthchain/__init__.py: Use get_logger instead of manual handler setup
  • 47 modules across interop/, sandbox/, gateway/, config/, pipeline/, models/, fhir/, io/: Replace import logging + logging.getLogger(__name__) with from healthchain.utils.logger import get_logger

Test plan

  • All 719 tests pass (uv run pytest)
  • Linter passes (uv run ruff check . --fix && uv run ruff format .)
  • Verified HEALTHCHAIN_LOG_LEVEL=DEBUG correctly propagates to child loggers

- Enhance healthchain/utils/logger.py with centralized get_logger()
  that configures a single handler on the root 'healthchain' logger
- Support HEALTHCHAIN_LOG_LEVEL env var (DEBUG/INFO/WARNING/ERROR/CRITICAL)
- Migrate all 50 modules from raw `import logging` + `logging.getLogger`
  to `from healthchain.utils.logger import get_logger`
- Consistent log format and color formatting inherited via propagation
- Backward-compatible: existing add_handlers() still works

Closes dotimplement#124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize logging config

2 participants