p2p: remove trailing newlines from log messages

This commit is contained in:
Péter Szilágyi 2017-02-20 19:41:54 +02:00
parent b9d48b4a93
commit 189dee26c6
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D
5 changed files with 19 additions and 19 deletions

View File

@ -296,7 +296,7 @@ func (t *dialTask) resolve(srv *Server) bool {
// dial performs the actual connection attempt. // dial performs the actual connection attempt.
func (t *dialTask) dial(srv *Server, dest *discover.Node) bool { func (t *dialTask) dial(srv *Server, dest *discover.Node) bool {
addr := &net.TCPAddr{IP: dest.IP, Port: int(dest.TCP)} addr := &net.TCPAddr{IP: dest.IP, Port: int(dest.TCP)}
glog.V(logger.Debug).Infof("dial tcp %v (%x)\n", addr, dest.ID[:6]) glog.V(logger.Debug).Infof("dial tcp %v (%x)", addr, dest.ID[:6])
fd, err := srv.Dialer.Dial("tcp", addr.String()) fd, err := srv.Dialer.Dial("tcp", addr.String())
if err != nil { if err != nil {
glog.V(logger.Detail).Infof("%v", err) glog.V(logger.Detail).Infof("%v", err)

View File

@ -464,7 +464,7 @@ func (t *udp) send(toaddr *net.UDPAddr, ptype byte, req interface{}) error {
if err != nil { if err != nil {
return err return err
} }
glog.V(logger.Detail).Infof(">>> %v %T\n", toaddr, req) glog.V(logger.Detail).Infof(">>> %v %T", toaddr, req)
if _, err = t.conn.WriteToUDP(packet, toaddr); err != nil { if _, err = t.conn.WriteToUDP(packet, toaddr); err != nil {
glog.V(logger.Detail).Infoln("UDP send failed:", err) glog.V(logger.Detail).Infoln("UDP send failed:", err)
} }
@ -518,14 +518,14 @@ func (t *udp) readLoop() {
func (t *udp) handlePacket(from *net.UDPAddr, buf []byte) error { func (t *udp) handlePacket(from *net.UDPAddr, buf []byte) error {
packet, fromID, hash, err := decodePacket(buf) packet, fromID, hash, err := decodePacket(buf)
if err != nil { if err != nil {
glog.V(logger.Debug).Infof("Bad packet from %v: %v\n", from, err) glog.V(logger.Debug).Infof("Bad packet from %v: %v", from, err)
return err return err
} }
status := "ok" status := "ok"
if err = packet.handle(t, from, fromID, hash); err != nil { if err = packet.handle(t, from, fromID, hash); err != nil {
status = err.Error() status = err.Error()
} }
glog.V(logger.Detail).Infof("<<< %v %T: %s\n", from, packet, status) glog.V(logger.Detail).Infof("<<< %v %T: %s", from, packet, status)
return err return err
} }

View File

@ -348,7 +348,7 @@ func (t *udp) sendPacket(toid NodeID, toaddr *net.UDPAddr, ptype byte, req inter
//fmt.Println(err) //fmt.Println(err)
return hash, err return hash, err
} }
glog.V(logger.Detail).Infof(">>> %v to %x@%v\n", nodeEvent(ptype), toid[:8], toaddr) glog.V(logger.Detail).Infof(">>> %v to %x@%v", nodeEvent(ptype), toid[:8], toaddr)
if _, err = t.conn.WriteToUDP(packet, toaddr); err != nil { if _, err = t.conn.WriteToUDP(packet, toaddr); err != nil {
glog.V(logger.Detail).Infoln("UDP send failed:", err) glog.V(logger.Detail).Infoln("UDP send failed:", err)
} }
@ -407,7 +407,7 @@ func (t *udp) readLoop() {
func (t *udp) handlePacket(from *net.UDPAddr, buf []byte) error { func (t *udp) handlePacket(from *net.UDPAddr, buf []byte) error {
pkt := ingressPacket{remoteAddr: from} pkt := ingressPacket{remoteAddr: from}
if err := decodePacket(buf, &pkt); err != nil { if err := decodePacket(buf, &pkt); err != nil {
glog.V(logger.Debug).Infof("Bad packet from %v: %v\n", from, err) glog.V(logger.Debug).Infof("Bad packet from %v: %v", from, err)
//fmt.Println("bad packet", err) //fmt.Println("bad packet", err)
return err return err
} }

View File

@ -102,13 +102,13 @@ func Map(m Interface, c chan struct{}, protocol string, extport, intport int, na
refresh := time.NewTimer(mapUpdateInterval) refresh := time.NewTimer(mapUpdateInterval)
defer func() { defer func() {
refresh.Stop() refresh.Stop()
glog.V(logger.Debug).Infof("deleting port mapping: %s %d -> %d (%s) using %s\n", protocol, extport, intport, name, m) glog.V(logger.Debug).Infof("deleting port mapping: %s %d -> %d (%s) using %s", protocol, extport, intport, name, m)
m.DeleteMapping(protocol, extport, intport) m.DeleteMapping(protocol, extport, intport)
}() }()
if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil { if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil {
glog.V(logger.Debug).Infof("network port %s:%d could not be mapped: %v\n", protocol, intport, err) glog.V(logger.Debug).Infof("network port %s:%d could not be mapped: %v", protocol, intport, err)
} else { } else {
glog.V(logger.Info).Infof("mapped network port %s:%d -> %d (%s) using %s\n", protocol, extport, intport, name, m) glog.V(logger.Info).Infof("mapped network port %s:%d -> %d (%s) using %s", protocol, extport, intport, name, m)
} }
for { for {
select { select {
@ -117,9 +117,9 @@ func Map(m Interface, c chan struct{}, protocol string, extport, intport int, na
return return
} }
case <-refresh.C: case <-refresh.C:
glog.V(logger.Detail).Infof("refresh port mapping %s:%d -> %d (%s) using %s\n", protocol, extport, intport, name, m) glog.V(logger.Detail).Infof("refresh port mapping %s:%d -> %d (%s) using %s", protocol, extport, intport, name, m)
if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil { if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil {
glog.V(logger.Debug).Infof("network port %s:%d could not be mapped: %v\n", protocol, intport, err) glog.V(logger.Debug).Infof("network port %s:%d could not be mapped: %v", protocol, intport, err)
} }
refresh.Reset(mapUpdateInterval) refresh.Reset(mapUpdateInterval)
} }

View File

@ -157,27 +157,27 @@ loop:
// A write finished. Allow the next write to start if // A write finished. Allow the next write to start if
// there was no error. // there was no error.
if err != nil { if err != nil {
glog.V(logger.Detail).Infof("%v: write error: %v\n", p, err) glog.V(logger.Detail).Infof("%v: write error: %v", p, err)
reason = DiscNetworkError reason = DiscNetworkError
break loop break loop
} }
writeStart <- struct{}{} writeStart <- struct{}{}
case err := <-readErr: case err := <-readErr:
if r, ok := err.(DiscReason); ok { if r, ok := err.(DiscReason); ok {
glog.V(logger.Debug).Infof("%v: remote requested disconnect: %v\n", p, r) glog.V(logger.Debug).Infof("%v: remote requested disconnect: %v", p, r)
requested = true requested = true
reason = r reason = r
} else { } else {
glog.V(logger.Detail).Infof("%v: read error: %v\n", p, err) glog.V(logger.Detail).Infof("%v: read error: %v", p, err)
reason = DiscNetworkError reason = DiscNetworkError
} }
break loop break loop
case err := <-p.protoErr: case err := <-p.protoErr:
reason = discReasonForError(err) reason = discReasonForError(err)
glog.V(logger.Debug).Infof("%v: protocol error: %v (%v)\n", p, err, reason) glog.V(logger.Debug).Infof("%v: protocol error: %v (%v)", p, err, reason)
break loop break loop
case reason = <-p.disc: case reason = <-p.disc:
glog.V(logger.Debug).Infof("%v: locally requested disconnect: %v\n", p, reason) glog.V(logger.Debug).Infof("%v: locally requested disconnect: %v", p, reason)
break loop break loop
} }
} }
@ -298,14 +298,14 @@ func (p *Peer) startProtocols(writeStart <-chan struct{}, writeErr chan<- error)
proto.closed = p.closed proto.closed = p.closed
proto.wstart = writeStart proto.wstart = writeStart
proto.werr = writeErr proto.werr = writeErr
glog.V(logger.Detail).Infof("%v: Starting protocol %s/%d\n", p, proto.Name, proto.Version) glog.V(logger.Detail).Infof("%v: Starting protocol %s/%d", p, proto.Name, proto.Version)
go func() { go func() {
err := proto.Run(p, proto) err := proto.Run(p, proto)
if err == nil { if err == nil {
glog.V(logger.Detail).Infof("%v: Protocol %s/%d returned\n", p, proto.Name, proto.Version) glog.V(logger.Detail).Infof("%v: Protocol %s/%d returned", p, proto.Name, proto.Version)
err = errors.New("protocol returned") err = errors.New("protocol returned")
} else if err != io.EOF { } else if err != io.EOF {
glog.V(logger.Detail).Infof("%v: Protocol %s/%d error: %v\n", p, proto.Name, proto.Version, err) glog.V(logger.Detail).Infof("%v: Protocol %s/%d error: %v", p, proto.Name, proto.Version, err)
} }
p.protoErr <- err p.protoErr <- err
p.wg.Done() p.wg.Done()