mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 19:32:26 +00:00
add exception for unknown logging level
This commit is contained in:
@@ -179,6 +179,12 @@ func Init6Hook(cs *corestate.CoreState, x *app.AppX) {
|
|||||||
replaced := strings.ReplaceAll(*x.Config.Conf.Log.OutPath, "%tmp%", filepath.Clean(run_manager.RuntimeDir()))
|
replaced := strings.ReplaceAll(*x.Config.Conf.Log.OutPath, "%tmp%", filepath.Clean(run_manager.RuntimeDir()))
|
||||||
x.Config.Conf.Log.OutPath = &replaced
|
x.Config.Conf.Log.OutPath = &replaced
|
||||||
}
|
}
|
||||||
|
if !slices.Contains(logs.Levels.Available, *x.Config.Conf.Log.Level) {
|
||||||
|
if !slices.Contains(*x.Config.Conf.DisableWarnings, "--WUndefLogLevel") {
|
||||||
|
x.Log.Printf("%s: %s", logs.PrintWarn(), fmt.Sprintf("Unknown logging level %s, fallback level: %s", *x.Config.Conf.Log.Level, logs.Levels.Fallback))
|
||||||
|
}
|
||||||
|
x.Config.Conf.Log.Level = &logs.Levels.Fallback
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init7Hook(cs *corestate.CoreState, x *app.AppX) {
|
func Init7Hook(cs *corestate.CoreState, x *app.AppX) {
|
||||||
|
|||||||
@@ -16,6 +16,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var GlobalLevel slog.Level
|
var GlobalLevel slog.Level
|
||||||
|
type levelsStruct struct {
|
||||||
|
Available []string
|
||||||
|
Fallback string
|
||||||
|
}
|
||||||
|
|
||||||
|
var Levels = levelsStruct{
|
||||||
|
Available: []string{
|
||||||
|
"debug", "info",
|
||||||
|
},
|
||||||
|
Fallback: "info",
|
||||||
|
}
|
||||||
|
|
||||||
type SlogWriter struct {
|
type SlogWriter struct {
|
||||||
Logger *slog.Logger
|
Logger *slog.Logger
|
||||||
|
|||||||
Reference in New Issue
Block a user