5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-01 14:02:17 +08:00

fix: suppress excessive console logs after updating to v2.10.1

This commit is contained in:
dingda.li 2025-04-01 15:19:27 +08:00
parent 7245b5b4d7
commit 92a25c7dfd
2 changed files with 21 additions and 10 deletions

View File

@ -46,7 +46,12 @@ func CreateApp(appoptions *options.App) (*App, error) {
ctx = context.WithValue(ctx, "debug", true)
ctx = context.WithValue(ctx, "devtoolsEnabled", true)
// Set up logger
// Set up logger if the appoptions.LogLevel is an invalid value, set it to the default log level
appoptions.LogLevel, err = pkglogger.StringToLogLevel(appoptions.LogLevel.String())
if err != nil {
return nil, err
}
myLogger := logger.New(appoptions.Logger)
myLogger.SetLogLevel(appoptions.LogLevel)
@ -91,15 +96,8 @@ func CreateApp(appoptions *options.App) (*App, error) {
if frontendDevServerURLFlag != nil {
frontendDevServerURL = *frontendDevServerURLFlag
}
// Only override LogLevel if the flag was explicitly set
if loglevelFlag != nil && devFlags.Lookup("loglevel").Value.String() != appoptions.LogLevel.String() {
loggerLevel, err := pkglogger.StringToLogLevel(*loglevelFlag)
if err != nil {
return nil, err
}
if loggerLevel != appoptions.LogLevel {
myLogger.SetLogLevel(loggerLevel)
}
if loglevelFlag != nil {
loglevel = *loglevelFlag
}
}
@ -176,6 +174,17 @@ func CreateApp(appoptions *options.App) (*App, error) {
ctx = context.WithValue(ctx, "devserver", devServer)
}
if loglevel != "" {
level, err := pkglogger.StringToLogLevel(loglevel)
if err != nil {
return nil, err
}
// Only set the log level if it's different from the appoptions.LogLevel
if level != appoptions.LogLevel {
myLogger.SetLogLevel(level)
}
}
// Attach logger to context
ctx = context.WithValue(ctx, "logger", myLogger)
ctx = context.WithValue(ctx, "buildtype", "dev")

View File

@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added "Branding" section to `wails doctor` to correctly identify Windows 11 [#3891](https://github.com/wailsapp/wails/pull/3891) by [@ronen25](https://github.com/ronen25)
- Added `-skipembedcreate` flag to build and dev command to improve compile and recompile speed [#4143](https://github.com/wailsapp/wails/pull/4143) by @josStorer
### Fixed
- Fixed excessive console logging after updating to v2.10.1 by @superDingda in [#4111](https://github.com/wailsapp/wails/issues/4111)
## v2.10.1 - 2025-02-24