summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authordsp <dsp@2f30.org>2016-07-30 14:16:48 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-30 12:17:37 +0900
commitc4fe45902e736a858c4870bcab01c9143551f696 (patch)
treecbc45786d584fd98c1fb55851f2200bea938c909 /server/server.go
parentbb15c18402ffcb5beb60aa61cfdc57577633f234 (diff)
all logging is done with log.WithFields
Signed-off-by: dsp <dsp@2f30.org> Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go54
1 files changed, 41 insertions, 13 deletions
diff --git a/server/server.go b/server/server.go
index cfbe514f..889e677e 100644
--- a/server/server.go
+++ b/server/server.go
@@ -76,7 +76,10 @@ func NewTCPListener(address string, port uint32, ch chan *net.TCPConn) (*TCPList
conn, err := l.AcceptTCP()
if err != nil {
close(closeCh)
- log.Warn(err)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Error": err,
+ }).Warn("Failed to AcceptTCP")
return err
}
ch <- conn
@@ -148,11 +151,15 @@ func (server *BgpServer) Serve() {
handleFsmMsg := func(e *FsmMsg) {
peer, found := server.neighborMap[e.MsgSrc]
if !found {
- log.Warn("Can't find the neighbor ", e.MsgSrc)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Warnf("Cant't find the neighbor %s", e.MsgSrc)
return
}
if e.Version != peer.fsm.version {
- log.Debug("FSM Version inconsistent")
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debug("FSM version inconsistent")
return
}
server.handleFSMMessage(peer, e)
@@ -166,7 +173,11 @@ func (server *BgpServer) Serve() {
peer, found := server.neighborMap[remoteAddr]
if found {
if peer.fsm.adminState != ADMIN_STATE_UP {
- log.Debug("new connection for non admin-state-up peer ", remoteAddr, peer.fsm.adminState)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ "Remote Addr": remoteAddr,
+ "Admin State": peer.fsm.adminState,
+ }).Debug("New connection for non admin-state-up peer")
conn.Close()
return
}
@@ -196,10 +207,14 @@ func (server *BgpServer) Serve() {
conn.Close()
return
}
- log.Debug("accepted a new passive connection from ", remoteAddr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debugf("Accepted a new passive connection from:%s", remoteAddr)
peer.PassConn(conn)
} else {
- log.Info("can't find configuration for a new passive connection from ", remoteAddr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Infof("Can't find configuration for a new passive connection from:%s", remoteAddr)
conn.Close()
}
}
@@ -641,7 +656,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
log.WithFields(log.Fields{
"Topic": "Peer",
"Key": peer.ID(),
- }).Debugf("now syncing, suppress sending updates. start deferral timer(%d)", deferral)
+ }).Debugf("Now syncing, suppress sending updates. start deferral timer(%d)", deferral)
time.AfterFunc(time.Second*time.Duration(deferral), deferralExpiredFunc(bgp.RouteFamily(0)))
}
} else {
@@ -1567,10 +1582,14 @@ func (s *BgpServer) GetAdjRib(addr string, family bgp.RouteFamily, in bool, pref
var paths []*table.Path
if in {
paths = peer.adjRibIn.PathList([]bgp.RouteFamily{family}, false)
- log.Debugf("RouteFamily=%v adj-rib-in found : %d", family.String(), len(paths))
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debugf("RouteFamily=%v adj-rib-in found : %d", family.String(), len(paths))
} else {
paths = peer.adjRibOut.PathList([]bgp.RouteFamily{family}, false)
- log.Debugf("RouteFamily=%v adj-rib-out found : %d", family.String(), len(paths))
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Debugf("RouteFamily=%v adj-rib-out found : %d", family.String(), len(paths))
}
for i, p := range paths {
@@ -1664,7 +1683,9 @@ func (server *BgpServer) addNeighbor(c *config.Neighbor) error {
SetTcpMD5SigSockopts(l, addr, c.Config.AuthPassword)
}
}
- log.Info("Add a peer configuration for ", addr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Infof("Add a peer configuration for:%s", addr)
peer := NewPeer(&server.bgpConfig.Global, c, server.globalRib, server.policy)
server.setPolicyByConfig(peer.ID(), c.ApplyPolicy)
@@ -1716,16 +1737,23 @@ func (server *BgpServer) deleteNeighbor(c *config.Neighbor, code, subcode uint8)
for _, l := range server.Listeners(addr) {
SetTcpMD5SigSockopts(l, addr, "")
}
- log.Info("Delete a peer configuration for ", addr)
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Infof("Delete a peer configuration for:%s", addr)
n.fsm.sendNotification(code, subcode, nil, "")
go func(addr string) {
- t := time.AfterFunc(time.Minute*5, func() { log.Fatal("failed to free the fsm.h.t for ", addr) })
+ logfatal := func() {
+ log.WithFields(log.Fields{
+ "Topic": "Peer",
+ }).Fatalf("Failed to free the fsm.h.t for %s", addr)
+ }
+ t := time.AfterFunc(time.Minute*5, logfatal)
n.fsm.h.t.Kill(nil)
n.fsm.h.t.Wait()
t.Stop()
- t = time.AfterFunc(time.Minute*5, func() { log.Fatal("failed to free the fsm.h for ", addr) })
+ t = time.AfterFunc(time.Minute*5, logfatal)
n.fsm.t.Kill(nil)
n.fsm.t.Wait()
t.Stop()