-
Notifications
You must be signed in to change notification settings - Fork 117
feat(l1,l2): add CLI option to force color output mode #5034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new CLI flag --log.color to control ANSI color output in logs, addressing the issue where colors are disabled when TTY is not detected (e.g., in systemd environments). The flag supports three modes: auto (default, current behavior), always (force colors), and never (disable colors).
Key Changes:
- Added
LogColorenum with three variants:Auto,Always, andNever - Implemented
DisplayandFromStrtraits for theLogColorenum to support CLI parsing - Modified the tracing initialization logic to respect the new color mode setting
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/ethrex/cli.rs | Defines the LogColor enum, implements required traits, and adds the --log.color CLI option |
| cmd/ethrex/initializers.rs | Updates the tracing initialization to check the new log_color option before disabling ANSI colors |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Lines of code reportTotal lines added: Detailed view |
Motivation
Recently changes turned off ANSI colors when TTY is not detected. This is sometimes annoying (e.g., with
systemd).Description
Add a
--log.colorflag (following--log.levelformat) with optionsauto(current and default behaviour),alwaysandnever