diff --git a/cmd/q3rcon-proxy/main.go b/cmd/q3rcon-proxy/main.go index 5cc260e..cf74b7c 100644 --- a/cmd/q3rcon-proxy/main.go +++ b/cmd/q3rcon-proxy/main.go @@ -2,10 +2,12 @@ package main import ( "fmt" - "log" "os" + "strconv" "strings" + log "github.com/sirupsen/logrus" + "github.com/onyx-and-iris/q3rcon-proxy/pkg/udpproxy" ) @@ -26,9 +28,21 @@ func start(proxy string) { } var ( - proxies, host string + proxies, host, debug string ) +func getenvInt(key string) (int, error) { + s := os.Getenv(key) + if s == "" { + return 0, nil + } + v, err := strconv.Atoi(s) + if err != nil { + return 0, err + } + return v, nil +} + func init() { proxies = os.Getenv("Q3RCON_PROXY") if proxies == "" { @@ -39,6 +53,18 @@ func init() { if host == "" { host = "0.0.0.0" } + + debug, err := getenvInt("Q3RCON_DEBUG") + if err != nil { + log.Fatal(err) + } + + if debug == 1 { + log.SetLevel(log.DebugLevel) + } else { + log.SetLevel(log.InfoLevel) + } + } func main() {