diff --git a/README.md b/README.md index 39173ac..ed43de8 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,19 @@ Then just run the binary which you can compile yourself, download from `Releases ### Logging -Set the log level with environment variable `Q3RCON_LOGLEVEL`: +Set the log level with environment variable `Q3RCON_LOGLEVEL`. -`0 = Panic, 1 = Fatal, 2 = Error, 3 = Warning, 4 = Info, 5 = Debug, 6 = Trace` +Acceptable values are: + +- `trace` +- `debug` +- `info` +- `warn` +- `error` +- `fatal` +- `panic` + +If not set it will default to `info`. ### Special Thanks diff --git a/cmd/q3rcon-proxy/main.go b/cmd/q3rcon-proxy/main.go index 062c8f7..f5c4388 100644 --- a/cmd/q3rcon-proxy/main.go +++ b/cmd/q3rcon-proxy/main.go @@ -3,7 +3,6 @@ package main import ( "fmt" "os" - "slices" "strings" "time" @@ -13,13 +12,16 @@ import ( ) func main() { - logLevel, err := getEnvInt("Q3RCON_LOGLEVEL") + loglevel := os.Getenv("Q3RCON_LOGLEVEL") + if loglevel == "" { + loglevel = "info" + } + level, err := log.ParseLevel(loglevel) if err != nil { - log.Fatalf("unable to parse Q3RCON_LEVEL: %s", err.Error()) - } - if slices.Contains(log.AllLevels, log.Level(logLevel)) { - log.SetLevel(log.Level(logLevel)) + fmt.Fprintf(os.Stderr, "Invalid log level: %s\n", loglevel) + os.Exit(1) } + log.SetLevel(level) proxyHost := os.Getenv("Q3RCON_PROXY_HOST") if proxyHost == "" {