-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix dev mode logging bug #3972
fix dev mode logging bug #3972
Conversation
Warning Rate limit exceeded@leaanthony has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 11 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe pull request modifies the log level handling in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
eee294a
to
d66d074
Compare
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 (1)
website/src/pages/changelog.mdx (1)
24-24
: Improve bug fix descriptionThe bug fix entry "Fixed dev mode logging bug by @attperac in #3972" would benefit from more descriptive details about what was fixed.
-Fixed dev mode logging bug by @attperac in [#3972](https://wailsapp/wails/pull/3972) +Fixed incorrect logger configuration in dev mode where logger was being set twice, causing user-defined options to be reverted by @attperac in [#3972](https://wailsapp/wails/pull/3972)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
v2/internal/app/app_dev.go
(0 hunks)website/src/pages/changelog.mdx
(1 hunks)
💤 Files with no reviewable changes (1)
- v2/internal/app/app_dev.go
🔇 Additional comments (1)
website/src/pages/changelog.mdx (1)
Line range hint 1-24
: LGTM! Version entry follows changelog format
The latest version entry follows the established changelog format with clear sections for Added, Fixed, Changed etc. The formatting is consistent with previous entries.
🧰 Tools
🪛 LanguageTool
[duplication] ~23-~23: Possible typo: you repeated a word
Context: ...app/wails/pull/3828) by @APshenkin ### Fixed - Fixed dev mode logging bug by @attperac in [#...
(ENGLISH_WORD_REPEAT_RULE)
d66d074
to
bfb292e
Compare
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: 1
🧹 Nitpick comments (1)
v2/internal/app/app_dev.go (1)
Line range hint
52-57
: Consider explicit error handling for invalid log levelsThe code silently accepts any string value for the log level. Consider adding validation to ensure only valid log levels are accepted (Trace, Debug, Info, Warning, Error).
Example validation:
if loglevelFlag != nil { loglevel = *loglevelFlag + validLevels := map[string]bool{"trace": true, "debug": true, "info": true, "warning": true, "error": true} + if _, valid := validLevels[strings.ToLower(loglevel)]; !valid { + myLogger.Warning("Invalid log level '%s', defaulting to 'debug'", loglevel) + loglevel = "debug" + } logger.SetLogLevel(loglevel) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
v2/internal/app/app_dev.go
(1 hunks)website/src/pages/changelog.mdx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- website/src/pages/changelog.mdx
🔇 Additional comments (1)
v2/internal/app/app_dev.go (1)
94-97
: LGTM! The changes align with the PR objectives
The removal of the second logger setting and the pkglogger
dependency simplifies the code while maintaining the desired behavior in dev mode. The logger is properly initialized and configured before any logging calls.
v2/internal/app/app_dev.go
Outdated
@@ -93,6 +92,7 @@ func CreateApp(appoptions *options.App) (*App, error) { | |||
} | |||
if loglevelFlag != nil { | |||
loglevel = *loglevelFlag | |||
logger.SetLogLevel(loglevel) |
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.
💡 Codebase verification
SetLogLevel expects LogLevel type, not string
The verification reveals a type mismatch in the logger configuration:
LogLevel
is defined astype LogLevel uint8
in the logger package- The code is passing
loglevel
string directly toSetLogLevel
without conversion - Previously removed
StringToLogLevel
function was necessary for converting CLI string input to properLogLevel
type
This needs to be fixed by:
- Restoring the string-to-LogLevel conversion before calling
SetLogLevel
- Using
logger.StringToLogLevel(loglevel)
to convert the CLI input
🔗 Analysis chain
Verify logger.SetLogLevel type expectations
The removal of pkglogger.StringToLogLevel
conversion means we're passing a raw string to SetLogLevel
. We should verify that SetLogLevel
can handle string values correctly.
Let's check the logger package implementation:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check the SetLogLevel implementation to ensure it can handle string values
ast-grep --pattern 'func SetLogLevel($param) {
$$$
}'
# Also check for any string to level conversion utilities
rg -A 5 'StringToLogLevel|ParseLogLevel'
Length of output: 443
Script:
#!/bin/bash
# Let's check the SetLogLevel method signature and implementation
ast-grep --pattern 'func ($$$) SetLogLevel($param) {
$$$
}'
# Also check the type definition of LogLevel
rg -A 3 'type LogLevel'
# Let's also check the actual usage in app_dev.go
rg -B 5 -A 5 'SetLogLevel' v2/internal/app/app_dev.go
Length of output: 1150
changelog.md retain env support actually fix the issue
bfb292e
to
5175127
Compare
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)
v2/pkg/logger/logger.go (1)
44-60
: Consider providing a more explicit fallback value or error for unrecognized log levels.Currently, unrecognized log levels default to
"debug"
:default: return "debug"While this is functional, it may mask configuration errors. As a good-to-have improvement, consider returning an error or a dedicated placeholder like
"unknown"
to make debugging potential misconfigurations simpler.website/src/pages/changelog.mdx (1)
24-24
: Fix broken link for PR reference.The link for PR #3972 is missing
github.com
in the URL. Consider applying the following change:- Fixed dev mode logging bug by @attperac in [#3972](https://wailsapp/wails/pull/3972) + Fixed dev mode logging bug by @attperac in [#3972](https://github.com/wailsapp/wails/pull/3972)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
v2/internal/app/app_dev.go
(2 hunks)v2/pkg/logger/logger.go
(1 hunks)website/src/pages/changelog.mdx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- v2/internal/app/app_dev.go
The dev mode sets the logger twice, the later time checking it as a string but the options now required a
logger.Level
type to be passed in. This PR removes the second setting that was resetting to default rather then user defined in options.Summary by CodeRabbit
Documentation
go.mod
Bug Fixes
New Features