Make -debug a global config flag, clean up logger.Debugf() callsites
This commit is contained in:
8
main.go
8
main.go
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/posteo/go-agentx"
|
||||
|
||||
"govpp-snmp-example/config"
|
||||
"govpp-snmp-example/ifmib"
|
||||
"govpp-snmp-example/vppstats"
|
||||
)
|
||||
@ -20,6 +21,9 @@ func main() {
|
||||
debug := flag.Bool("debug", false, "Enable debug logging")
|
||||
flag.Parse()
|
||||
|
||||
// Set global debug flag
|
||||
config.Debug = *debug
|
||||
|
||||
var network, address string
|
||||
if strings.HasPrefix(*addr, "/") {
|
||||
network = "unix"
|
||||
@ -37,7 +41,7 @@ func main() {
|
||||
client.ReconnectInterval = 1 * time.Second
|
||||
|
||||
// Create the interface MIB
|
||||
interfaceMIB := ifmib.NewInterfaceMIB(*ifIndexOffset, *debug)
|
||||
interfaceMIB := ifmib.NewInterfaceMIB(*ifIndexOffset)
|
||||
|
||||
// Register the interface MIB with the AgentX client
|
||||
if err := interfaceMIB.RegisterWithClient(client); err != nil {
|
||||
@ -45,7 +49,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Start VPP stats routine with callback to update MIB
|
||||
vppstats.StartStatsRoutine(*vppStatsAddr, time.Duration(*period*1000)*time.Millisecond, interfaceMIB.UpdateStats, *debug)
|
||||
vppstats.StartStatsRoutine(*vppStatsAddr, time.Duration(*period*1000)*time.Millisecond, interfaceMIB.UpdateStats)
|
||||
|
||||
for {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
Reference in New Issue
Block a user