github.com/pingcap/br@v5.3.0-alpha.0.20220125034240-ec59c7b6ce30+incompatible/pkg/utils/env.go (about) 1 // Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. 2 3 package utils 4 5 import ( 6 "github.com/pingcap/log" 7 "go.uber.org/zap" 8 "golang.org/x/net/http/httpproxy" 9 ) 10 11 // LogEnvVariables logs related environment variables. 12 func LogEnvVariables() { 13 // log http proxy settings, it will be used in gRPC connection by default 14 fields := proxyFields() 15 if len(fields) > 0 { 16 log.Info("using proxy config", fields...) 17 } 18 } 19 20 func proxyFields() []zap.Field { 21 proxyCfg := httpproxy.FromEnvironment() 22 fields := make([]zap.Field, 0, 3) 23 if proxyCfg.HTTPProxy != "" { 24 fields = append(fields, zap.String("http_proxy", proxyCfg.HTTPProxy)) 25 } 26 if proxyCfg.HTTPSProxy != "" { 27 fields = append(fields, zap.String("https_proxy", proxyCfg.HTTPSProxy)) 28 } 29 if proxyCfg.NoProxy != "" { 30 fields = append(fields, zap.String("no_proxy", proxyCfg.NoProxy)) 31 } 32 return fields 33 }