diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-22 04:58:46 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-22 04:58:46 -0800 |
commit | a5874d6912e2286fa5af5dc452e3d99ebc38c7a5 (patch) | |
tree | 77724caffc72447f6b4b0d89de643fa980bbfcfa /server/server.go | |
parent | 6ecf5e15ceda5e8535727d16a3d04e35cb7f51d0 (diff) |
server: use logger instead of stdout
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/server/server.go b/server/server.go index bca36afa..01daa23a 100644 --- a/server/server.go +++ b/server/server.go @@ -17,6 +17,7 @@ package server import ( "fmt" + log "github.com/Sirupsen/logrus" "github.com/osrg/gobgp/api" "github.com/osrg/gobgp/config" "net" @@ -67,7 +68,7 @@ func (server *BgpServer) Serve() { l, err := net.ListenTCP("tcp4", addr) if err != nil { - fmt.Println(err) + log.Fatal(err) os.Exit(1) } @@ -76,7 +77,7 @@ func (server *BgpServer) Serve() { for { conn, err := l.Accept() if err != nil { - fmt.Println(err) + log.Info(err) continue } acceptCh <- conn.(*net.TCPConn) @@ -89,33 +90,30 @@ func (server *BgpServer) Serve() { f, _ := l.File() select { case conn := <-acceptCh: - fmt.Println(conn) remoteAddr := strings.Split(conn.RemoteAddr().String(), ":")[0] peer, found := server.peerMap[remoteAddr] if found { - fmt.Println("found neighbor", remoteAddr) + log.Info("accepted a new passive connection for", remoteAddr) peer.PassConn(conn) } else { - fmt.Println("can't found neighbor", remoteAddr) + log.Info("can't find configuration for a new passive connection", remoteAddr) conn.Close() } case peer := <-server.addedPeerCh: - fmt.Println(peer) addr := peer.NeighborAddress.String() SetTcpMD5SigSockopts(int(f.Fd()), addr, peer.AuthPassword) p := NewPeer(server.bgpConfig.Global, peer, broadcastCh) server.peerMap[peer.NeighborAddress.String()] = p case peer := <-server.deletedPeerCh: - fmt.Println(peer) addr := peer.NeighborAddress.String() SetTcpMD5SigSockopts(int(f.Fd()), addr, "") p, found := server.peerMap[addr] if found { - fmt.Println("found neighbor", addr) + log.Info("Delete a peer configuration for", addr) p.Stop() delete(server.peerMap, addr) } else { - fmt.Println("can't found neighbor", addr) + log.Info("Can't delete a peer configuration for", addr) } case restReq := <-server.RestReqCh: server.handleRest(restReq) |