[VOL-4760] Log library generalization
Change-Id: I8235413276bdfa07ca6319887b80415077d2ab9d
diff --git a/internal/pkg/application/application.go b/internal/pkg/application/application.go
index 8b1e763..9476e55 100644
--- a/internal/pkg/application/application.go
+++ b/internal/pkg/application/application.go
@@ -38,7 +38,7 @@
"voltha-go-controller/internal/pkg/tasks"
"voltha-go-controller/internal/pkg/util"
errorCodes "voltha-go-controller/internal/pkg/errorcodes"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
var logger log.CLogger
@@ -47,7 +47,7 @@
func init() {
// Setup this package so that it's log level can be modified at run time
var err error
- logger, err = log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{})
+ logger, err = log.AddPackageWithDefaultParam()
if err != nil {
panic(err)
}
@@ -64,9 +64,9 @@
// List of Mac Learning Type
const (
- MacLearningNone MacLearningType = iota
- Learn
- ReLearn
+ MacLearningNone MacLearningType = iota
+ Learn
+ ReLearn
)
// MacLearningType represents Mac Learning Type
@@ -2050,7 +2050,7 @@
va.DeleteDevFlowForVlanFromDevice(vnet, vnet.PendingDeviceToDelete)
va.deleteVnetConfig(vnet)
} else {
- logger.Warn(ctx, "Vnet Delete Failed : Device Not Found", log.Fields{"Vnet": vnet.Name, "Device": vnet.PendingDeviceToDelete})
+ logger.Warnw(ctx, "Vnet Delete Failed : Device Not Found", log.Fields{"Vnet": vnet.Name, "Device": vnet.PendingDeviceToDelete})
}
}
}
diff --git a/internal/pkg/application/dhcprelay.go b/internal/pkg/application/dhcprelay.go
index 06aa3db..c57771c 100644
--- a/internal/pkg/application/dhcprelay.go
+++ b/internal/pkg/application/dhcprelay.go
@@ -27,7 +27,7 @@
cntlr "voltha-go-controller/internal/pkg/controller"
"voltha-go-controller/internal/pkg/of"
"voltha-go-controller/internal/pkg/util"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// DhcpRelayState type
@@ -509,7 +509,7 @@
logger.Debugw(ctx, "IPv6 Allocated", log.Fields{"IANA IPv6": ipv6Addr})
return ipv6Addr, leaseTime
}
- logger.Warn(ctx, "Decode of IANA Failed", log.Fields{"Reason": err.Error()})
+ logger.Warnw(ctx, "Decode of IANA Failed", log.Fields{"Reason": err.Error()})
break
}
}
@@ -532,7 +532,7 @@
logger.Debugw(ctx, "IPv6 Allocated", log.Fields{"IAPD IPv6": ipv6Addr})
break
} else {
- logger.Warn(ctx, "Decode of IAPD Failed", log.Fields{"Reason": err.Error()})
+ logger.Warnw(ctx, "Decode of IAPD Failed", log.Fields{"Reason": err.Error()})
break
}
}
diff --git a/internal/pkg/application/dhcpserverhandler.go b/internal/pkg/application/dhcpserverhandler.go
index c208910..947dd34 100644
--- a/internal/pkg/application/dhcpserverhandler.go
+++ b/internal/pkg/application/dhcpserverhandler.go
@@ -19,7 +19,7 @@
"sync"
"time"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
const (
diff --git a/internal/pkg/application/flowevent.go b/internal/pkg/application/flowevent.go
index 4fe1a0a..f6f3584 100644
--- a/internal/pkg/application/flowevent.go
+++ b/internal/pkg/application/flowevent.go
@@ -19,7 +19,7 @@
infraerrorcode "voltha-go-controller/internal/pkg/errorcodes/service"
"voltha-go-controller/internal/pkg/intf"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
//Generic Framework to enabling all flow based event trigger and handling.
diff --git a/internal/pkg/application/igmp.go b/internal/pkg/application/igmp.go
index d43283d..ba3f8fe 100644
--- a/internal/pkg/application/igmp.go
+++ b/internal/pkg/application/igmp.go
@@ -33,7 +33,7 @@
"voltha-go-controller/database"
"voltha-go-controller/internal/pkg/of"
"voltha-go-controller/internal/pkg/util"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
const (
@@ -2771,7 +2771,7 @@
}
return ig
}
- logger.Error(ctx, "GetMvlan Pro failed", log.Fields{"Group": gip})
+ logger.Errorw(ctx, "GetMvlan Pro failed", log.Fields{"Group": gip})
return nil
}
diff --git a/internal/pkg/application/major_upgrade.go b/internal/pkg/application/major_upgrade.go
index 084a554..639822b 100644
--- a/internal/pkg/application/major_upgrade.go
+++ b/internal/pkg/application/major_upgrade.go
@@ -25,7 +25,7 @@
"github.com/google/gopacket/layers"
"voltha-go-controller/database"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
const (
@@ -123,7 +123,7 @@
Migrate := new(DataMigration)
var NoDataInDB bool
err := GetMigrationInfo(Migrate)
- logger.Debug(ctx, "Migration data", log.Fields{"DataMigration": Migrate})
+ logger.Debugw(ctx, "Migration data", log.Fields{"DataMigration": Migrate})
// No DB entry represents N verison Bring Up for the First time
if err != nil {
NoDataInDB = true
@@ -136,10 +136,10 @@
Migrate.Status = MigrationComplete
Migrate.ModuleVer = database.PresentVersionMap
if err := Migrate.WriteToDb(); err != nil {
- logger.Error(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
+ logger.Errorw(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
}
//MigrateProbestatus has to be Updated to Complete when No Migration is Required
- logger.Debug(ctx, "Migration Probe Status", log.Fields{"Migration Probe": Migrate.Status})
+ logger.Debugw(ctx, "Migration Probe Status", log.Fields{"Migration Probe": Migrate.Status})
//probe.UpdateDBMigrationStatus(ctx, true)
return false
// Migration required when vgc moves to Higher Versions
@@ -173,7 +173,7 @@
}
// In case Service Reboots/Rolls Back then Probe Success to MSM
- logger.Debug(ctx, "Migration Probe Status", log.Fields{"Migration Probe": Migrate.Status})
+ logger.Debugw(ctx, "Migration Probe Status", log.Fields{"Migration Probe": Migrate.Status})
//probe.UpdateDBMigrationStatus(ctx, true)
return false
}
@@ -193,10 +193,10 @@
logger.Debug(ctx, "Started Go Routine for data migration")
err = MigrateDBData()
if err != nil {
- logger.Error(ctx, "Failed to Migrate the Data", log.Fields{"error": err})
+ logger.Errorw(ctx, "Failed to Migrate the Data", log.Fields{"error": err})
Migrate.Status = MigrationFailed
if err := Migrate.WriteToDb(); err != nil {
- logger.Error(ctx, "DB Write failed to Migration Path", log.Fields{"error": err})
+ logger.Errorw(ctx, "DB Write failed to Migration Path", log.Fields{"error": err})
}
}
logger.Debug(ctx, "Completed Go Routine for data migration")
@@ -206,17 +206,17 @@
Migrate.Status = MigrationInProgress
Migrate.ModuleVer = database.PresentVersionMap
if err = Migrate.WriteToDb(); err != nil {
- logger.Error(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
+ logger.Errorw(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
return
}
}()
// Failure Senario can be Exceptions, incase of panic Update the status as failed
defer func() {
if err := recover(); err != nil {
- logger.Error(ctx, "Migration failure due to Exception happend", log.Fields{"reason": err})
+ logger.Errorw(ctx, "Migration failure due to Exception happend", log.Fields{"reason": err})
Migrate.Status = MigrationFailed
if err := Migrate.WriteToDb(); err != nil {
- logger.Error(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
+ logger.Errorw(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
}
//probe.UpdateDBMigrationStatus(ctx, false)
return
@@ -227,9 +227,9 @@
//probe.UpdateDBMigrationStatus(ctx, true)
Migrate.Status = MigrationComplete
if err := Migrate.WriteToDb(); err != nil {
- logger.Error(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
+ logger.Errorw(ctx, "DB Write failed for Migration Path", log.Fields{"error": err})
}
- logger.Info(ctx, "Migration completed successfully", log.Fields{"Status": Migrate.Status})
+ logger.Infow(ctx, "Migration completed successfully", log.Fields{"Status": Migrate.Status})
}
// MigrateDBData to migrate database data
@@ -277,18 +277,18 @@
previousPath := database.GetModuleKeypath(module, database.PreviousVersionMap[module])
dbPathKeysValueMap, err := db.List(previousPath)
if err != nil {
- logger.Error(ctx, "failed to Fetch the Keys from Redis", log.Fields{"error": err})
+ logger.Errorw(ctx, "failed to Fetch the Keys from Redis", log.Fields{"error": err})
//No return required, Data might not be present in DB
return nil
}
if len(dbPathKeysValueMap) == 0 {
- logger.Debug(ctx, "No data present in DB for the path", log.Fields{"dbPath": module})
+ logger.Debugw(ctx, "No data present in DB for the path", log.Fields{"dbPath": module})
return nil
}
// Fetch each Path from previous version and store to present version after data migration changes
for hash, value := range dbPathKeysValueMap {
- logger.Debug(ctx, "DB path", log.Fields{"hash": hash})
+ logger.Debugw(ctx, "DB path", log.Fields{"hash": hash})
//convert the value to a specific type based on the dbPath
b, ok := value.Value.([]byte)
if !ok {
@@ -307,7 +307,7 @@
presentPath := database.GetKeyPath(module) + hash
logger.Infow(ctx, "Before writing to DB", log.Fields{"presentParams": presentParams})
if err := db.Put(presentPath, presentParams); err != nil {
- logger.Error(ctx, "Update Params failed", log.Fields{"key": presentPath, "presentparams": presentParams})
+ logger.Errorw(ctx, "Update Params failed", log.Fields{"key": presentPath, "presentparams": presentParams})
return err
}
}
@@ -323,7 +323,7 @@
err := json.Unmarshal(data, &vsmap)
if err != nil {
- logger.Warn(ctx, "Unmarshal of VPV failed", log.Fields{"error": err})
+ logger.Warnw(ctx, "Unmarshal of VPV failed", log.Fields{"error": err})
return ""
}
// changes to handle change in data type of MacLearning parameter
@@ -399,7 +399,7 @@
err := json.Unmarshal(data, &vnet)
if err != nil {
- logger.Warn(ctx, "Unmarshal of VNET failed", log.Fields{"error": err})
+ logger.Warnw(ctx, "Unmarshal of VNET failed", log.Fields{"error": err})
return ""
}
@@ -432,7 +432,7 @@
err := json.Unmarshal(data, &vpvmap)
if err != nil {
- logger.Warn(ctx, "Unmarshal of VPV failed", log.Fields{"error": err})
+ logger.Warnw(ctx, "Unmarshal of VPV failed", log.Fields{"error": err})
return ""
}
// changes to handle change in data type of MacLearning parameter
@@ -606,12 +606,12 @@
//DeleteDbPathKeys Deleted the paths from DB
func DeleteDbPathKeys(keyPath string) error {
- logger.Debug(ctx, "Deleting paths for version", log.Fields{"Path": keyPath})
+ logger.Debugw(ctx, "Deleting paths for version", log.Fields{"Path": keyPath})
// Delete all the keys
err := db.DeleteAll(keyPath)
if err != nil && err.Error() != common.ErrEntryNotFound.Error() {
- logger.Error(ctx, "Delete Key failed", log.Fields{"error": err})
+ logger.Errorw(ctx, "Delete Key failed", log.Fields{"error": err})
return err
}
return nil
diff --git a/internal/pkg/application/meters.go b/internal/pkg/application/meters.go
index 4b5fd71..cd3e724 100644
--- a/internal/pkg/application/meters.go
+++ b/internal/pkg/application/meters.go
@@ -23,7 +23,7 @@
cntlr "voltha-go-controller/internal/pkg/controller"
"voltha-go-controller/database"
"voltha-go-controller/internal/pkg/of"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// VoltShaperConfig is shaper profile configuration structure
@@ -192,7 +192,7 @@
meter.AddBand(vm.Air, 0)
}
- logger.Debug(ctx, "Total Bands are", log.Fields{"meter": *meter})
+ logger.Debugw(ctx, "Total Bands are", log.Fields{"meter": *meter})
if err := cntlr.GetController().ModMeter(port, device, of.MeterCommandAdd, meter); err != nil {
logger.Warnw(ctx, "Add meter to device Failed", log.Fields{"Id": vm.ID, "meter": *meter, "Error": err})
}
diff --git a/internal/pkg/application/minor_upgrade.go b/internal/pkg/application/minor_upgrade.go
index 8953470..d8e7094 100644
--- a/internal/pkg/application/minor_upgrade.go
+++ b/internal/pkg/application/minor_upgrade.go
@@ -24,7 +24,7 @@
"github.com/google/gopacket/layers"
"voltha-go-controller/database"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
type paramsUpdationFunc func(hash string, value interface{}) error
diff --git a/internal/pkg/application/pppoeia.go b/internal/pkg/application/pppoeia.go
index 8b5a214..7c55b79 100644
--- a/internal/pkg/application/pppoeia.go
+++ b/internal/pkg/application/pppoeia.go
@@ -27,7 +27,7 @@
cntlr "voltha-go-controller/internal/pkg/controller"
"voltha-go-controller/internal/pkg/of"
"voltha-go-controller/internal/pkg/util"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// PppoeIaState type
diff --git a/internal/pkg/application/service.go b/internal/pkg/application/service.go
index e9a7393..b9ff4b2 100644
--- a/internal/pkg/application/service.go
+++ b/internal/pkg/application/service.go
@@ -35,7 +35,7 @@
"voltha-go-controller/internal/pkg/of"
"voltha-go-controller/internal/pkg/util"
errorCodes "voltha-go-controller/internal/pkg/errorcodes"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
const (
@@ -569,7 +569,7 @@
if err := vs.setDSMatchActionVlanT0(subflow1); err != nil {
return nil, err
}
- logger.Info(ctx, "HSIA DS flows MAC Learning & MAC", log.Fields{"ML": vs.MacLearning, "Mac": vs.MacAddr})
+ logger.Infow(ctx, "HSIA DS flows MAC Learning & MAC", log.Fields{"ML": vs.MacLearning, "Mac": vs.MacAddr})
if NonZeroMacAddress(vs.MacAddr) {
subflow1.SetMatchDstMac(vs.MacAddr)
}
@@ -1065,7 +1065,7 @@
va.AddVnetToPort(vs.Port, vnet, vs)
}
} else {
- logger.Error(ctx, "VNET-does-not-exist-for-service", log.Fields{"ServiceName": cfg.Name})
+ logger.Errorw(ctx, "VNET-does-not-exist-for-service", log.Fields{"ServiceName": cfg.Name})
return errors.New("VNET doesn't exist")
}
@@ -1089,7 +1089,7 @@
}
//mmAg.AssociatedServices++
//va.UpdateMeterProf(*mmAg)
- logger.Debug(ctx, "northbound-service-add-sucessful", log.Fields{"ServiceName": vs.Name})
+ logger.Debugw(ctx, "northbound-service-add-sucessful", log.Fields{"ServiceName": vs.Name})
}
logger.Warnw(ctx, "Added Service to DB", log.Fields{"Name": vs.Name, "Port": (vs.Port), "ML": vs.MacLearning})
@@ -1208,7 +1208,7 @@
if meter.AssociatedServices > 0 {
meter.AssociatedServices--
if meter.AssociatedServices == 0 && !skipMeterDeletion {
- logger.Info(ctx, "Meter should be deleted now\n", log.Fields{"MeterID": meter})
+ logger.Infow(ctx, "Meter should be deleted now\n", log.Fields{"MeterID": meter})
va.UpdateMeterProf(*meter)
}
}
@@ -1271,7 +1271,7 @@
prevBwAvail = bwAvailInfo.PrevBw
presentBwAvail = bwAvailInfo.PresentBw
vs.BwAvailInfo = prevBwAvail + "," + presentBwAvail
- logger.Debug(ctx, "Bandwidth-value-formed", log.Fields{"BwAvailInfo": vs.BwAvailInfo})
+ logger.Debugw(ctx, "Bandwidth-value-formed", log.Fields{"BwAvailInfo": vs.BwAvailInfo})
}
vs.WriteToDb()
@@ -1495,7 +1495,7 @@
vlans = append(vlans, of.VlanType(vlan))
service := GetApplication().GetServiceFromCvlan(device, portName, vlans, uint8(pbit))
if nil != service {
- logger.Info(ctx, "Service Found for", log.Fields{"serviceName": service.Name, "portName": portName, "ctag": vlan})
+ logger.Infow(ctx, "Service Found for", log.Fields{"serviceName": service.Name, "portName": portName, "ctag": vlan})
} else {
logger.Errorw(ctx, "No Service for", log.Fields{"portName": portName, "ctag": vlan, "Pbit": pbit, "device": device, "VlanControl": vlanControl})
}
@@ -1630,7 +1630,7 @@
if vs.UsHSIAFlowsApplied {
vpv.DelTrapFlows()
vs.DelHsiaFlows()
- logger.Info(ctx, "Remove Service Flows Triggered", log.Fields{"Service": srv, "US": vs.UsHSIAFlowsApplied, "DS": vs.DsHSIAFlowsApplied})
+ logger.Infow(ctx, "Remove Service Flows Triggered", log.Fields{"Service": srv, "US": vs.UsHSIAFlowsApplied, "DS": vs.DsHSIAFlowsApplied})
} else {
vs.updateVnetProfile(msr.DeviceID)
}
@@ -1690,7 +1690,7 @@
// Removes old service and creates new VPV & service with udpated vnet profile
func (vs *VoltService) updateVnetProfile(deviceID string) {
- logger.Info(ctx, "Update Vnet Profile Triggering", log.Fields{"Service": vs.Name, "US": vs.UsHSIAFlowsApplied, "DS": vs.DsHSIAFlowsApplied})
+ logger.Infow(ctx, "Update Vnet Profile Triggering", log.Fields{"Service": vs.Name, "US": vs.UsHSIAFlowsApplied, "DS": vs.DsHSIAFlowsApplied})
nvs := VoltService{}
nvs.VoltServiceCfg = vs.VoltServiceCfg
diff --git a/internal/pkg/application/vnets.go b/internal/pkg/application/vnets.go
index 40add28..78fe54f 100644
--- a/internal/pkg/application/vnets.go
+++ b/internal/pkg/application/vnets.go
@@ -34,7 +34,7 @@
"voltha-go-controller/internal/pkg/of"
"voltha-go-controller/internal/pkg/util"
errorCodes "voltha-go-controller/internal/pkg/errorcodes"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
const (
@@ -292,7 +292,7 @@
devicesToHandle = append(devicesToHandle, serialNum)
}
if len(devicesToHandle) == 0 {
- logger.Debug(ctx, "Ignoring Duplicate VNET by name ", log.Fields{"Vnet": cfg.Name})
+ logger.Debugw(ctx, "Ignoring Duplicate VNET by name ", log.Fields{"Vnet": cfg.Name})
AppMutex.VnetMutex.Unlock()
return nil
}
@@ -687,7 +687,7 @@
// AddSvcUsMeterToDevice to add service upstream meter info to device
func AddSvcUsMeterToDevice(key, value interface{}) bool {
svc := value.(*VoltService)
- logger.Info(ctx, "Adding upstream meter profile to device", log.Fields{"ServiceName": svc.Name})
+ logger.Infow(ctx, "Adding upstream meter profile to device", log.Fields{"ServiceName": svc.Name})
if device, _ := GetApplication().GetDeviceFromPort(svc.Port); device != nil {
GetApplication().AddMeterToDevice(svc.Port, device.Name, svc.UsMeterID, 0)
return true
@@ -1076,7 +1076,7 @@
// updateIPv4AndProvisionFlows to update ipv4 and provisional flows
func (vpv *VoltPortVnet) updateIPv4AndProvisionFlows(key, value interface{}) bool {
svc := value.(*VoltService)
- logger.Info(ctx, "Updating Ipv4 address for service", log.Fields{"ServiceName": svc.Name})
+ logger.Infow(ctx, "Updating Ipv4 address for service", log.Fields{"ServiceName": svc.Name})
svc.SetIpv4Addr(vpv.Ipv4Addr)
svc.WriteToDb()
@@ -2459,7 +2459,7 @@
pushflow := func(key interface{}, value interface{}) bool {
device := value.(*VoltDevice)
if !isDeviceInList(device.SerialNum, vnet.DevicesList) {
- logger.Info(ctx, "Device not present in vnet device list", log.Fields{"Device": device.SerialNum})
+ logger.Infow(ctx, "Device not present in vnet device list", log.Fields{"Device": device.SerialNum})
return true
}
if device.State != controller.DeviceStateUP {
@@ -2721,7 +2721,7 @@
// BuildICMPv6Flow to Build DS flow for ICMPv6
func BuildICMPv6Flow(inport uint32, vnet *VoltVnet) *of.VoltFlow {
- logger.Info(ctx, "Building ICMPv6 MC Flow", log.Fields{"SVlan": vnet.SVlan, "CVlan": vnet.CVlan})
+ logger.Infow(ctx, "Building ICMPv6 MC Flow", log.Fields{"SVlan": vnet.SVlan, "CVlan": vnet.CVlan})
flow := &of.VoltFlow{}
flow.SubFlows = make(map[uint64]*of.VoltSubFlow)
subFlow := of.NewVoltSubFlow()
@@ -2750,7 +2750,7 @@
//BuildDSArpFlow Builds DS flow for ARP
func BuildDSArpFlow(inport uint32, vnet *VoltVnet) *of.VoltFlow {
- logger.Info(ctx, "Building ARP MC Flow", log.Fields{"SVlan": vnet.SVlan, "CVlan": vnet.CVlan})
+ logger.Infow(ctx, "Building ARP MC Flow", log.Fields{"SVlan": vnet.SVlan, "CVlan": vnet.CVlan})
flow := &of.VoltFlow{}
flow.SubFlows = make(map[uint64]*of.VoltSubFlow)