feat: configurable logging level with env variable#216
Conversation
📝 WalkthroughWalkthroughAdds a dedicated logging initializer exposing LOG_LEVEL, moves logging setup out of main into Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/gomodel/logging_test.go`:
- Line 31: Remove the redundant per-iteration capture statements "tt := tt" in
the test code (they are unnecessary since Go 1.22+ scopes range variables per
iteration); locate the two occurrences of the exact statement and delete them
(no other changes needed), ensuring the range loop body still references the
loop variable "tt" directly.
In `@cmd/gomodel/logging.go`:
- Around line 20-30: The duplicate godotenv.Load() call should be centralized:
remove the godotenv.Load() invocation from configureLogging and instead call
godotenv.Load() once at program startup (e.g., in main) before invoking
configureLogging and config.Load(); update code so configureLogging(w, isTTY)
only parses env vars and sets up slog without loading dotenv, and ensure main
calls godotenv.Load() once to preserve the intended ordering and avoid future
confusion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 53493441-021f-443b-8b3e-73a617bd69ac
📒 Files selected for processing (6)
.env.templateDEVELOPMENT.mdGETTING_STARTED.mdcmd/gomodel/logging.gocmd/gomodel/logging_test.gocmd/gomodel/main.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/gomodel/logging.go`:
- Line 52: Update the invalid-level error message returned (the fmt.Errorf call
that uses envLogLevel and raw) so it lists both canonical log levels and
accepted aliases (e.g., debug/dbg, info/inf, warn/warning, error/err) to avoid
confusion; modify the fmt.Errorf string that currently reads "supported values
are debug, info, warn, error" to include the alias forms alongside the canonical
names while keeping envLogLevel and raw in the formatted message.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 016dfefb-50f8-405b-b033-442d17cb29b0
📒 Files selected for processing (5)
cmd/gomodel/logging.gocmd/gomodel/logging_test.gocmd/gomodel/main.goconfig/config.gointernal/httpclient/client.go
💤 Files with no reviewable changes (1)
- config/config.go
Summary by CodeRabbit
New Features
Documentation
Tests