5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 21:30:39 +08:00

Add support for loglevel flag in debug builds

This commit is contained in:
Lea Anthony 2021-01-25 21:42:31 +11:00
parent 2415d4c531
commit e9d16e77a3
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405

View File

@ -2,11 +2,36 @@
package app
import (
"flag"
"github.com/wailsapp/wails/v2/pkg/logger"
"strings"
)
// Init initialises the application for a debug environment
func (a *App) Init() error {
// Indicate debug mode
a.debug = true
// Enable dev tools
a.options.DevTools = true
// Set log levels
greeting := flag.String("loglevel", "debug", "Loglevel to use - Trace, Debug, Info, Warning, Error")
flag.Parse()
if len(*greeting) > 0 {
switch strings.ToLower(*greeting) {
case "trace":
a.logger.SetLogLevel(logger.TRACE)
case "info":
a.logger.SetLogLevel(logger.INFO)
case "warning":
a.logger.SetLogLevel(logger.WARNING)
case "error":
a.logger.SetLogLevel(logger.ERROR)
default:
a.logger.SetLogLevel(logger.DEBUG)
}
}
return nil
}