@@ -10,6 +10,7 @@ import (
10
10
"time"
11
11
12
12
"github.com/ethereum/go-ethereum/logger"
13
+ "github.com/ethereum/go-ethereum/logger/glog"
13
14
"github.com/ethereum/go-ethereum/p2p/discover"
14
15
"github.com/ethereum/go-ethereum/rlp"
15
16
)
@@ -34,10 +35,6 @@ const (
34
35
35
36
// Peer represents a connected remote node.
36
37
type Peer struct {
37
- // Peers have all the log methods.
38
- // Use them to display messages related to the peer.
39
- * logger.Logger
40
-
41
38
conn net.Conn
42
39
rw * conn
43
40
running map [string ]* protoRW
@@ -99,10 +96,8 @@ func (p *Peer) String() string {
99
96
}
100
97
101
98
func newPeer (fd net.Conn , conn * conn , protocols []Protocol ) * Peer {
102
- logtag := fmt .Sprintf ("Peer %.8x %v" , conn .ID [:], fd .RemoteAddr ())
103
99
protomap := matchProtocols (protocols , conn .Caps , conn )
104
100
p := & Peer {
105
- Logger : logger .NewLogger (logtag ),
106
101
conn : fd ,
107
102
rw : conn ,
108
103
running : protomap ,
@@ -130,7 +125,7 @@ func (p *Peer) run() DiscReason {
130
125
} else {
131
126
// Note: We rely on protocols to abort if there is a write
132
127
// error. It might be more robust to handle them here as well.
133
- p . DebugDetailf ( " Read error: %v\n " , err )
128
+ glog . V ( logger . Detail ). Infof ( "%v: Read error: %v\n ", p , err )
134
129
reason = DiscNetworkError
135
130
}
136
131
case err := <- p .protoErr :
@@ -141,7 +136,7 @@ func (p *Peer) run() DiscReason {
141
136
close (p .closed )
142
137
p .politeDisconnect (reason )
143
138
p .wg .Wait ()
144
- p . Debugf ( " Disconnected: %v\n " , reason )
139
+ glog . V ( logger . Debug ). Infof ( "%v: Disconnected: %v\n ", p , reason )
145
140
return reason
146
141
}
147
142
@@ -195,7 +190,7 @@ func (p *Peer) handle(msg Msg) error {
195
190
// This is the last message. We don't need to discard or
196
191
// check errors because, the connection will be closed after it.
197
192
rlp .Decode (msg .Payload , & reason )
198
- p . Debugf ( " Disconnect requested : %v\n " , reason [0 ])
193
+ glog . V ( logger . Debug ). Infof ( "%v: Disconnect Requested : %v\n ", p , reason [0 ])
199
194
return DiscRequested
200
195
case msg .Code < baseProtocolLength :
201
196
// ignore other base protocol messages
@@ -239,14 +234,14 @@ func (p *Peer) startProtocols() {
239
234
for _ , proto := range p .running {
240
235
proto := proto
241
236
proto .closed = p .closed
242
- p . DebugDetailf ( " Starting protocol %s/%d\n " , proto .Name , proto .Version )
237
+ glog . V ( logger . Detail ). Infof ( "%v: Starting protocol %s/%d\n ", p , proto .Name , proto .Version )
243
238
go func () {
244
239
err := proto .Run (p , proto )
245
240
if err == nil {
246
- p . DebugDetailf ( " Protocol %s/%d returned\n " , proto .Name , proto .Version )
241
+ glog . V ( logger . Detail ). Infof ( "%v: Protocol %s/%d returned\n ", p , proto .Name , proto .Version )
247
242
err = errors .New ("protocol returned" )
248
- } else {
249
- p . DebugDetailf ( " Protocol %s/%d error: %v \n " , proto .Name , proto .Version , err )
243
+ } else if err != io . EOF {
244
+ glog . V ( logger . Detail ). Infof ( "%v: Protocol %s/%d error: \n ", p , proto .Name , proto .Version , err )
250
245
}
251
246
p .protoErr <- err
252
247
p .wg .Done ()
0 commit comments