Fixes #1206. ERROR level used in Production

This commit is contained in:
Lea Anthony
2022-03-04 17:46:04 +11:00
parent c7c068ade0
commit 8eae31d865
+9 -3
View File
@@ -13,6 +13,7 @@ import (
"github.com/wailsapp/wails/v2/internal/frontend/runtime"
"github.com/wailsapp/wails/v2/internal/logger"
"github.com/wailsapp/wails/v2/internal/menumanager"
pkgLog "github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
)
@@ -50,10 +51,18 @@ func CreateApp(appoptions *options.App) (*App, error) {
// Merge default options
options.MergeDefaults(appoptions)
debug := IsDebug()
ctx = context.WithValue(ctx, "debug", debug)
// Set up logger
myLogger := logger.New(appoptions.Logger)
myLogger.SetLogLevel(appoptions.LogLevel)
if !IsDebug() {
myLogger.SetLogLevel(pkgLog.ERROR)
}
ctx = context.WithValue(ctx, "logger", myLogger)
// Preflight Checks
err = PreflightChecks(appoptions, myLogger)
if err != nil {
@@ -78,11 +87,8 @@ func CreateApp(appoptions *options.App) (*App, error) {
ctx = context.WithValue(ctx, "events", eventHandler)
messageDispatcher := dispatcher.NewDispatcher(myLogger, appBindings, eventHandler)
debug := IsDebug()
ctx = context.WithValue(ctx, "debug", debug)
// Attach logger to context
if debug {
ctx = context.WithValue(ctx, "logger", myLogger)
ctx = context.WithValue(ctx, "buildtype", "debug")
} else {
ctx = context.WithValue(ctx, "buildtype", "production")