diff --git a/cmd/hvpn-node/hvpn-node.go b/cmd/hvpn-node/hvpn-node.go index c452528..ec2aacb 100644 --- a/cmd/hvpn-node/hvpn-node.go +++ b/cmd/hvpn-node/hvpn-node.go @@ -102,18 +102,13 @@ func createCliApp() *cli.App { Value: "INFO", EnvVars: []string{"LOG_LEVEL"}, Action: func(ctx *cli.Context, s string) error { - switch s { - case "INFO": - slog.SetLogLoggerLevel(slog.LevelInfo) - case "DEBUG": - slog.SetLogLoggerLevel(slog.LevelDebug) - case "WARN": - slog.SetLogLoggerLevel(slog.LevelWarn) - case "ERROR": - slog.SetLogLoggerLevel(slog.LevelError) - default: - return cli.Exit(fmt.Sprintf("Undefined log level: %s", s), 1) + lvl := new(slog.LevelVar) + err := lvl.UnmarshalText([]byte(s)) + if err != nil { + slog.Debug("Error on unmarshal log level flag") + return err } + slog.SetLogLoggerLevel(lvl.Level()) return nil }, }