From 8eae31d8651298bf67b99822289e070f1f3a7e0e Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Fri, 4 Mar 2022 17:46:04 +1100 Subject: [PATCH] Fixes #1206. ERROR level used in Production --- v2/internal/appng/app_production.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/v2/internal/appng/app_production.go b/v2/internal/appng/app_production.go index 07afaf9f..15467a81 100644 --- a/v2/internal/appng/app_production.go +++ b/v2/internal/appng/app_production.go @@ -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")