From 3afbc9d8d9f418978dd0b22c42f4cda3e1edfaf9 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 3 Feb 2015 01:06:07 -0800 Subject: [PATCH] logs: removed all log.Errors unhelpful to users Let's save log.Error for things the user can take action on. Moved all our diagnostics to log.Debug. We can ideally reduce them even further. --- net/swarm/swarm_listen.go | 4 ++-- net/swarm/swarm_test.go | 8 ++++---- protocol/mux.go | 7 ++----- test/backpressure/backpressure_test.go | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/net/swarm/swarm_listen.go b/net/swarm/swarm_listen.go index 8c7a7b5a..d19ad961 100644 --- a/net/swarm/swarm_listen.go +++ b/net/swarm/swarm_listen.go @@ -33,7 +33,7 @@ func (s *Swarm) listen(addrs []ma.Multiaddr) error { retErr.Errors = make([]error, len(addrs)) } retErr.Errors[i] = err - log.Errorf("Failed to listen on: %s - %s", addr, err) + log.Debugf("Failed to listen on: %s - %s", addr, err) } } @@ -122,7 +122,7 @@ func (s *Swarm) connHandler(c *ps.Conn) *Conn { sc, err := s.newConnSetup(ctx, c) if err != nil { - log.Error(err) + log.Debug(err) log.Event(ctx, "newConnHandlerDisconnect", lgbl.NetConn(c.NetConn()), lgbl.Error(err)) c.Close() // boom. close it. return nil diff --git a/net/swarm/swarm_test.go b/net/swarm/swarm_test.go index 1c2ae1d0..a2bb943e 100644 --- a/net/swarm/swarm_test.go +++ b/net/swarm/swarm_test.go @@ -22,25 +22,25 @@ func EchoStreamHandler(stream inet.Stream) { // pull out the ipfs conn c := stream.Conn() - log.Debugf("%s ponging to %s", c.LocalPeer(), c.RemotePeer()) + log.Infof("%s ponging to %s", c.LocalPeer(), c.RemotePeer()) buf := make([]byte, 4) for { if _, err := stream.Read(buf); err != nil { if err != io.EOF { - log.Error("ping receive error:", err) + log.Info("ping receive error:", err) } return } if !bytes.Equal(buf, []byte("ping")) { - log.Errorf("ping receive error: ping != %s %v", buf, buf) + log.Infof("ping receive error: ping != %s %v", buf, buf) return } if _, err := stream.Write([]byte("pong")); err != nil { - log.Error("pond send error:", err) + log.Info("pond send error:", err) return } } diff --git a/protocol/mux.go b/protocol/mux.go index 4ff3bc2f..0e93325b 100644 --- a/protocol/mux.go +++ b/protocol/mux.go @@ -24,9 +24,8 @@ type streamHandlerMap map[ID]inet.StreamHandler // It contains the handlers for each protocol accepted. // It dispatches handlers for streams opened by remote peers. type Mux struct { - - lock sync.RWMutex - handlers streamHandlerMap + lock sync.RWMutex + handlers streamHandlerMap defaultHandler inet.StreamHandler } @@ -50,13 +49,11 @@ func (m *Mux) Protocols() []ID { // readHeader reads the stream and returns the next Handler function // according to the muxer encoding. func (m *Mux) readHeader(s io.Reader) (ID, inet.StreamHandler, error) { - // log.Error("ReadProtocolHeader") p, err := ReadHeader(s) if err != nil { return "", nil, err } - // log.Debug("readHeader got:", p) m.lock.RLock() defer m.lock.RUnlock() h, found := m.handlers[p] diff --git a/test/backpressure/backpressure_test.go b/test/backpressure/backpressure_test.go index 3d6dfd29..78c1ce97 100644 --- a/test/backpressure/backpressure_test.go +++ b/test/backpressure/backpressure_test.go @@ -66,9 +66,9 @@ a problem. // our request handler. can do stuff here. we // simulate something taking time by waiting // on requestHandled - log.Error("request worker handling...") + log.Debug("request worker handling...") <-requestHandled - log.Error("request worker done!") + log.Debug("request worker done!") receiverRatelimit <- struct{}{} // release }() }