Perfect! The migration is complete. The only remaining references to structlog are in documentation comments explaining the compatibility. Let me create a summary of what was accomplished:
Migration Complete!
I've successfully migrated the entire project from structlog to Python's standard library logging with rich enhancements. Here's what was done:
Changes Made:
- Core Logging Module (
src/concierge/core/logging.py): - Replaced structlog with a custom
StructuredLoggerAdapterclass - Integrated
RichHandlerfor colored output, timestamps, and enhanced formatting -
Preserved the kwargs-based API for structured logging (e.g.,
logger.info("msg", key=value)) -
Updated 15 Source Files:
- Changed all imports from
import structlogtofrom concierge.core.logging import get_logger -
Updated logger instantiation from
structlog.get_logger()toget_logger(__name__) -
Dependencies:
- Removed
structlog>=24.1.0frompyproject.toml -
Dependencies synced successfully with uv
-
Code Quality:
- ✅ Type checking passed (
ty check) - ✅ Linting passed (
ruff check) - ✅ Formatting verified (
ruff format)
Key Features Preserved:
- Structured logging: Context data can still be passed as kwargs:
logger.info("Bootstrapping Juju", provider=provider.name()) - Colored output: Rich provides better coloring than structlog
- Timestamps: Shown with rich formatting
- Exception rendering: Enhanced with rich tracebacks
- Log levels: trace→DEBUG, verbose→INFO, default→WARNING
Output Format Changes:
Before (structlog):
2025-12-13 10:15:23 [info ] Bootstrapping Juju provider=lxd
After (stdlib + rich):
10:15:23 concierge.juju.handler INFO Bootstrapping Juju [provider=lxd]
The new format includes module paths which aids in debugging, and context data is clearly separated in dimmed brackets.
All code is now using standard library logging with rich enhancements, and structlog has been completely removed from the project!