add exception for unknown logging level

This commit is contained in:
2025-07-30 20:16:49 +03:00
parent f44e89b0de
commit cfa7724b68
2 changed files with 17 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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