fix(broker-router): honor --log-level=4 (warn) instead of defaulting to debug#1141
fix(broker-router): honor --log-level=4 (warn) instead of defaulting to debug#1141PRAteek-singHWY wants to merge 2 commits into
--log-level=4 (warn) instead of defaulting to debug#1141Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughTwo log-level mappings now cast integer values directly to ChangesLog Level Cast Simplification
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/main.go (1)
58-59:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate CLI help text to include warn mapping.
The
--log-levelhelp string omits4=warn, while the implementation now accepts raw slog levels including warn. Keep the help text aligned with runtime behavior.Suggested change
-flag.IntVar(&loglevel, "log-level", int(slog.LevelInfo), "log level: 0=info, 8=error, -4=debug") +flag.IntVar(&loglevel, "log-level", int(slog.LevelInfo), "log level: 0=info, 4=warn, 8=error, -4=debug")🤖 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 `@cmd/main.go` around lines 58 - 59, The help text for the --log-level flag in the flag.IntVar call for loglevel is missing the warn level mapping. Update the help string to include "4=warn" in the sequence of level mappings so it reads "log level: 0=info, 4=warn, 8=error, -4=debug" to accurately reflect all supported log levels that the implementation accepts.
🤖 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.
Outside diff comments:
In `@cmd/main.go`:
- Around line 58-59: The help text for the --log-level flag in the flag.IntVar
call for loglevel is missing the warn level mapping. Update the help string to
include "4=warn" in the sequence of level mappings so it reads "log level:
0=info, 4=warn, 8=error, -4=debug" to accurately reflect all supported log
levels that the implementation accepts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 72165569-b996-47f9-b3bf-9d4def8968c3
📒 Files selected for processing (3)
cmd/main.gocmd/mcp-broker-router/main.gocmd/mcp-broker-router/main_test.go
a9b1831 to
5a1f8ae
Compare
|
Hello @jasonmadigan @david-martin , could you please have a look whenever you get a chance? |
5a1f8ae to
25d63b5
Compare
14f3698 to
d909663
Compare
|
Thanks for the contribution, @PRAteek-singHWY! You currently have other non-draft PR(s) open: To help us review and merge changes as efficiently as possible, we ask contributors to focus on one PR at a time. Activity on this project can be high, and maintainers have other priorities outside the project, so having a single active PR helps everyone get changes landed faster. This PR has been moved to draft. Once your other PR(s) are merged or closed, mark this one as ready for review and we will take a look. Note This is an experimental process and may change or need manual intervention while we trial it. |
…to debug The level switch in setupLogger only handled 0, 8 and -4, so warn (4) and any other value fell through to the default case and were mapped to debug, the most verbose level. The flag value is already a raw slog.Level, so map it directly. The controller binary had the same switch; fixed there too. Adds a unit test covering the info/warn/error/debug/arbitrary mappings. Fixes Kuadrant#1143 Signed-off-by: PRAteek-singHWY <prateek23022004@gmail.com>
d909663 to
f985947
Compare
|
Hi @david-martin , this is now my only active PR (#1172 is merged) and I've rebased it on latest main. Please review whenever you're free. |
|
@PRAteek-singHWY, Nice fix👍 and I like that you went with the raw Both binaries line up now, and the |
|
Quick note on the red e2e check... looks unrelated to this change. It's |
Thank you for reviewing @Aman-Cool sir, i'll re-run it ASAp. |
f985947 to
3049dc9
Compare
The controller's --log-level help omitted 4=warn even though the level is now honored. List it so the help matches the broker-router flag and the accepted values. Signed-off-by: PRAteek-singHWY <prateek23022004@gmail.com>
3049dc9 to
9ed18e7
Compare
|
Re-ran the e2e suite and all checks are green now - the @david-martin @Aman-Cool this is ready for review whenever you have a chance. Thanks. |
|
@PRAteek-singHWY, The controller help-text follow-up closes the one loose end too ; the broker-router already advertised LGTM from me 👍 the fix is correct and about as minimal as it gets ; |
What
setupLogger()selected the slog level with a switch that only handled0(info),
8(error), and-4(debug). The--log-levelflag help advertises4=warn, but4had no case and fell through todefault, which setslog.LevelDebug. As a result, requesting warn produced the most verbose loglevel instead.
This replaces the switch with a direct conversion from the flag value to
slog.Level, so all slog levels (including warn) are honored:A unit test is added for the level mapping (
setupLoggerwas previouslyuntested).
Why
The flag value is already a raw
slog.Level(Info=0,Warn=4,Error=8,Debug=-4), so4is valid, documented input. Mapping it to debug means anoperator asking for warn gets the noisiest level instead: more log volume, more
risk of sensitive data at debug, and extra work on the broker/router hot paths.
The level is reachable in normal operation because the controller forwards
BROKER_ROUTER_LOG_LEVELto--log-level(seedocs/release-notes/0.0.8.md).Changes
cmd/mcp-broker-router/main.go: map--log-leveldirectly toslog.LevelinsetupLogger().cmd/main.go: same fix for the controller binary, which had the identicalswitch.
cmd/mcp-broker-router/main_test.go: add a test covering info/warn/error/debugand an arbitrary value.
Testing
make test-unitpasses.gofmt/goimportsclean on the changed files.Notes
Bugfix, exempt from the issue-first requirement per
CONTRIBUTING.md. Trackingissue: #1143. Commit is signed off (
git commit -s).Fixes #1143
Summary by CodeRabbit
--log-levelhelp text to document the expected numeric values.