github.com/cilium/cilium@v1.16.2/pkg/flowdebug/flowdebug.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package flowdebug 5 6 import ( 7 "github.com/sirupsen/logrus" 8 ) 9 10 var perFlowDebug = false 11 12 // Enable enables per-flow debugging 13 func Enable() { 14 perFlowDebug = true 15 } 16 17 // Enabled reports the status of per-flow debugging 18 func Enabled() bool { 19 return perFlowDebug 20 } 21 22 // Log must be used to log any debug messages emitted per request/message/connection 23 func Log(f func() (l *logrus.Entry, msg string)) { 24 if perFlowDebug { 25 l, args := f() 26 l.Debug(args) 27 } 28 } 29 30 // Logf must be used to log any debug messages emitted per request/message/connection 31 func Logf(l *logrus.Entry, format string, args ...interface{}) { 32 if perFlowDebug { 33 l.Debugf(format, args...) 34 } 35 }