From bec5ad28f86dc0baaa58eaf972a727cddf1cfcdc Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Sat, 18 Apr 2020 16:19:28 -0400 Subject: [PATCH] Facilitate log level coalescence when consuming as a library Signed-off-by: Brian Dwyer --- pkg/gontlm-proxy/gontlm-proxy.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/gontlm-proxy/gontlm-proxy.go b/pkg/gontlm-proxy/gontlm-proxy.go index 402e4e8..671fbe4 100644 --- a/pkg/gontlm-proxy/gontlm-proxy.go +++ b/pkg/gontlm-proxy/gontlm-proxy.go @@ -38,8 +38,10 @@ func Run() { } setGoProxyCA() proxy := goproxy.NewProxyHttpServer() - if _, enabled := os.LookupEnv("GONTLM_PROXY_VERBOSE"); proxyVerbose || enabled { - log.SetLevel(log.DebugLevel) + if _, verbose := os.LookupEnv("GONTLM_PROXY_VERBOSE"); log.IsLevelEnabled(log.DebugLevel) || proxyVerbose || verbose { + if !log.IsLevelEnabled(log.DebugLevel) { + log.SetLevel(log.DebugLevel) + } proxy.Verbose = true } dialContext := proxyplease.NewDialContext(proxyplease.Proxy{URL: proxyUrl})