Skip to content

Commit 0d93d69

Browse files
committed
IGP debug flag
1 parent 68bb834 commit 0d93d69

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

cmd/statshouse-igp/ingress_proxy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type ConfigIngressProxy struct {
5757
ResponseMemoryLimit int
5858
Version string
5959
ConfigAgent agent.Config
60+
Debug bool
6061
}
6162

6263
type ingressProxy struct {
@@ -76,6 +77,7 @@ type ingressProxy struct {
7677
// logging
7778
rareLogLast time.Time
7879
rareLogMu sync.Mutex
80+
debug bool
7981

8082
firstClientConn map[string]bool
8183
firstClientConnMu sync.Mutex
@@ -138,6 +140,7 @@ func RunIngressProxy(ctx context.Context, config ConfigIngressProxy, aesPwd stri
138140
serverKeys: config.IngressKeys,
139141
startTime: uint32(time.Now().Unix()),
140142
firstClientConn: make(map[string]bool),
143+
debug: config.Debug,
141144
}
142145
restart := make(chan int)
143146
if config.UpstreamAddr != "" {
@@ -254,6 +257,10 @@ func (p *ingressProxy) newProxyServer(network string) proxyServer {
254257
}
255258

256259
func (p *ingressProxy) rareLog(format string, args ...any) {
260+
if p.debug {
261+
log.Printf(format, args...)
262+
return
263+
}
257264
now := time.Now()
258265
p.rareLogMu.Lock()
259266
defer p.rareLogMu.Unlock()

cmd/statshouse-igp/statshouse-igp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ func parseCommandLine() error {
175175
flag.StringVar(&argv.ingressExtAddrIPv6, "ingress-external-addr-ipv6", "", "Comma-separate list of IPv6 external addresses of ingress proxies.")
176176
flag.StringVar(&argv.ingressPwdDir, "ingress-pwd-dir", "", "path to AES passwords dir for clients of ingress proxy.")
177177
flag.StringVar(&argv.UpstreamAddr, "ingress-upstream-addr", "", "Upstream server address (for debug purpose, do not use in production).")
178+
flag.BoolVar(&argv.Debug, "debug", false, "enable debug logging")
178179
argv.ConfigAgent.Bind(flag.CommandLine, agent.DefaultConfig())
179180
build.FlagParseShowVersionHelp()
180181

0 commit comments

Comments
 (0)