Make -debug a global config flag, clean up logger.Debugf() callsites
This commit is contained in:
@ -14,12 +14,12 @@ import (
|
||||
type StatsCallback func(*api.InterfaceStats)
|
||||
|
||||
// StartStatsRoutine starts a goroutine that queries VPP interface stats at the specified interval
|
||||
func StartStatsRoutine(statsSocketPath string, period time.Duration, callback StatsCallback, debug bool) {
|
||||
go statsRoutine(statsSocketPath, period, callback, debug)
|
||||
func StartStatsRoutine(statsSocketPath string, period time.Duration, callback StatsCallback) {
|
||||
go statsRoutine(statsSocketPath, period, callback)
|
||||
}
|
||||
|
||||
func statsRoutine(statsSocketPath string, period time.Duration, callback StatsCallback, debug bool) {
|
||||
logger.Debugf(debug, "Starting VPP stats routine with socket: %s, period: %v", statsSocketPath, period)
|
||||
func statsRoutine(statsSocketPath string, period time.Duration, callback StatsCallback) {
|
||||
logger.Debugf("Starting VPP stats routine with socket: %s, period: %v", statsSocketPath, period)
|
||||
|
||||
// Create stats client
|
||||
client := statsclient.NewStatsClient(statsSocketPath)
|
||||
@ -33,7 +33,7 @@ func statsRoutine(statsSocketPath string, period time.Duration, callback StatsCa
|
||||
defer c.Disconnect()
|
||||
|
||||
// Query stats immediately on startup
|
||||
queryInterfaceStats(c, callback, debug)
|
||||
queryInterfaceStats(c, callback)
|
||||
|
||||
ticker := time.NewTicker(period)
|
||||
defer ticker.Stop()
|
||||
@ -41,12 +41,12 @@ func statsRoutine(statsSocketPath string, period time.Duration, callback StatsCa
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
queryInterfaceStats(c, callback, debug)
|
||||
queryInterfaceStats(c, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func queryInterfaceStats(c *core.StatsConnection, callback StatsCallback, debug bool) {
|
||||
func queryInterfaceStats(c *core.StatsConnection, callback StatsCallback) {
|
||||
// Create the proper struct for interface stats
|
||||
stats := new(api.InterfaceStats)
|
||||
|
||||
@ -60,13 +60,11 @@ func queryInterfaceStats(c *core.StatsConnection, callback StatsCallback, debug
|
||||
logger.Printf("Retrieved stats for %d interfaces", len(stats.Interfaces))
|
||||
|
||||
// Debug logging for individual interfaces
|
||||
if debug {
|
||||
for _, iface := range stats.Interfaces {
|
||||
logger.Debugf(debug, "Interface %d (%s): RX %d pkts/%d bytes, TX %d pkts/%d bytes",
|
||||
iface.InterfaceIndex, iface.InterfaceName,
|
||||
iface.Rx.Packets, iface.Rx.Bytes,
|
||||
iface.Tx.Packets, iface.Tx.Bytes)
|
||||
}
|
||||
for _, iface := range stats.Interfaces {
|
||||
logger.Debugf("Interface %d (%s): RX %d pkts/%d bytes, TX %d pkts/%d bytes",
|
||||
iface.InterfaceIndex, iface.InterfaceName,
|
||||
iface.Rx.Packets, iface.Rx.Bytes,
|
||||
iface.Tx.Packets, iface.Tx.Bytes)
|
||||
}
|
||||
|
||||
// Call the callback to update the MIB
|
||||
|
Reference in New Issue
Block a user