mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:51:44 +08:00
38 lines
735 B
Go
38 lines
735 B
Go
//go:build dev
|
|
// +build dev
|
|
|
|
package app
|
|
|
|
import (
|
|
"flag"
|
|
"strings"
|
|
|
|
"github.com/wailsapp/wails/v2/pkg/logger"
|
|
)
|
|
|
|
// Init initialises the application for a debug environment
|
|
func (a *App) Init() error {
|
|
// Indicate debug mode
|
|
a.debug = true
|
|
|
|
// Set log levels
|
|
loglevel := flag.String("loglevel", "debug", "Loglevel to use - Trace, Debug, Info, Warning, Error")
|
|
flag.Parse()
|
|
if len(*loglevel) > 0 {
|
|
switch strings.ToLower(*loglevel) {
|
|
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
|
|
}
|