[VOL-3424] Switch completely to Context based Logger instance
Change-Id: Ifc4525fc58747915b44063c2eb9ea30e7681e944
diff --git a/cmd/ofagent/main.go b/cmd/ofagent/main.go
index 1dd05fb..69443e1 100644
--- a/cmd/ofagent/main.go
+++ b/cmd/ofagent/main.go
@@ -100,12 +100,12 @@
// Setup default logger - applies for packages that do not have specific logger set
if _, err := log.SetDefaultLogger(log.JSON, logLevel, log.Fields{"instanceId": config.InstanceID}); err != nil {
- log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ logger.With(log.Fields{"error": err}).Fatal(ctx, "Cannot setup logging")
}
// Update all loggers (provisionned via init) with a common field
if err := log.UpdateAllLoggers(log.Fields{"instanceId": config.InstanceID}); err != nil {
- log.With(log.Fields{"error": err}).Fatal("Cannot setup logging")
+ logger.With(log.Fields{"error": err}).Fatal(ctx, "Cannot setup logging")
}
log.SetAllLogLevel(logLevel)
diff --git a/internal/pkg/openflow/connection.go b/internal/pkg/openflow/connection.go
index a3a3555..3908aeb 100644
--- a/internal/pkg/openflow/connection.go
+++ b/internal/pkg/openflow/connection.go
@@ -170,7 +170,7 @@
}
go func() {
if err := ofc.establishConnectionToController(ctx); err != nil {
- log.Errorw("controller-connection-failed", log.Fields{"error": err})
+ logger.Errorw(ctx, "controller-connection-failed", log.Fields{"error": err})
panic(err)
}
}()
@@ -206,19 +206,19 @@
// If the child context exists, then cancel it
if ofDone != nil {
- log.Debugw("closing-child-processes",
+ logger.Debugw(ctx, "closing-child-processes",
log.Fields{"device-id": ofc.DeviceID})
ofDone()
}
// If the connection is open, then close it
if ofc.conn != nil {
- log.Debugw("closing-of-connection",
+ logger.Debugw(ctx, "closing-of-connection",
log.Fields{"device-id": ofc.DeviceID})
ofc.conn.Close()
ofc.conn = nil
}
- log.Debugw("state-machine-finished",
+ logger.Debugw(ctx, "state-machine-finished",
log.Fields{"device-id": ofc.DeviceID})
}