mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 19:02:12 +08:00
Add support for production log levels (#1555)
This commit is contained in:
parent
77db50a76a
commit
f068c33dcf
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2/internal/frontend/runtime"
|
"github.com/wailsapp/wails/v2/internal/frontend/runtime"
|
||||||
"github.com/wailsapp/wails/v2/internal/logger"
|
"github.com/wailsapp/wails/v2/internal/logger"
|
||||||
"github.com/wailsapp/wails/v2/internal/menumanager"
|
"github.com/wailsapp/wails/v2/internal/menumanager"
|
||||||
pkgLog "github.com/wailsapp/wails/v2/pkg/logger"
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/options"
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,11 +60,7 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
|||||||
|
|
||||||
// Set up logger
|
// Set up logger
|
||||||
myLogger := logger.New(appoptions.Logger)
|
myLogger := logger.New(appoptions.Logger)
|
||||||
myLogger.SetLogLevel(appoptions.LogLevel)
|
myLogger.SetLogLevel(appoptions.LogLevelProduction)
|
||||||
|
|
||||||
if !IsDebug() {
|
|
||||||
myLogger.SetLogLevel(pkgLog.ERROR)
|
|
||||||
}
|
|
||||||
ctx = context.WithValue(ctx, "logger", myLogger)
|
ctx = context.WithValue(ctx, "logger", myLogger)
|
||||||
|
|
||||||
// Preflight Checks
|
// Preflight Checks
|
||||||
|
@ -11,6 +11,7 @@ var Default = &App{
|
|||||||
Height: 768,
|
Height: 768,
|
||||||
Logger: logger.NewDefaultLogger(),
|
Logger: logger.NewDefaultLogger(),
|
||||||
LogLevel: logger.INFO,
|
LogLevel: logger.INFO,
|
||||||
|
LogLevelProduction: logger.ERROR,
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultMacMenu = menu.NewMenuFromItems(
|
var defaultMacMenu = menu.NewMenuFromItems(
|
||||||
|
@ -49,6 +49,7 @@ type App struct {
|
|||||||
Menu *menu.Menu
|
Menu *menu.Menu
|
||||||
Logger logger.Logger `json:"-"`
|
Logger logger.Logger `json:"-"`
|
||||||
LogLevel logger.LogLevel
|
LogLevel logger.LogLevel
|
||||||
|
LogLevelProduction logger.LogLevel
|
||||||
OnStartup func(ctx context.Context) `json:"-"`
|
OnStartup func(ctx context.Context) `json:"-"`
|
||||||
OnDomReady func(ctx context.Context) `json:"-"`
|
OnDomReady func(ctx context.Context) `json:"-"`
|
||||||
OnShutdown func(ctx context.Context) `json:"-"`
|
OnShutdown func(ctx context.Context) `json:"-"`
|
||||||
|
@ -34,6 +34,7 @@ func main() {
|
|||||||
Menu: app.applicationMenu(),
|
Menu: app.applicationMenu(),
|
||||||
Logger: nil,
|
Logger: nil,
|
||||||
LogLevel: logger.DEBUG,
|
LogLevel: logger.DEBUG,
|
||||||
|
LogLevelProduction: logger.ERROR,
|
||||||
OnStartup: app.startup,
|
OnStartup: app.startup,
|
||||||
OnDomReady: app.domready,
|
OnDomReady: app.domready,
|
||||||
OnShutdown: app.shutdown,
|
OnShutdown: app.shutdown,
|
||||||
@ -286,6 +287,16 @@ Default: `Info` in dev mode, `Error` in production mode
|
|||||||
|
|
||||||
The default log level. More details about logging in the [Log Reference](../reference/runtime/log.mdx).
|
The default log level. More details about logging in the [Log Reference](../reference/runtime/log.mdx).
|
||||||
|
|
||||||
|
### LogLevelProduction
|
||||||
|
|
||||||
|
Name: LogLevelProduction
|
||||||
|
|
||||||
|
Type: logger.LogLevel
|
||||||
|
|
||||||
|
Default: `Error`
|
||||||
|
|
||||||
|
The default log level for production builds. More details about logging in the [Log Reference](../reference/runtime/log.mdx).
|
||||||
|
|
||||||
### OnStartup
|
### OnStartup
|
||||||
|
|
||||||
Name: OnStartup
|
Name: OnStartup
|
||||||
|
Loading…
Reference in New Issue
Block a user