summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bgpd.go5
-rw-r--r--server/fsm.go2
-rw-r--r--server/server.go8
3 files changed, 9 insertions, 6 deletions
diff --git a/bgpd.go b/bgpd.go
index 38e5c849..8e9effd3 100644
--- a/bgpd.go
+++ b/bgpd.go
@@ -37,6 +37,7 @@ func main() {
var opts struct {
ConfigFile string `short:"f" long:"config-file" description:"specifying a config file"`
LogLevel string `short:"l" long:"log-level" description:"specifying log level"`
+ LogJson bool `shot:"j" long:"log-json" description:"use json format for logging"`
}
_, err := flags.Parse(&opts)
if err != nil {
@@ -52,7 +53,9 @@ func main() {
log.SetLevel(log.InfoLevel)
}
log.SetOutput(os.Stderr)
- log.SetFormatter(&log.JSONFormatter{})
+ if opts.LogJson {
+ log.SetFormatter(&log.JSONFormatter{})
+ }
if opts.ConfigFile == "" {
opts.ConfigFile = "gobgpd.conf"
diff --git a/server/fsm.go b/server/fsm.go
index 9dab59e2..62c2495b 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -96,7 +96,7 @@ func (fsm *FSM) StateChanged() chan int {
}
func (fsm *FSM) StateChange(nextState int) {
- log.Debugf("Peer (%v) state changed from %v to %v", fsm.peerConfig.NeighborAddress, nextState, fsm.state)
+ log.Debugf("Peer (%v) state changed from %v to %v", fsm.peerConfig.NeighborAddress, fsm.state, nextState)
fsm.state = nextState
}
diff --git a/server/server.go b/server/server.go
index 01daa23a..f3ed0092 100644
--- a/server/server.go
+++ b/server/server.go
@@ -93,10 +93,10 @@ func (server *BgpServer) Serve() {
remoteAddr := strings.Split(conn.RemoteAddr().String(), ":")[0]
peer, found := server.peerMap[remoteAddr]
if found {
- log.Info("accepted a new passive connection for", remoteAddr)
+ log.Info("accepted a new passive connection from ", remoteAddr)
peer.PassConn(conn)
} else {
- log.Info("can't find configuration for a new passive connection", remoteAddr)
+ log.Info("can't find configuration for a new passive connection from ", remoteAddr)
conn.Close()
}
case peer := <-server.addedPeerCh:
@@ -109,11 +109,11 @@ func (server *BgpServer) Serve() {
SetTcpMD5SigSockopts(int(f.Fd()), addr, "")
p, found := server.peerMap[addr]
if found {
- log.Info("Delete a peer configuration for", addr)
+ log.Info("Delete a peer configuration for ", addr)
p.Stop()
delete(server.peerMap, addr)
} else {
- log.Info("Can't delete a peer configuration for", addr)
+ log.Info("Can't delete a peer configuration for ", addr)
}
case restReq := <-server.RestReqCh:
server.handleRest(restReq)