diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-22 20:10:07 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 18:16:44 +0800 |
commit | d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch) | |
tree | 17c93170551d3eeabe2935de1765f157007f0dc2 /p2p/discv5/net.go | |
parent | 47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff) | |
download | dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip |
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'p2p/discv5/net.go')
-rw-r--r-- | p2p/discv5/net.go | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/p2p/discv5/net.go b/p2p/discv5/net.go index 74d485836..a39cfcc64 100644 --- a/p2p/discv5/net.go +++ b/p2p/discv5/net.go @@ -28,8 +28,7 @@ import ( "github.com/ethereum/go-ethereum/common/mclock" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/sha3" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/p2p/netutil" "github.com/ethereum/go-ethereum/rlp" @@ -437,10 +436,10 @@ loop: if err := net.handle(n, pkt.ev, &pkt); err != nil { status = err.Error() } - if glog.V(logger.Detail) { - glog.Infof("<<< (%d) %v from %x@%v: %v -> %v (%v)", + log.Trace("", "msg", log.Lazy{Fn: func() string { + return fmt.Sprintf("<<< (%d) %v from %x@%v: %v -> %v (%v)", net.tab.count, pkt.ev, pkt.remoteID[:8], pkt.remoteAddr, prestate, n.state, status) - } + }}) // TODO: persist state if n.state goes >= known, delete if it goes <= known // State transition timeouts. @@ -456,10 +455,10 @@ loop: if err := net.handle(timeout.node, timeout.ev, nil); err != nil { status = err.Error() } - if glog.V(logger.Detail) { - glog.Infof("--- (%d) %v for %x@%v: %v -> %v (%v)", + log.Trace("", "msg", log.Lazy{Fn: func() string { + return fmt.Sprintf("--- (%d) %v for %x@%v: %v -> %v (%v)", net.tab.count, timeout.ev, timeout.node.ID[:8], timeout.node.addr(), prestate, timeout.node.state, status) - } + }}) // Querying. case q := <-net.queryReq: @@ -655,7 +654,7 @@ loop: } debugLog("loop stopped") - glog.V(logger.Debug).Infof("shutting down") + log.Debug(fmt.Sprintf("shutting down")) if net.conn != nil { net.conn.Close() } @@ -685,20 +684,20 @@ func (net *Network) refresh(done chan<- struct{}) { seeds = net.nursery } if len(seeds) == 0 { - glog.V(logger.Detail).Info("no seed nodes found") + log.Trace(fmt.Sprint("no seed nodes found")) close(done) return } for _, n := range seeds { - if glog.V(logger.Debug) { + log.Debug("", "msg", log.Lazy{Fn: func() string { var age string if net.db != nil { age = time.Since(net.db.lastPong(n.ID)).String() } else { age = "unknown" } - glog.Infof("seed node (age %s): %v", age, n) - } + return fmt.Sprintf("seed node (age %s): %v", age, n) + }}) n = net.internNodeFromDB(n) if n.state == unknown { net.transition(n, verifyinit) @@ -1254,7 +1253,7 @@ func (net *Network) handleNeighboursPacket(n *Node, pkt *ingressPacket) error { for i, rn := range req.Nodes { nn, err := net.internNodeFromNeighbours(pkt.remoteAddr, rn) if err != nil { - glog.V(logger.Debug).Infof("invalid neighbour (%v) from %x@%v: %v", rn.IP, n.ID[:8], pkt.remoteAddr, err) + log.Debug(fmt.Sprintf("invalid neighbour (%v) from %x@%v: %v", rn.IP, n.ID[:8], pkt.remoteAddr, err)) continue } nodes[i] = nn |