Merge pull request #851 from lucas-clemente/lowercase-log-level

accept lower case log levels for the QUIC_GO_LOG_LEVEL flag
This commit is contained in:
Marten Seemann
2017-09-28 15:35:43 +07:00
committed by GitHub
2 changed files with 11 additions and 4 deletions

View File

@@ -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")

View File

@@ -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()