RSPEED-2471: Use plain log handler in non-TTY environments#1201
RSPEED-2471: Use plain log handler in non-TTY environments#1201tisnik merged 1 commit intolightspeed-core:mainfrom
Conversation
RichHandler's columnar layout falls back to 80 columns without a TTY, leaving only ~40 chars for log messages. Tracebacks become unreadable. Fall back to a plain StreamHandler when stderr is not a terminal. Signed-off-by: Major Hayden <major@redhat.com>
|
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 (2)
WalkthroughBoth files refactor logging initialization to conditionally adapt handler configuration based on TTY presence. Interactive terminals use RichHandler with simplified formatting, while non-interactive environments default to plain StreamHandler with verbose output including timestamps and line numbers. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 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)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
tisnik
left a comment
There was a problem hiding this comment.
ok, interesting bug + fix. TY
Description
RichHandler's columnar layout (timestamp, level, right-aligned filename) falls back to 80 columns when there's no TTY. The columns consume ~40 of those chars, leaving only ~35-40 for the actual log message. Tracebacks in containers become nearly unreadable.
Use
sys.stderr.isatty()to pick the handler:RichHandlerwhen a terminal is present (local dev), plainStreamHandlerwhen not (containers, CI). No behavior change for local development.Type of change
Tools used to create PR
Related Tickets & Documents
Checklist before requesting a review
Testing
Verified both code paths (TTY → RichHandler, no TTY → StreamHandler). All existing unit tests pass. All linters pass.
Summary by CodeRabbit