diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-08 15:35:18 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-08 15:35:18 +0900 |
commit | 165aea923661333ea23ba06e9b4e0035a5911db3 (patch) | |
tree | 6bb12bba5b9d98ed8bcf010cdba37840456d890e /server | |
parent | 8919e408e4a4a51c4f597c14670cedca6927da46 (diff) |
server: clean up logging messages
Use Fields.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 15 | ||||
-rw-r--r-- | server/peer.go | 13 |
2 files changed, 21 insertions, 7 deletions
diff --git a/server/fsm.go b/server/fsm.go index 8d43c6c8..62fc860e 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -16,7 +16,6 @@ package server import ( - "encoding/json" log "github.com/Sirupsen/logrus" "github.com/osrg/gobgp/config" "github.com/osrg/gobgp/packet" @@ -103,7 +102,12 @@ func NewFSM(gConfig *config.GlobalType, pConfig *config.NeighborType, connCh cha } func (fsm *FSM) StateChange(nextState bgp.FSMState) { - log.Debugf("Peer (%v) state changed from %v to %v", fsm.peerConfig.NeighborAddress, fsm.state, nextState) + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": fsm.peerConfig.NeighborAddress, + "old": fsm.state.String(), + "new": nextState.String(), + }).Debug("state changed") fsm.state = nextState } @@ -320,8 +324,11 @@ func (h *FSMHandler) sendMessageloop() error { h.errorCh <- true return nil } - j, _ := json.Marshal(m) - log.Debugf("sent %v: %s", fsm.peerConfig.NeighborAddress, string(j)) + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": fsm.peerConfig.NeighborAddress, + "data": m, + }).Debug("sent") fsm.bgpMessageStateUpdate(m.Header.Type, false) case <-fsm.keepaliveTicker.C: m := bgp.NewBGPKeepAliveMessage() diff --git a/server/peer.go b/server/peer.go index 08a52530..ee3b2311 100644 --- a/server/peer.go +++ b/server/peer.go @@ -96,8 +96,11 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, serverMsgCh chan *se } func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) { - j, _ := json.Marshal(m) - log.Debugf("received %v: %s", peer.peerConfig.NeighborAddress, j) + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": peer.peerConfig.NeighborAddress, + "data": m, + }).Debug("received") switch m.Header.Type { case bgp.BGP_MSG_OPEN: @@ -151,7 +154,11 @@ func (peer *Peer) sendMessages(msgs []*bgp.BGPMessage) { _, y := peer.capMap[bgp.BGP_CAP_FOUR_OCTET_AS_NUMBER] if !y { - log.Debug("update BGPUpdate for 2byte AS peer, ", peer.peerConfig.NeighborAddress.String()) + log.WithFields(log.Fields{ + "Topic": "Peer", + "Key": peer.peerConfig.NeighborAddress, + "data": m, + }).Debug("update for 2byte AS peer") table.UpdatePathAttrs2ByteAs(m.Body.(*bgp.BGPUpdate)) } |