mirror of
https://github.com/onyx-and-iris/q3rcon-proxy.git
synced 2025-04-09 15:23:45 +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
|
### 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
|
### Special Thanks
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -13,13 +12,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logLevel, err := getEnvInt("Q3RCON_LOGLEVEL")
|
loglevel := os.Getenv("Q3RCON_LOGLEVEL")
|
||||||
|
if loglevel == "" {
|
||||||
|
loglevel = "info"
|
||||||
|
}
|
||||||
|
level, err := log.ParseLevel(loglevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("unable to parse Q3RCON_LEVEL: %s", err.Error())
|
fmt.Fprintf(os.Stderr, "Invalid log level: %s\n", loglevel)
|
||||||
}
|
os.Exit(1)
|
||||||
if slices.Contains(log.AllLevels, log.Level(logLevel)) {
|
|
||||||
log.SetLevel(log.Level(logLevel))
|
|
||||||
}
|
}
|
||||||
|
log.SetLevel(level)
|
||||||
|
|
||||||
proxyHost := os.Getenv("Q3RCON_PROXY_HOST")
|
proxyHost := os.Getenv("Q3RCON_PROXY_HOST")
|
||||||
if proxyHost == "" {
|
if proxyHost == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user