diff --git a/pkg/log/config.go b/pkg/log/config.go index 5b9f96eab..2242a88f3 100644 --- a/pkg/log/config.go +++ b/pkg/log/config.go @@ -31,8 +31,6 @@ const ( debugEnvVar = "LOGGER_DEBUG" // logSourceEnvVar is the environment variable used to seed source logging. logSourceEnvVar = "LOGGER_LOG_SOURCE" - // configModule is our module name in the runtime configuration. - configModule = "logger" ) // srcmap tracks debugging settings for sources. diff --git a/pkg/log/klogcontrol/klogcontrol.go b/pkg/log/klogcontrol/klogcontrol.go index 3b52294ac..1765f23ef 100644 --- a/pkg/log/klogcontrol/klogcontrol.go +++ b/pkg/log/klogcontrol/klogcontrol.go @@ -18,7 +18,7 @@ import ( "errors" "flag" "fmt" - "io/ioutil" + "io" "os" "strings" @@ -69,7 +69,7 @@ func klogError(format string, args ...interface{}) error { // init discovers klog flags and sets up dynamic control for them. func init() { - ctl.SetOutput(ioutil.Discard) + ctl.SetOutput(io.Discard) klog.InitFlags(ctl.FlagSet) ctl.VisitAll(func(f *flag.Flag) { if name, value, ok := getEnvForFlag(f.Name); ok { @@ -84,7 +84,10 @@ func init() { if f.Name == "skip_headers" { if value, _ := os.LookupEnv("JOURNAL_STREAM"); value != "" { klog.Infof("Logging to journald, forcing headers off...") - ctl.Set(f.Name, "true") + err := ctl.Set(f.Name, "true") + if err != nil { + klog.Warningf("failed to set klog flag %s to true: %v", f.Name, err) + } } } } diff --git a/pkg/log/log.go b/pkg/log/log.go index 3f44e9698..ef736ec88 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -161,7 +161,10 @@ func DebugEnabled(source string) bool { func SetLevel(level Level) { log.Lock() defer log.Unlock() - log.setLevel(level) + err := log.setLevel(level) + if err != nil { + Default().Warn("failed to set log level to %v: %v", level, err) + } } // Flush flushes any pending log messages. diff --git a/pkg/log/signal.go b/pkg/log/signal.go index c7302d85d..62fb94340 100644 --- a/pkg/log/signal.go +++ b/pkg/log/signal.go @@ -35,12 +35,7 @@ func SetupDebugToggleSignal(sig os.Signal) { go func(sig <-chan os.Signal) { state := map[bool]string{false: "off", true: "on"} for { - select { - case _, ok := <-sig: - if !ok { - return - } - } + <-sig log.forced = !log.forced deflog.Warn("forced full debugging is now %s...", state[log.forced]) }