mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 04:59:38 +08:00
fix dev mode logging bug (#3972)
changelog.md retain env support actually fix the issue
This commit is contained in:
parent
00be6f24d2
commit
d824318a66
@ -75,7 +75,7 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||||||
|
|
||||||
loglevel := os.Getenv("loglevel")
|
loglevel := os.Getenv("loglevel")
|
||||||
if loglevel == "" {
|
if loglevel == "" {
|
||||||
loglevelFlag = devFlags.String("loglevel", "debug", "Loglevel to use - Trace, Debug, Info, Warning, Error")
|
loglevelFlag = devFlags.String("loglevel", appoptions.LogLevel.String(), "Loglevel to use - Trace, Debug, Info, Warning, Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we weren't given the assetdir in the environment variables
|
// If we weren't given the assetdir in the environment variables
|
||||||
@ -91,8 +91,15 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||||||
if frontendDevServerURLFlag != nil {
|
if frontendDevServerURLFlag != nil {
|
||||||
frontendDevServerURL = *frontendDevServerURLFlag
|
frontendDevServerURL = *frontendDevServerURLFlag
|
||||||
}
|
}
|
||||||
if loglevelFlag != nil {
|
// Only override LogLevel if the flag was explicitly set
|
||||||
loglevel = *loglevelFlag
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,14 +176,6 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||||||
ctx = context.WithValue(ctx, "devserver", devServer)
|
ctx = context.WithValue(ctx, "devserver", devServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if loglevel != "" {
|
|
||||||
level, err := pkglogger.StringToLogLevel(loglevel)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
myLogger.SetLogLevel(level)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach logger to context
|
// Attach logger to context
|
||||||
ctx = context.WithValue(ctx, "logger", myLogger)
|
ctx = context.WithValue(ctx, "logger", myLogger)
|
||||||
ctx = context.WithValue(ctx, "buildtype", "dev")
|
ctx = context.WithValue(ctx, "buildtype", "dev")
|
||||||
|
@ -41,6 +41,24 @@ func StringToLogLevel(input string) (LogLevel, error) {
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns the string representation of the LogLevel
|
||||||
|
func (l LogLevel) String() string {
|
||||||
|
switch l {
|
||||||
|
case TRACE:
|
||||||
|
return "trace"
|
||||||
|
case DEBUG:
|
||||||
|
return "debug"
|
||||||
|
case INFO:
|
||||||
|
return "info"
|
||||||
|
case WARNING:
|
||||||
|
return "warning"
|
||||||
|
case ERROR:
|
||||||
|
return "error"
|
||||||
|
default:
|
||||||
|
return "debug"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Logger specifies the methods required to attach
|
// Logger specifies the methods required to attach
|
||||||
// a logger to a Wails application
|
// a logger to a Wails application
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Added option to set window class name on Windows. Added in [PR](https://github.com/wailsapp/wails/pull/3828) by @APshenkin
|
- Added option to set window class name on Windows. Added in [PR](https://github.com/wailsapp/wails/pull/3828) by @APshenkin
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fixed dev mode logging bug by @attperac in [#3972](https://wailsapp/wails/pull/3972)
|
||||||
- Fixed `reloaddirs` wails.json config options by @atterpac in [#4005](https//github.com/wailsapp/wails/pull/4005)
|
- Fixed `reloaddirs` wails.json config options by @atterpac in [#4005](https//github.com/wailsapp/wails/pull/4005)
|
||||||
- Fixed cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying)
|
- Fixed cross compilation failed with CGO [PR](https://github.com/wailsapp/wails/pull/3795) by [@fcying](https://github.com/fcying)
|
||||||
- Using go-webview2 v0.1.17 to fix native webview2loader issue, by @leaanthony
|
- Using go-webview2 v0.1.17 to fix native webview2loader issue, by @leaanthony
|
||||||
|
Loading…
Reference in New Issue
Block a user