More logs cleanup
Change-Id: I5129e833d648e871a6c9719caf145f4da477ee19
diff --git a/common/logger/logger.go b/common/logger/logger.go
index cf391bf..5830e3b 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -17,8 +17,6 @@
package logger
import (
- "fmt"
-
lkh "github.com/gfremex/logrus-kafka-hook"
log "github.com/sirupsen/logrus"
)
@@ -77,25 +75,25 @@
}
func Panic(msg string, args ...interface{}) {
- myLogger.Panic(fmt.Sprintf(msg, args...))
+ myLogger.Panicf(msg, args...)
}
func Fatal(msg string, args ...interface{}) {
- myLogger.Fatal(fmt.Sprintf(msg, args...))
+ myLogger.Fatalf(msg, args...)
}
func Error(msg string, args ...interface{}) {
- myLogger.Error(fmt.Sprintf(msg, args...))
+ myLogger.Errorf(msg, args...)
}
func Warn(msg string, args ...interface{}) {
- myLogger.Warn(fmt.Sprintf(msg, args...))
+ myLogger.Warnf(msg, args...)
}
func Info(msg string, args ...interface{}) {
- myLogger.Info(fmt.Sprintf(msg, args...))
+ myLogger.Infof(msg, args...)
}
func Debug(msg string, args ...interface{}) {
- myLogger.Debug(fmt.Sprintf(msg, args...))
+ myLogger.Debugf(msg, args...)
}
diff --git a/common/utils/utils.go b/common/utils/utils.go
index f532d51..f36cae4 100644
--- a/common/utils/utils.go
+++ b/common/utils/utils.go
@@ -38,7 +38,7 @@
return logger.GetLogger()
}
- return logger.WithFields(log.Fields{
+ return logger.GetLogger().WithFields(log.Fields{
"serial_number": OnuToSn(onu),
"interfaceId": onu.IntfID,
"onuId": onu.OnuID,
diff --git a/core/core_server.go b/core/core_server.go
index 48ac9a9..964d704 100644
--- a/core/core_server.go
+++ b/core/core_server.go
@@ -359,7 +359,7 @@
continue
}
case unipkt := <-unichannel:
- logger.Debug("Received packet in grpc Server from UNI.")
+ logger.Debug("Received packet from UNI in grpc Server")
if unipkt.Info == nil || unipkt.Info.iotype != "uni" {
logger.Debug("WARNING: This packet does not come from UNI ")
continue
@@ -401,6 +401,9 @@
}).Error("Could not find onuid in CtagMap", onuid, sn, s.CtagMap)
}
} else {
+ utils.LoggerWithOnu(onu).WithFields(log.Fields{
+ "gemId": gemid,
+ }).Info("Received upstream packet is of unknow type, skipping.")
continue
}
@@ -417,9 +420,9 @@
continue
}
onuid := nnipkt.Info.onuid
- onu, _ := getOnuByID(s.Onumap, onuid)
+ onu, _ := s.GetOnuByID(onuid)
- utils.LoggerWithOnu(onu).Info("Received packet in grpc Server from NNI.")
+ utils.LoggerWithOnu(onu).Info("Received packet from NNI in grpc Server.")
intfid := nnipkt.Info.intfid
pkt := nnipkt.Pkt
utils.LoggerWithOnu(onu).Info("sendPktInd - NNI Packet")
diff --git a/core/grpc_service.go b/core/grpc_service.go
index 9cd6fae..3981aed 100644
--- a/core/grpc_service.go
+++ b/core/grpc_service.go
@@ -111,7 +111,7 @@
func (s *Server) OnuPacketOut(c context.Context, packet *openolt.OnuPacket) (*openolt.Empty, error) {
onu, _ := s.GetOnuByID(packet.OnuId)
- utils.LoggerWithOnu(onu).Debug("OLT %d receives OnuPacketOut () to IF-ID:%d ONU-ID %d.", s.Olt.ID, packet.IntfId, packet.OnuId)
+ utils.LoggerWithOnu(onu).Debugf("OLT %d receives OnuPacketOut () to IF-ID:%d ONU-ID %d.", s.Olt.ID, packet.IntfId, packet.OnuId)
onuid := packet.OnuId
intfid := packet.IntfId
rawpkt := gopacket.NewPacket(packet.Pkt, layers.LayerTypeEthernet, gopacket.Default)
diff --git a/core/tester.go b/core/tester.go
index e665aa3..4f9ccaf 100644
--- a/core/tester.go
+++ b/core/tester.go
@@ -307,15 +307,15 @@
func activateDHCPClient(univeth UniVeth, s *Server) (err error) {
onu, _ := s.GetOnuByID(univeth.OnuId)
- utils.LoggerWithOnu(onu).WithFields(log.Fields{
- "veth": univeth.Veth,
- }).Info("activateDHCPClient() start for: %s", univeth)
+
cmd := exec.Command("/usr/local/bin/dhclient", univeth.Veth)
if err := cmd.Start(); err != nil {
- logger.Error("Fail to activateDHCPClient() for: %s", univeth)
+ logger.Error("Fail to activateDHCPClient() for: %s", univeth.Veth)
logger.Panic("activateDHCPClient %s", err)
}
- logger.Debug("activateDHCPClient() done for: %s", univeth)
+ utils.LoggerWithOnu(onu).WithFields(log.Fields{
+ "veth": univeth.Veth,
+ }).Infof("activateDHCPClient() start for: %s", univeth.Veth)
return
}