fix: label uvicorn logs without error tag#1296
Conversation
WalkthroughUpdated logging module name derivation in both ChangesUvicorn logger naming fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/app/logging/setup_logging.py`:
- Around line 238-246: The logging logic (notably InterceptHandler.emit and the
module_name normalization in setup_logging) is duplicated between
backend.app.logging.setup_logging and
sync-microservice.app.logging.setup_logging; extract the shared parts into a
single reusable utility module (e.g., shared_logging or common.logging) that
exposes InterceptHandler.emit behavior and any helper functions used to
normalize record.name (module_name), then update both setup_logging modules to
import and call those helpers instead of duplicating code; ensure public symbols
include InterceptHandler (or a factory that returns it) and a
normalize_module_name(record) helper so both services can replace their local
logic with imports and remain functionally identical.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: be592c1c-01bc-47bc-bf6b-e669b87221cb
📒 Files selected for processing (2)
backend/app/logging/setup_logging.pysync-microservice/app/logging/setup_logging.py
| # Get the appropriate module name. Uvicorn uses logger names such as | ||
| # ``uvicorn.error`` for regular server lifecycle messages, so avoid | ||
| # reducing those names to just ``error`` because that makes INFO logs | ||
| # look like failures in the formatted output. | ||
| module_name = record.name | ||
| if "." in module_name: | ||
| if module_name.startswith("uvicorn"): | ||
| module_name = "uvicorn" | ||
| elif "." in module_name: | ||
| module_name = module_name.split(".")[-1] |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift
Significant code duplication across backend and sync-microservice.
The InterceptHandler.emit() logic (and the entire logging setup module) is duplicated between backend/app/logging/setup_logging.py and sync-microservice/app/logging/setup_logging.py. This violates the DRY principle and creates maintenance burden—any future logging fixes would need to be applied in both places.
Consider extracting the shared logging functionality into a common utilities module that both services can import.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/app/logging/setup_logging.py` around lines 238 - 246, The logging
logic (notably InterceptHandler.emit and the module_name normalization in
setup_logging) is duplicated between backend.app.logging.setup_logging and
sync-microservice.app.logging.setup_logging; extract the shared parts into a
single reusable utility module (e.g., shared_logging or common.logging) that
exposes InterceptHandler.emit behavior and any helper functions used to
normalize record.name (module_name), then update both setup_logging modules to
import and call those helpers instead of duplicating code; ensure public symbols
include InterceptHandler (or a factory that returns it) and a
normalize_module_name(record) helper so both services can replace their local
logic with imports and remain functionally identical.
|
Everyone is required to ask for assignment before opening a respective PR. |
Summary
[uvicorn]instead of deriving[error]fromuvicorn.errorTest Plan
python3 -m py_compile backend/app/logging/setup_logging.py sync-microservice/app/logging/setup_logging.pyuvicorn.errorconfirms output contains[uvicorn]and not[error]Closes #1172
Summary by CodeRabbit
Release Notes