diff --git a/internal/utils/log.go b/internal/utils/log.go index 9128510e6..342d8ddca 100644 --- a/internal/utils/log.go +++ b/internal/utils/log.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "strings" "time" ) @@ -79,14 +80,14 @@ func init() { } func readLoggingEnv() { - switch os.Getenv(logEnv) { + switch strings.ToLower(os.Getenv(logEnv)) { case "": return - case "DEBUG": + case "debug": logLevel = LogLevelDebug - case "INFO": + case "info": logLevel = LogLevelInfo - case "ERROR": + case "error": logLevel = LogLevelError default: fmt.Fprintln(os.Stderr, "invalid quic-go log level, see https://github.com/lucas-clemente/quic-go/wiki/Logging") diff --git a/internal/utils/log_test.go b/internal/utils/log_test.go index 8a44c39dd..f13c31504 100644 --- a/internal/utils/log_test.go +++ b/internal/utils/log_test.go @@ -108,6 +108,12 @@ var _ = Describe("Log", func() { Expect(logLevel).To(Equal(LogLevelDebug)) }) + It("reads debug", func() { + os.Setenv(logEnv, "debug") + readLoggingEnv() + Expect(logLevel).To(Equal(LogLevelDebug)) + }) + It("reads INFO", func() { os.Setenv(logEnv, "INFO") readLoggingEnv()