mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2025-04-07 06:13:47 +01:00
update loglevel to str env var
This commit is contained in:
parent
16e5e9c010
commit
fd51761ab5
14
README.md
14
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
|
||||
|
||||
|
@ -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 == "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user