[VOL-4760] Log library generalization
Change-Id: I8235413276bdfa07ca6319887b80415077d2ab9d
diff --git a/database/database.go b/database/database.go
index 11040b0..fe88556 100644
--- a/database/database.go
+++ b/database/database.go
@@ -29,7 +29,7 @@
"voltha-go-controller/internal/pkg/of"
"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
var logger log.CLogger
@@ -83,7 +83,7 @@
// Del to delete value from database
func (db *Database) Del(fullPath string) error {
if err := db.kvc.Delete(context.Background(), fullPath); err != nil {
- logger.Errorf(ctx, "The path doesn't exist", log.Fields{"key": fullPath, "Error": err})
+ logger.Errorw(ctx, "The path doesn't exist", log.Fields{"key": fullPath, "Error": err})
return err
}
return nil
@@ -92,7 +92,7 @@
// DeleteAll to delete all value from database
func (db *Database) DeleteAll(fullPath string) error {
if err := db.kvc.DeleteWithPrefix(context.Background(), fullPath); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": fullPath, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": fullPath, "Error": err})
return err
}
return nil
@@ -101,7 +101,7 @@
// DeleteAllUnderHashKey to delete all values under hash key
func (db *Database) DeleteAllUnderHashKey(hashKeyPrefix string) error {
if err := db.kvc.Delete(context.Background(), hashKeyPrefix); err != nil {
- logger.Errorf(ctx, "The key path doesn't exist", log.Fields{"key": hashKeyPrefix, "Error": err})
+ logger.Errorw(ctx, "The key path doesn't exist", log.Fields{"key": hashKeyPrefix, "Error": err})
return err
}
return nil
@@ -137,7 +137,7 @@
func (db *Database) DelOlt(deviceID string) error {
key := fmt.Sprintf(GetKeyPath(DevicePath), deviceID)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -167,7 +167,7 @@
func (db *Database) DelFlow(deviceID string, flowID uint64) error {
key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), deviceID) + strconv.FormatUint(flowID, 10)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -198,7 +198,7 @@
func (db *Database) DelGroup(deviceID string, groupID uint32) error {
key := fmt.Sprintf(GetKeyPath(DeviceGroupPath), deviceID) + strconv.FormatUint(uint64(groupID), 10)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -208,7 +208,7 @@
func (db *Database) DelAllGroup(deviceID string) error {
key := fmt.Sprintf(GetKeyPath(DeviceGroupPath), deviceID)
if err := db.DeleteAllUnderHashKey(key); err != nil {
- logger.Warnf(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
logger.Infow(ctx, "Deleting all the groups for device", log.Fields{"device": deviceID})
@@ -219,7 +219,7 @@
func (db *Database) DelAllPorts(device string) error {
key := fmt.Sprintf(GetKeyPath(DevicePortPath), device)
if err := db.DeleteAllUnderHashKey(key); err != nil {
- logger.Warnf(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
logger.Infow(ctx, "Deleting all the ports for device", log.Fields{"device": device})
@@ -250,7 +250,7 @@
func (db *Database) DelPort(deviceID string, portID uint32) error {
key := fmt.Sprintf(GetKeyPath(DevicePortPath), deviceID) + strconv.FormatUint(uint64(portID), 10)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -280,7 +280,7 @@
func (db *Database) DelDeviceMeter(deviceID string, meterID uint32) error {
key := fmt.Sprintf(GetKeyPath(DeviceMeterPath), deviceID) + strconv.FormatUint(uint64(meterID), 10)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -310,7 +310,7 @@
func (db *Database) DelService(name string) error {
key := GetKeyPath(ServicePath) + name
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -340,7 +340,7 @@
func (db *Database) DelVnet(name string) error {
key := GetKeyPath(VnetPath) + name
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -373,7 +373,7 @@
name := port + fmt.Sprintf("-%v-%v-%v", SVlan, CVlan, UniVlan)
key := GetKeyPath(VpvPath) + name
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -406,7 +406,7 @@
name := strconv.FormatInt(int64(mvlan), 10)
key := GetKeyPath(MvlanPath) + name
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -418,7 +418,7 @@
func (db *Database) DelIGMPCfg() error {
key := GetKeyPath(IgmpConfPath)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -448,7 +448,7 @@
func (db *Database) DelIgmpProfile(name string) error {
key := GetKeyPath(IgmpProfPath) + name
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -478,7 +478,7 @@
func (db *Database) DelMcastConfig(name string) error {
key := GetKeyPath(McastConfigPath) + name
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -502,7 +502,7 @@
func (db *Database) DelHealth() error {
key := GetKeyPath(HealthPath)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -532,7 +532,7 @@
func (db *Database) DelMeter(name string) error {
key := GetKeyPath(MeterPath) + name
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -542,7 +542,7 @@
func (db *Database) DelAllMeter(device string) error {
key := GetKeyPath(DevicePath) + device + "/" + MeterPath
if err := db.DeleteAllUnderHashKey(key); err != nil {
- logger.Warnf(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
logger.Infow(ctx, "Deleting all the meters for device", log.Fields{"device": device})
@@ -573,7 +573,7 @@
func (db *Database) DelIgmpGroup(id string) error {
key := GetKeyPath(IgmpGroupPath) + id
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -615,7 +615,7 @@
func (db *Database) DelIgmpDevice(mvlan of.VlanType, gid string, gip net.IP, device string) error {
key := GetKeyPath(IgmpDevicePath) + mvlan.String() + "/" + gid + "/" + gip.String() + "/" + device
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -657,7 +657,7 @@
func (db *Database) DelIgmpChannel(mvlan of.VlanType, gName string, device string, gip net.IP) error {
key := GetKeyPath(IgmpChannelPath) + mvlan.String() + "/" + gName + "/" + device + "/" + gip.String()
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -699,7 +699,7 @@
func (db *Database) DelIgmpRcvr(mvlan of.VlanType, gip net.IP, device string, rcvr string) error {
key := GetKeyPath(IgmpPortPath) + mvlan.String() + "/" + gip.String() + "/" + device + "/" + rcvr
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -709,7 +709,7 @@
func (db *Database) DelAllIgmpRcvr(mvlan of.VlanType, gip net.IP, device string) error {
key := GetKeyPath(IgmpPortPath) + mvlan.String() + "/" + gip.String() + "/" + device + "/"
if err := db.DeleteAll(key); err != nil {
- logger.Warnf(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -721,7 +721,7 @@
logger.Infow(ctx, "Deleting all the flows for device", log.Fields{"device": device})
key := fmt.Sprintf(GetKeyPath(DeviceFlowPath), device)
if err := db.DeleteAllUnderHashKey(key); err != nil {
- logger.Warnf(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -732,7 +732,7 @@
key := GetKeyPath(NbDevicePath) + device + "/pon-port/" + fmt.Sprintf("%v", ponPortID)
if err := db.kvc.Put(context.Background(), key, value); err != nil {
- logger.Warnf(ctx, "Put Device Port failed", key)
+ logger.Warnw(ctx, "Put Device Port failed", log.Fields{"key": key})
}
}
@@ -741,7 +741,7 @@
key := GetKeyPath(NbDevicePath) + device + "/pon-port/" + fmt.Sprintf("%v", ponPortID)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "Delete Device Port failed", key)
+ logger.Warnw(ctx, "Delete Device Port failed", log.Fields{"key": key})
}
}
@@ -769,7 +769,7 @@
func (db *Database) DelMigrationInfo() error {
key := GetKeyPath(MigrationInfoPath)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -799,7 +799,7 @@
func (db *Database) DelPonCounter(device, ponID string) error {
key := GetKeyPath(PonCounterPath) + device + "/" + ponID
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -829,7 +829,7 @@
func (db *Database) DelPonChannelCounter(device, ponID, channel string) error {
key := GetKeyPath(PonCounterPath) + device + "/" + ponID + "/" + ChannelCounterPath + channel
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -845,7 +845,7 @@
func (db *Database) DelPONCounters(device string, ponID string) {
key := GetKeyPath(PonCounterPath) + device + "/" + ponID + "/"
if err := db.DeleteAll(key); err != nil {
- logger.Warnf(ctx, "Delete Pon counters failed", key)
+ logger.Warnw(ctx, "Delete Pon counters failed", log.Fields{"key": key})
}
//DeletePonCounter(device, ponID)
}
@@ -886,7 +886,7 @@
func (db *Database) DelServiceChannelCounter(serviceName, channel string) error {
key := GetKeyPath(ServiceCounterPath) + serviceName + "/" + ChannelCounterPath + channel
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -923,7 +923,7 @@
func (db *Database) PutPortAlarmProfile(portAlarmProfileID string, value string) {
key := GetKeyPath(PortAlarmProfilePath) + fmt.Sprintf("%v", portAlarmProfileID)
if err := db.kvc.Put(context.Background(), key, value); err != nil {
- logger.Warnf(ctx, "Put PortAlarmProfile failed", key)
+ logger.Warnw(ctx, "Put PortAlarmProfile failed", log.Fields{"key": key})
}
}
@@ -931,7 +931,7 @@
func (db *Database) DelPortAlarmProfile(portAlarmProfileID string) {
key := GetKeyPath(PortAlarmProfilePath) + fmt.Sprintf("%v", portAlarmProfileID)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "Delete PortAlarmProfile failed", key)
+ logger.Warnw(ctx, "Delete PortAlarmProfile failed", log.Fields{"key": key})
}
}
@@ -945,7 +945,7 @@
func (db *Database) PutPortAlarmData(deviceID string, portID uint32, value string) {
key := fmt.Sprintf(GetKeyPath(PortAlarmDataPath), deviceID) + fmt.Sprintf("%v", portID)
if err := db.kvc.Put(context.Background(), key, value); err != nil {
- logger.Warnf(ctx, "Put PortAlarmData failed", key)
+ logger.Warnw(ctx, "Put PortAlarmData failed", log.Fields{"key": key})
}
}
@@ -953,7 +953,7 @@
func (db *Database) DelPortAlarmData(deviceID string, portID uint32) {
key := fmt.Sprintf(GetKeyPath(PortAlarmDataPath), deviceID) + fmt.Sprintf("%v", portID)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "Delete PortAlarmData failed", key)
+ logger.Warnw(ctx, "Delete PortAlarmData failed", log.Fields{"key": key})
}
}
@@ -973,7 +973,7 @@
func (db *Database) PutSubAlarmData(deviceID string, portName string, value string) {
key := fmt.Sprintf(GetKeyPath(SubAlarmDataPath), deviceID) + fmt.Sprintf("%v", portName)
if err := db.kvc.Put(context.Background(), key, value); err != nil {
- logger.Warnf(ctx, "Put Subscriber AlarmData failed", key)
+ logger.Warnw(ctx, "Put Subscriber AlarmData failed", log.Fields{"key": key})
}
}
@@ -981,7 +981,7 @@
func (db *Database) DelSubAlarmData(deviceID string, portName string) {
key := fmt.Sprintf(GetKeyPath(SubAlarmDataPath), deviceID) + fmt.Sprintf("%v", portName)
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Warnf(ctx, "Delete Subscriber AlarmData failed", key)
+ logger.Warnw(ctx, "Delete Subscriber AlarmData failed", log.Fields{"key": key})
}
}
@@ -1021,7 +1021,7 @@
func (db *Database) DelMigrateServicesReq(deviceID string, vnet string) error {
key := fmt.Sprintf(GetKeyPath(ServicesMigrateReqPath), deviceID) + vnet
if err := db.kvc.Delete(context.Background(), key); err != nil {
- logger.Errorf(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Errorw(ctx, "The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
return nil
@@ -1031,7 +1031,7 @@
func (db *Database) DelAllMigrateServicesReq(deviceID string) error {
key := fmt.Sprintf(GetKeyPath(ServicesMigrateReqPath), deviceID)
if err := db.DeleteAllUnderHashKey(key); err != nil {
- logger.Warnf(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
+ logger.Warnw(ctx, "Delete All failed: The key doesn't exist", log.Fields{"key": key, "Error": err})
return err
}
logger.Infow(ctx, "Deleting all the Update Vnet Requests for device", log.Fields{"device": deviceID})
@@ -1039,10 +1039,10 @@
}
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{})
- if err != nil {
- panic(err)
- }
+ // Setup this package so that it's log level can be modified at run time
+ var err error
+ logger, err = log.AddPackageWithDefaultParam()
+ if err != nil {
+ panic(err)
+ }
}
diff --git a/go.mod b/go.mod
index 53025b3..f2704f9 100755
--- a/go.mod
+++ b/go.mod
@@ -16,7 +16,7 @@
github.com/gorilla/mux v1.8.0
github.com/guumaster/tablewriter v0.0.10
github.com/jessevdk/go-flags v1.5.0
- github.com/opencord/voltha-lib-go/v7 v7.2.0
+ github.com/opencord/voltha-lib-go/v7 v7.2.1
github.com/opencord/voltha-protos/v5 v5.2.4
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/stretchr/testify v1.7.1 // indirect
diff --git a/go.sum b/go.sum
index 43c76e2..e1d6bf7 100644
--- a/go.sum
+++ b/go.sum
@@ -193,8 +193,8 @@
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
-github.com/opencord/voltha-lib-go/v7 v7.2.0 h1:BkSq/3eaRCPUjoESNcy4qAW6xUu1noOtFxa/nt8Zui8=
-github.com/opencord/voltha-lib-go/v7 v7.2.0/go.mod h1:+X6jdL5SauRC4YkUBxO5H1oinZvxqTP7gzE1keE6wN8=
+github.com/opencord/voltha-lib-go/v7 v7.2.1 h1:dPXWLFHfAuiNkimGkLQ6ChXBwPdpG9dup8ZW7wopJ90=
+github.com/opencord/voltha-lib-go/v7 v7.2.1/go.mod h1:+X6jdL5SauRC4YkUBxO5H1oinZvxqTP7gzE1keE6wN8=
github.com/opencord/voltha-protos/v5 v5.2.2/go.mod h1:ZGcyW79kQKIo7AySo1LRu613E6uiozixrCF0yNB/4x8=
github.com/opencord/voltha-protos/v5 v5.2.4 h1:gokXh1SAGH/fkpQGl6taMmLXYlK+jUkQs/61h8Icl98=
github.com/opencord/voltha-protos/v5 v5.2.4/go.mod h1:ZGcyW79kQKIo7AySo1LRu613E6uiozixrCF0yNB/4x8=
diff --git a/infra/pprofcontroller/profile.go b/infra/pprofcontroller/profile.go
index 514971e..d8e3a97 100644
--- a/infra/pprofcontroller/profile.go
+++ b/infra/pprofcontroller/profile.go
@@ -22,20 +22,20 @@
// using for init
_ "net/http/pprof"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
- "context"
+ "voltha-go-controller/log"
+ "context"
)
var logger log.CLogger
var ctx = context.TODO()
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{})
- if err != nil {
- panic(err)
- }
+ // 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{})
+ if err != nil {
+ panic(err)
+ }
logger.Error(ctx, "Profiling is ENABLED")
go func() {
err := http.ListenAndServe("0.0.0.0:6060", nil)
diff --git a/infra/pprofcontroller/release.go b/infra/pprofcontroller/release.go
index 933081c..f6f08d1 100644
--- a/infra/pprofcontroller/release.go
+++ b/infra/pprofcontroller/release.go
@@ -19,7 +19,7 @@
import (
"github.com/opencord/voltha-lib-go/v7/pkg/log"
- "context"
+ "context"
)
var logger log.CLogger
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)
diff --git a/internal/pkg/controller/addflows.go b/internal/pkg/controller/addflows.go
index 0364341..0d6c27a 100644
--- a/internal/pkg/controller/addflows.go
+++ b/internal/pkg/controller/addflows.go
@@ -22,7 +22,7 @@
"time"
"voltha-go-controller/internal/pkg/of"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
const (
diff --git a/internal/pkg/controller/auditdevice.go b/internal/pkg/controller/auditdevice.go
index ea00185..2cabffc 100644
--- a/internal/pkg/controller/auditdevice.go
+++ b/internal/pkg/controller/auditdevice.go
@@ -20,7 +20,7 @@
"time"
"voltha-go-controller/internal/pkg/tasks"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"github.com/opencord/voltha-protos/v5/go/common"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
)
diff --git a/internal/pkg/controller/audittables.go b/internal/pkg/controller/audittables.go
index 486d560..1afad05 100644
--- a/internal/pkg/controller/audittables.go
+++ b/internal/pkg/controller/audittables.go
@@ -24,7 +24,7 @@
"voltha-go-controller/internal/pkg/of"
"voltha-go-controller/internal/pkg/tasks"
"voltha-go-controller/internal/pkg/util"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"github.com/opencord/voltha-protos/v5/go/common"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
"github.com/opencord/voltha-protos/v5/go/voltha"
@@ -306,7 +306,7 @@
var present bool
if flow.FlowMod != nil {
if dbFlow, present = att.device.GetFlow(flow.FlowMod.Cookie); !present {
- logger.Warn(ctx, "Flow Removed from DB. Ignoring Add Missing Flow", log.Fields{"Device": att.device.ID, "Cookie": flow.FlowMod.Cookie})
+ logger.Warnw(ctx, "Flow Removed from DB. Ignoring Add Missing Flow", log.Fields{"Device": att.device.ID, "Cookie": flow.FlowMod.Cookie})
continue
}
}
@@ -332,7 +332,7 @@
for _, flow := range flows {
if _, present := att.device.GetFlow(flow.Cookie); present {
- logger.Warn(ctx, "Flow Present in DB. Ignoring Delete Excess Flow", log.Fields{"Device": att.device.ID, "Cookie": flow.Cookie})
+ logger.Warnw(ctx, "Flow Present in DB. Ignoring Delete Excess Flow", log.Fields{"Device": att.device.ID, "Cookie": flow.Cookie})
continue
}
diff --git a/internal/pkg/controller/changeevent.go b/internal/pkg/controller/changeevent.go
index 95f6b07..21ed05d 100644
--- a/internal/pkg/controller/changeevent.go
+++ b/internal/pkg/controller/changeevent.go
@@ -20,7 +20,7 @@
"errors"
"time"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
)
diff --git a/internal/pkg/controller/controller.go b/internal/pkg/controller/controller.go
index ae34133..9abbd42 100644
--- a/internal/pkg/controller/controller.go
+++ b/internal/pkg/controller/controller.go
@@ -31,7 +31,7 @@
"voltha-go-controller/internal/pkg/util"
"voltha-go-controller/internal/pkg/vpagent"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
var logger log.CLogger
@@ -40,7 +40,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)
}
diff --git a/internal/pkg/controller/controllertasks.go b/internal/pkg/controller/controllertasks.go
index bd06ffb..50a51ee 100644
--- a/internal/pkg/controller/controllertasks.go
+++ b/internal/pkg/controller/controllertasks.go
@@ -22,7 +22,7 @@
"voltha-go-controller/internal/pkg/intf"
"voltha-go-controller/internal/pkg/vpagent"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// AddDeviceTask structure
diff --git a/internal/pkg/controller/device.go b/internal/pkg/controller/device.go
index aa7bd2c..cea6960 100644
--- a/internal/pkg/controller/device.go
+++ b/internal/pkg/controller/device.go
@@ -31,7 +31,7 @@
//"voltha-go-controller/internal/pkg/vpagent"
"voltha-go-controller/internal/pkg/tasks"
"voltha-go-controller/internal/pkg/util"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
"github.com/opencord/voltha-protos/v5/go/voltha"
)
diff --git a/internal/pkg/controller/modgroup.go b/internal/pkg/controller/modgroup.go
index 49da920..e51a347 100644
--- a/internal/pkg/controller/modgroup.go
+++ b/internal/pkg/controller/modgroup.go
@@ -23,7 +23,7 @@
infraerrorcode "voltha-go-controller/internal/pkg/errorcodes/service"
"voltha-go-controller/internal/pkg/of"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"google.golang.org/grpc/codes"
)
diff --git a/internal/pkg/controller/modmeter.go b/internal/pkg/controller/modmeter.go
index 04b1e04..b5ce86c 100644
--- a/internal/pkg/controller/modmeter.go
+++ b/internal/pkg/controller/modmeter.go
@@ -20,7 +20,7 @@
"time"
"voltha-go-controller/internal/pkg/of"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// ModMeterTask structure
@@ -82,7 +82,7 @@
// log.Fields{"meterId": mmt.meter.ID, "meterOp": mmt.command, "Status": statusCode, "errorReason": statusMsg})
// go mmt.device.AddMeterToDb(mmt.meter)
// } else {
- // log.Infow("Meter Mod Result", log.Fields{"meterID": mmt.meter.ID, "Error Code": statusCode})
+ // logger.Infow("Meter Mod Result", log.Fields{"meterID": mmt.meter.ID, "Error Code": statusCode})
// }
// }
diff --git a/internal/pkg/controller/pendingprofiles.go b/internal/pkg/controller/pendingprofiles.go
index 6258f36..a97cdfa 100644
--- a/internal/pkg/controller/pendingprofiles.go
+++ b/internal/pkg/controller/pendingprofiles.go
@@ -19,7 +19,7 @@
"context"
"time"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// PendingProfilesTask structure
diff --git a/internal/pkg/of/flows.go b/internal/pkg/of/flows.go
index 2cc84ac..ff44754 100644
--- a/internal/pkg/of/flows.go
+++ b/internal/pkg/of/flows.go
@@ -23,7 +23,7 @@
"github.com/google/gopacket/layers"
"github.com/opencord/voltha-lib-go/v7/pkg/flows"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
//"github.com/opencord/voltha-protos/v5/go/voltha"
)
@@ -40,7 +40,6 @@
)
var logger log.CLogger
-
var ctx = context.TODO()
// ----------------------------------------------------------
@@ -1009,7 +1008,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)
}
diff --git a/internal/pkg/of/group.go b/internal/pkg/of/group.go
index 0a5863a..39a9a6d 100644
--- a/internal/pkg/of/group.go
+++ b/internal/pkg/of/group.go
@@ -16,7 +16,7 @@
package of
import (
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
// "github.com/opencord/voltha-protos/v5/go/voltha"
)
diff --git a/internal/pkg/of/meter.go b/internal/pkg/of/meter.go
index dc3be2f..625b1a7 100644
--- a/internal/pkg/of/meter.go
+++ b/internal/pkg/of/meter.go
@@ -16,7 +16,7 @@
package of
import (
- // "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ // "voltha-go-controller/log"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
// "github.com/opencord/voltha-protos/v5/go/voltha"
)
diff --git a/internal/pkg/tasks/tasks.go b/internal/pkg/tasks/tasks.go
index 414c4f2..34c4c2e 100644
--- a/internal/pkg/tasks/tasks.go
+++ b/internal/pkg/tasks/tasks.go
@@ -21,7 +21,7 @@
"sync"
"time"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
var logger log.CLogger
@@ -79,7 +79,7 @@
// Start to start the task
func (ts *TaskSet) Start(ctx context.Context, taskID uint8) error {
- logger.Debug(ctx, "Starting Execution TaskSet", log.Fields{"SetName": ts.name})
+ logger.Debugw(ctx, "Starting Execution TaskSet", log.Fields{"SetName": ts.name})
ts.taskID = taskID
for len(ts.queued) != 0 {
task := ts.queued[0]
@@ -302,7 +302,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)
}
diff --git a/internal/pkg/vpagent/changeEvent.go b/internal/pkg/vpagent/changeEvent.go
index 3d86675..9300671 100644
--- a/internal/pkg/vpagent/changeEvent.go
+++ b/internal/pkg/vpagent/changeEvent.go
@@ -20,7 +20,7 @@
"io"
"github.com/golang/protobuf/ptypes/empty"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"google.golang.org/grpc"
)
diff --git a/internal/pkg/vpagent/common.go b/internal/pkg/vpagent/common.go
index d32e0a6..5b62368 100644
--- a/internal/pkg/vpagent/common.go
+++ b/internal/pkg/vpagent/common.go
@@ -20,20 +20,10 @@
"context"
"strings"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
-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{})
- if err != nil {
- panic(err)
- }
-}
-
// IsConnCanceled returns true, if error is from a closed gRPC connection.
// ref. https://github.com/grpc/grpc-go/pull/1854
func isConnCanceled(err error) bool {
diff --git a/internal/pkg/vpagent/connection.go b/internal/pkg/vpagent/connection.go
index 607f7f3..9e93ae2 100644
--- a/internal/pkg/vpagent/connection.go
+++ b/internal/pkg/vpagent/connection.go
@@ -21,7 +21,7 @@
"time"
"github.com/golang/protobuf/ptypes/empty"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"github.com/opencord/voltha-lib-go/v7/pkg/probe"
"github.com/opencord/voltha-protos/v5/go/voltha"
"google.golang.org/grpc"
diff --git a/internal/pkg/vpagent/packetIn.go b/internal/pkg/vpagent/packetIn.go
index 4a2f7c3..81f6ff2 100644
--- a/internal/pkg/vpagent/packetIn.go
+++ b/internal/pkg/vpagent/packetIn.go
@@ -20,7 +20,7 @@
"io"
"github.com/golang/protobuf/ptypes/empty"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"google.golang.org/grpc"
)
diff --git a/internal/pkg/vpagent/packetOut.go b/internal/pkg/vpagent/packetOut.go
index 501bdea..ac9fa8b 100644
--- a/internal/pkg/vpagent/packetOut.go
+++ b/internal/pkg/vpagent/packetOut.go
@@ -18,7 +18,7 @@
import (
"context"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"google.golang.org/grpc"
)
@@ -47,9 +47,7 @@
case <-ctx.Done():
break top
case ofPacketOut := <-vpa.packetOutChannel:
- if logger.V(log.DebugLevel) {
- logger.Debug(ctx, "streamPacketOut Receive PacketOut from Channel")
- }
+ logger.Debug(ctx, "streamPacketOut Receive PacketOut from Channel")
if err := outClient.Send(ofPacketOut); err != nil {
logger.Errorw(ctx, "packet-out-send-error",
log.Fields{"error": err.Error()})
diff --git a/internal/pkg/vpagent/refresh.go b/internal/pkg/vpagent/refresh.go
index c06e5cd..83792d0 100644
--- a/internal/pkg/vpagent/refresh.go
+++ b/internal/pkg/vpagent/refresh.go
@@ -22,7 +22,7 @@
"voltha-go-controller/internal/pkg/intf"
"github.com/golang/protobuf/ptypes/empty"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"github.com/opencord/voltha-protos/v5/go/voltha"
)
diff --git a/internal/pkg/vpagent/volthaprotoagent.go b/internal/pkg/vpagent/volthaprotoagent.go
index 04e3d08..6a3dcd4 100644
--- a/internal/pkg/vpagent/volthaprotoagent.go
+++ b/internal/pkg/vpagent/volthaprotoagent.go
@@ -24,7 +24,7 @@
"voltha-go-controller/internal/pkg/holder"
"voltha-go-controller/internal/pkg/intf"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"github.com/opencord/voltha-lib-go/v7/pkg/probe"
ofp "github.com/opencord/voltha-protos/v5/go/openflow_13"
"github.com/opencord/voltha-protos/v5/go/voltha"
@@ -37,7 +37,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)
}
diff --git a/log/log.go b/log/log.go
new file mode 100644
index 0000000..60757d7
--- /dev/null
+++ b/log/log.go
@@ -0,0 +1,169 @@
+/*
+* Copyright 2022-present Open Networking Foundation
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+
+package log
+
+import (
+ "context"
+
+ "github.com/opencord/voltha-lib-go/v7/pkg/log"
+)
+
+const skipLevel = 2
+
+//Fields - struct to update log params
+type Fields log.Fields
+
+//CLogger - CLogger wrapper
+type CLogger struct {
+ clogger log.CLogger
+}
+
+type LogLevel int8
+
+// constants defining the Log Level
+const (
+ // DebugLevel logs a message at debug level
+ DebugLevel = iota
+ // InfoLevel logs a message at info level
+ InfoLevel
+ // WarnLevel logs a message at warning level
+ WarnLevel
+ // ErrorLevel logs a message at error level
+ ErrorLevel
+ // FatalLevel logs a message, then calls os.Exit(1).
+ FatalLevel
+)
+
+// AddPackageWithDefaultParam registers a package to the log map with default params
+func AddPackageWithDefaultParam() (CLogger, error) {
+ var cLogger CLogger
+ _, err := log.RegisterPackage(log.JSON, log.ErrorLevel, log.Fields{})
+ if err == nil {
+ cLogger.clogger, _ = log.UpdateCallerSkipLevel(skipLevel)
+ }
+ return cLogger, err
+}
+
+// AddPackage registers a package to the log map
+func AddPackage(level int) (*CLogger, error) {
+ var cLogger *CLogger
+ logger, err := log.RegisterPackage(log.JSON, log.LogLevel(level), log.Fields{})
+ if err == nil {
+ cLogger = &CLogger{
+ clogger: logger,
+ }
+ }
+ return cLogger, err
+}
+
+//StringToLogLevel - converts the log level from string to defined uint8
+func StringToLogLevel(l string) (LogLevel, error) {
+ ll, err := log.StringToLogLevel(l)
+ if err != nil {
+ return 0, err
+ }
+ return LogLevel(ll), nil
+}
+
+// With initializes logger with the key-value pairs
+func (cl CLogger) With(ctx context.Context, keysAndValues Fields, msg string) {
+ cl.clogger.With(log.Fields(keysAndValues)).Fatal(ctx, msg)
+}
+
+// SetAllLogLevel sets the log level of all registered packages to level
+func SetAllLogLevel(level int) {
+ log.SetAllLogLevel(log.LogLevel(level))
+}
+
+// SetDefaultLogLevel sets the log level used for packages that don't have specific loggers
+func SetDefaultLogLevel(level int) {
+ log.SetDefaultLogLevel(log.LogLevel(level))
+}
+
+// UpdateAllLoggers create new loggers for all registered pacakges with the defaultFields.
+func UpdateAllLoggers(defaultFields Fields) error {
+ _ = log.UpdateAllLoggers(log.Fields(defaultFields))
+ return log.UpdateAllCallerSkipLevel(skipLevel)
+}
+
+// SetDefaultLogger needs to be invoked before the logger API can be invoked. This function
+// initialize the default logger (zap's sugaredlogger)
+func SetDefaultLogger(ctx context.Context, level int, defaultFields Fields) error {
+ _, err := log.SetDefaultLogger(log.JSON, log.LogLevel(level), log.Fields(defaultFields))
+ return err
+}
+
+// CleanUp flushed any buffered log entries. Applications should take care to call
+// CleanUp before exiting.
+func CleanUp() error {
+ return log.CleanUp()
+}
+
+// Fatal logs a message at level Fatal on the standard logger.
+func (cl CLogger) Fatal(ctx context.Context, args string) {
+ cl.clogger.Fatal(ctx, args)
+}
+
+// Fatalw logs a message with some additional context. The variadic key-value
+// pairs are treated as they are in With.
+func (cl CLogger) Fatalw(ctx context.Context, msg string, keysAndValues Fields) {
+ cl.clogger.Fatalw(ctx, msg, log.Fields(keysAndValues))
+
+}
+
+// Error logs a message at level Error on the standard logger.
+func (cl CLogger) Error(ctx context.Context, args string) {
+ cl.clogger.Error(ctx, args)
+}
+
+// Errorw logs a message with some additional context. The variadic key-value
+// pairs are treated as they are in With.
+func (cl CLogger) Errorw(ctx context.Context, msg string, keysAndValues Fields) {
+ cl.clogger.Errorw(ctx, msg, log.Fields(keysAndValues))
+}
+
+// Warn logs a message at level Warn on the standard logger.
+func (cl CLogger) Warn(ctx context.Context, args string) {
+ cl.clogger.Warn(ctx, args)
+}
+
+// Warnw logs a message with some additional context. The variadic key-value
+// pairs are treated as they are in With.
+func (cl CLogger) Warnw(ctx context.Context, msg string, keysAndValues Fields) {
+ cl.clogger.Warnw(ctx, msg, log.Fields(keysAndValues))
+}
+
+// Info logs a message at level Info on the standard logger.
+func (cl CLogger) Info(ctx context.Context, args string) {
+ cl.clogger.Info(ctx, args)
+}
+
+// Infow logs a message with some additional context. The variadic key-value
+// pairs are treated as they are in With.
+func (cl CLogger) Infow(ctx context.Context, msg string, keysAndValues Fields) {
+ cl.clogger.Infow(ctx, msg, log.Fields(keysAndValues))
+}
+
+// Debug logs a message at level Debug on the standard logger.
+func (cl CLogger) Debug(ctx context.Context, args string) {
+ cl.clogger.Debug(ctx, args)
+}
+
+// Debugw logs a message with some additional context. The variadic key-value
+// pairs are treated as they are in With.
+func (cl CLogger) Debugw(ctx context.Context, msg string, keysAndValues Fields) {
+ cl.clogger.Debugw(ctx, msg, log.Fields(keysAndValues))
+}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go
index 7b1a123..6810fe1 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v7/pkg/log/log.go
@@ -660,3 +660,39 @@
func (l clogger) GetLogLevel() LogLevel {
return levelToLogLevel(cfgs[l.packageName].Level.Level())
}
+
+//UpdateCallerSkipLevel create new loggers for specified registered pacakges with the default updated caller skipltFields.
+//This will enable to skip wrapper file caller in caller info and stacktrace
+func UpdateCallerSkipLevel(skipLevel int) (CLogger, error) {
+ pkgName, _, _, _ := getCallerInfo()
+ if cfg, exist := cfgs[pkgName]; exist {
+ l, err := cfg.Build(zp.AddCallerSkip(skipLevel))
+ if err != nil {
+ return loggers[pkgName], err
+ }
+
+ // Update the existing zap logger instance
+ loggers[pkgName].log = l.Sugar()
+ loggers[pkgName].parent = l
+
+ return loggers[pkgName], nil
+ }
+
+ return loggers[pkgName], errors.New("Package Not Found")
+}
+
+//UpdateAllCallerSkipLevel create new loggers for all registered pacakges with the default updated caller skipltFields.
+//This will enable to skip wrapper file caller in caller info and stacktrace
+func UpdateAllCallerSkipLevel(skipLevel int) error {
+ for pkgName, cfg := range cfgs {
+ l, err := cfg.Build(zp.AddCallerSkip(skipLevel))
+ if err != nil {
+ return err
+ }
+
+ // Update the existing zap logger instance
+ loggers[pkgName].log = l.Sugar()
+ loggers[pkgName].parent = l
+ }
+ return nil
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 809e2e5..fd94487 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -65,7 +65,7 @@
github.com/jessevdk/go-flags
# github.com/mattn/go-runewidth v0.0.10
github.com/mattn/go-runewidth
-# github.com/opencord/voltha-lib-go/v7 v7.2.0
+# github.com/opencord/voltha-lib-go/v7 v7.2.1
## explicit
github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore
github.com/opencord/voltha-lib-go/v7/pkg/flows
diff --git a/voltha-go-controller/common.go b/voltha-go-controller/common.go
index d171ce9..28ca348 100644
--- a/voltha-go-controller/common.go
+++ b/voltha-go-controller/common.go
@@ -34,7 +34,7 @@
import (
"context"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
var logger log.CLogger
@@ -43,8 +43,9 @@
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)
}
}
+
diff --git a/voltha-go-controller/main.go b/voltha-go-controller/main.go
index a09f077..59424e7 100644
--- a/voltha-go-controller/main.go
+++ b/voltha-go-controller/main.go
@@ -34,7 +34,7 @@
"voltha-go-controller/voltha-go-controller/nbi"
"github.com/opencord/voltha-lib-go/v7/pkg/db/kvstore"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
"github.com/opencord/voltha-lib-go/v7/pkg/probe"
)
@@ -126,14 +126,15 @@
if logLevel, err = log.StringToLogLevel(config.LogLevel); err != nil {
logLevel = log.DebugLevel
}
- if _, err = log.SetDefaultLogger(log.JSON, logLevel, log.Fields{"instanceId": config.InstanceID}); err != nil {
- logger.With(log.Fields{"error": err}).Fatal(ctx, "Cannot setup logging")
- }
+ if err := log.SetDefaultLogger(ctx, int(logLevel), log.Fields{"instanceId": config.InstanceID}); err != nil {
+ logger.With(ctx, log.Fields{"error": err}, "Cannot setup logging")
+ }
+
// Update all loggers (provisionned via init) with a common field
if err := log.UpdateAllLoggers(log.Fields{"instanceId": config.InstanceID}); err != nil {
- logger.With(log.Fields{"error": err}).Fatal(ctx, "Cannot setup logging")
+ logger.With(ctx, log.Fields{"error": err}, "Cannot setup logging")
}
- log.SetAllLogLevel(logLevel)
+ log.SetAllLogLevel(int(logLevel))
if vgcInfo.kvClient, err = newKVClient(config.KVStoreType, config.KVStoreEndPoint, config.KVStoreTimeout); err != nil {
logger.Errorw(ctx, "KVClient Establishment Failure", log.Fields{"Reason": err})
@@ -161,10 +162,10 @@
logger.Info(ctx, "KV-store-reachable")
//Read if log-level is stored in DB
if logLevel, err := dbHandler.Get(db.GetKeyPath(db.LogLevelPath)); err == nil {
- logger.Info(ctx, "Read log-level from db", log.Fields{"logLevel": logLevel})
+ logger.Infow(ctx, "Read log-level from db", log.Fields{"logLevel": logLevel})
storedLogLevel, _ := log.StringToLogLevel(logLevel)
- log.SetAllLogLevel(storedLogLevel)
- log.SetDefaultLogLevel(storedLogLevel)
+ log.SetAllLogLevel(int(storedLogLevel))
+ log.SetDefaultLogLevel(int(storedLogLevel))
}
// Check if Data Migration is required
diff --git a/voltha-go-controller/nbi/device_info.go b/voltha-go-controller/nbi/device_info.go
index 7234a0b..ea7b866 100644
--- a/voltha-go-controller/nbi/device_info.go
+++ b/voltha-go-controller/nbi/device_info.go
@@ -21,7 +21,7 @@
"github.com/gorilla/mux"
app "voltha-go-controller/internal/pkg/application"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// DeviceInfoHandle Handle DeviceInfo Requests
diff --git a/voltha-go-controller/nbi/dhcp_session.go b/voltha-go-controller/nbi/dhcp_session.go
index 0fdd327..f29b141 100644
--- a/voltha-go-controller/nbi/dhcp_session.go
+++ b/voltha-go-controller/nbi/dhcp_session.go
@@ -24,7 +24,7 @@
"github.com/gorilla/mux"
app "voltha-go-controller/internal/pkg/application"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
//DHCPSessionInfoHandle handle dhcp session Requests
diff --git a/voltha-go-controller/nbi/flow_hash.go b/voltha-go-controller/nbi/flow_hash.go
index 77cf83c..a3a6115 100644
--- a/voltha-go-controller/nbi/flow_hash.go
+++ b/voltha-go-controller/nbi/flow_hash.go
@@ -23,7 +23,7 @@
"github.com/gorilla/mux"
cntlr "voltha-go-controller/internal/pkg/controller"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// FlowHashHandle Handle flowhash Requests
diff --git a/voltha-go-controller/nbi/get_device_id_list.go b/voltha-go-controller/nbi/get_device_id_list.go
index 6b5c59f..89a4a99 100644
--- a/voltha-go-controller/nbi/get_device_id_list.go
+++ b/voltha-go-controller/nbi/get_device_id_list.go
@@ -20,7 +20,7 @@
"net/http"
app "voltha-go-controller/internal/pkg/application"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// DeviceIDListHandle Handle DeviceIDList Requests
diff --git a/voltha-go-controller/nbi/rest.go b/voltha-go-controller/nbi/rest.go
index f6fcf11..77e4b71 100644
--- a/voltha-go-controller/nbi/rest.go
+++ b/voltha-go-controller/nbi/rest.go
@@ -21,7 +21,7 @@
"github.com/gorilla/mux"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
var logger log.CLogger
@@ -42,8 +42,9 @@
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)
}
}
+
diff --git a/voltha-go-controller/nbi/sadisbwprofile.go b/voltha-go-controller/nbi/sadisbwprofile.go
index 8d2a06c..d0f404b 100644
--- a/voltha-go-controller/nbi/sadisbwprofile.go
+++ b/voltha-go-controller/nbi/sadisbwprofile.go
@@ -21,7 +21,7 @@
"net/http"
app "voltha-go-controller/internal/pkg/application"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
//BWProfile - Sadis BW Profile
diff --git a/voltha-go-controller/nbi/sadisigmpproxy.go b/voltha-go-controller/nbi/sadisigmpproxy.go
index 6ac8b2c..6c8f27d 100644
--- a/voltha-go-controller/nbi/sadisigmpproxy.go
+++ b/voltha-go-controller/nbi/sadisigmpproxy.go
@@ -24,7 +24,7 @@
app "voltha-go-controller/internal/pkg/application"
"voltha-go-controller/internal/pkg/of"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// IgmpProxy - configurations
diff --git a/voltha-go-controller/nbi/sadismvlan.go b/voltha-go-controller/nbi/sadismvlan.go
index 8840adc..28fa1d5 100644
--- a/voltha-go-controller/nbi/sadismvlan.go
+++ b/voltha-go-controller/nbi/sadismvlan.go
@@ -24,7 +24,7 @@
app "voltha-go-controller/internal/pkg/application"
"voltha-go-controller/internal/pkg/types"
"voltha-go-controller/internal/pkg/of"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// McastConfig structure
type McastConfig struct {
@@ -126,7 +126,7 @@
if err := app.GetApplication().AddMvlanProfile(config.Name, config.Mvlan, config.PonVlan, config.Groups,
config.IsChannelBasedGroup, config.OLTSerialNum,
255, config.Proxy); err != nil {
- logger.Error(ctx, "northbound-add-mvlan-failed", log.Fields{"mvlan": config.Name, "Reason": err.Error()})
+ logger.Errorw(ctx, "northbound-add-mvlan-failed", log.Fields{"mvlan": config.Name, "Reason": err.Error()})
http.Error(w, err.Error(), http.StatusConflict)
return
}
diff --git a/voltha-go-controller/nbi/sadissubscriber.go b/voltha-go-controller/nbi/sadissubscriber.go
index bc4dbd6..86d9b2b 100644
--- a/voltha-go-controller/nbi/sadissubscriber.go
+++ b/voltha-go-controller/nbi/sadissubscriber.go
@@ -27,7 +27,7 @@
"voltha-go-controller/internal/pkg/application"
app "voltha-go-controller/internal/pkg/application"
"voltha-go-controller/internal/pkg/of"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
//SubscriberDeviceInfo - Subcriber Device Info
diff --git a/voltha-go-controller/nbi/task_list.go b/voltha-go-controller/nbi/task_list.go
index 82799ff..1821a54 100644
--- a/voltha-go-controller/nbi/task_list.go
+++ b/voltha-go-controller/nbi/task_list.go
@@ -21,7 +21,7 @@
"github.com/gorilla/mux"
app "voltha-go-controller/internal/pkg/application"
- "github.com/opencord/voltha-lib-go/v7/pkg/log"
+ "voltha-go-controller/log"
)
// TaskListHandle handle TaskList Requests