RSPEED-2477: Deduplicate logging setup across entry point, log utility, and uvicorn runner#1212
Merged
tisnik merged 3 commits intolightspeed-core:mainfrom Feb 24, 2026
Merged
Conversation
…nto log.py Add DEFAULT_LOG_FORMAT constant to constants.py and extract two public functions into log.py: resolve_log_level() for env-var-based level resolution and create_log_handler() for TTY-aware handler selection. Simplify get_logger() to delegate to these new functions while keeping its signature unchanged. Signed-off-by: Major Hayden <major@redhat.com>
Replace inline log-level resolution and handler creation in lightspeed_stack.py and runners/uvicorn.py with calls to the shared resolve_log_level() and create_log_handler() from log.py. Remove the private _resolve_log_level() from uvicorn.py and the direct RichHandler import from lightspeed_stack.py. Signed-off-by: Major Hayden <major@redhat.com>
Add parametrized tests for resolve_log_level() covering valid levels, invalid fallback, and unset default. Add tests for create_log_handler() verifying TTY returns RichHandler, non-TTY returns StreamHandler with the correct format. Update test_uvicorn_runner.py to import resolve_log_level from log instead of the deleted private _resolve_log_level from runners.uvicorn. Signed-off-by: Major Hayden <major@redhat.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
WalkthroughThe PR centralizes logging configuration by introducing utility functions in the log module and constants for log format, removing duplicated log level resolution logic from individual modules and creating a single source of truth for logging setup. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PRs #1201 and #1202 fixed TTY-aware logging in two places and log-level resolution in three places, leaving identical logic copy-pasted across
lightspeed_stack.py,log.py, andrunners/uvicorn.py.This extracts two shared functions into
log.py:resolve_log_level()— reads env var, validates, falls back to INFO (was in 3 files)create_log_handler()— TTY → RichHandler, non-TTY → StreamHandler (was in 2 files)The hardcoded format string moves to
DEFAULT_LOG_FORMATinconstants.py.get_logger()signature is unchanged — zero impact on the 72 modules that import it.lightspeed_stack.pykeeps its ownbasicConfig(force=True)call since root logger config is entry-point-specific.Type of change
Tools used to create PR
Related Tickets & Documents
Checklist before requesting a review
Testing
uv run make test-unit— 1500 tests pass (86% coverage)uv run make verify— all linters pass (black, pylint, pyright, ruff, docstyle, mypy)resolve_log_level()(parametrized levels, invalid fallback, unset default)create_log_handler()(TTY → RichHandler, non-TTY → StreamHandler, format verification)Summary by CodeRabbit
Refactor
Tests