Logging¶
PopHealth Observatory uses a centralized package logger configured in pophealth_observatory.logging_config.
Default Behavior¶
- Logger name:
pophealth_observatory - Default level:
INFO - Format:
timestamp level=... logger=... message=... - Logger propagation to root is disabled to avoid duplicate handlers in notebooks/apps.
Set Log Level¶
Use the LOGLEVEL environment variable before running your script or app.
PowerShell¶
$env:LOGLEVEL = "DEBUG"
python -c "import pophealth_observatory as p; print(p.__version__)"
Bash¶
export LOGLEVEL=DEBUG
python -c "import pophealth_observatory as p; print(p.__version__)"
Supported levels follow Python logging names (DEBUG, INFO, WARNING, ERROR, CRITICAL).
Invalid values fall back to INFO.
Transitional Fallback Prints¶
Logging migration is complete, and internal call sites currently use log_with_fallback(...) where compatibility mirroring is still needed.
That helper logs via the package logger and mirrors messages to stdout for compatibility.
- This duplication is an intentional temporary compatibility behavior.
- Removal timeline for compatibility-related transitions is documented in
docs/versioning.md.
For your own extension code, prefer direct logger calls unless you explicitly need mirrored stdout:
import logging
logger = logging.getLogger("pophealth_observatory")
logger.info("Custom message")
Recommended Usage in Applications¶
import logging
from pophealth_observatory.logging_config import configure_logging
configure_logging() # Reads LOGLEVEL from environment if set
logger = logging.getLogger("pophealth_observatory")
logger.info("Application started")