-
Notifications
You must be signed in to change notification settings - Fork 559
ensure info message is logged #1987
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
WalkthroughThe Changes
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
PR Summary
Enhanced logging level consistency in cli/pkg/usage/usage.go
by differentiating between success and error cases in the ReportErrorAndExit function.
- Modified
ReportErrorAndExit
to useslog.Info
for exitCode=0 (success) andslog.Error
for non-zero codes (errors) - Potential function naming inconsistency as
ReportErrorAndExit
now handles both success and error cases
1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
cli/pkg/usage/usage.go (2)
115-120
: Consider structured, DRY logging and include exit code as an attributeThe conditional branching achieves the desired severity switch, but we now have two almost-identical calls that differ only by level.
You can eliminate this duplication and get richer telemetry by logging the exit code as an attribute:- if exitCode == 0 { - slog.Info(message) - } else { - slog.Error(message) - } + l := slog.Info + if exitCode != 0 { + l = slog.Error + } + l("cli exit", "msg", message, "exitCode", exitCode)This keeps the code DRY, makes the log record trivially machine-queryable, and surfaces the numeric exit code without having to parse the free-text message.
115-120
: Function name no longer reflects behaviour whenexitCode == 0
With the new branch, the function is now a general “log-and-exit” helper, not strictly an error reporter.
If callers are expected to invoke it for successful termination, renaming (e.g.,
ReportAndExit
) or documenting the new semantics would avoid confusion for future readers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cli/pkg/usage/usage.go
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
Summary by CodeRabbit