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.
This commit is contained in:
parent
e3e91a4d24
commit
3afbc9d8d9
|
@ -33,7 +33,7 @@ func (s *Swarm) listen(addrs []ma.Multiaddr) error {
|
||||||
retErr.Errors = make([]error, len(addrs))
|
retErr.Errors = make([]error, len(addrs))
|
||||||
}
|
}
|
||||||
retErr.Errors[i] = err
|
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)
|
sc, err := s.newConnSetup(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Debug(err)
|
||||||
log.Event(ctx, "newConnHandlerDisconnect", lgbl.NetConn(c.NetConn()), lgbl.Error(err))
|
log.Event(ctx, "newConnHandlerDisconnect", lgbl.NetConn(c.NetConn()), lgbl.Error(err))
|
||||||
c.Close() // boom. close it.
|
c.Close() // boom. close it.
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -22,25 +22,25 @@ func EchoStreamHandler(stream inet.Stream) {
|
||||||
|
|
||||||
// pull out the ipfs conn
|
// pull out the ipfs conn
|
||||||
c := stream.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)
|
buf := make([]byte, 4)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if _, err := stream.Read(buf); err != nil {
|
if _, err := stream.Read(buf); err != nil {
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
log.Error("ping receive error:", err)
|
log.Info("ping receive error:", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(buf, []byte("ping")) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := stream.Write([]byte("pong")); err != nil {
|
if _, err := stream.Write([]byte("pong")); err != nil {
|
||||||
log.Error("pond send error:", err)
|
log.Info("pond send error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,8 @@ type streamHandlerMap map[ID]inet.StreamHandler
|
||||||
// It contains the handlers for each protocol accepted.
|
// It contains the handlers for each protocol accepted.
|
||||||
// It dispatches handlers for streams opened by remote peers.
|
// It dispatches handlers for streams opened by remote peers.
|
||||||
type Mux struct {
|
type Mux struct {
|
||||||
|
lock sync.RWMutex
|
||||||
lock sync.RWMutex
|
handlers streamHandlerMap
|
||||||
handlers streamHandlerMap
|
|
||||||
defaultHandler inet.StreamHandler
|
defaultHandler inet.StreamHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,13 +49,11 @@ func (m *Mux) Protocols() []ID {
|
||||||
// readHeader reads the stream and returns the next Handler function
|
// readHeader reads the stream and returns the next Handler function
|
||||||
// according to the muxer encoding.
|
// according to the muxer encoding.
|
||||||
func (m *Mux) readHeader(s io.Reader) (ID, inet.StreamHandler, error) {
|
func (m *Mux) readHeader(s io.Reader) (ID, inet.StreamHandler, error) {
|
||||||
// log.Error("ReadProtocolHeader")
|
|
||||||
p, err := ReadHeader(s)
|
p, err := ReadHeader(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.Debug("readHeader got:", p)
|
|
||||||
m.lock.RLock()
|
m.lock.RLock()
|
||||||
defer m.lock.RUnlock()
|
defer m.lock.RUnlock()
|
||||||
h, found := m.handlers[p]
|
h, found := m.handlers[p]
|
||||||
|
|
|
@ -66,9 +66,9 @@ a problem.
|
||||||
// our request handler. can do stuff here. we
|
// our request handler. can do stuff here. we
|
||||||
// simulate something taking time by waiting
|
// simulate something taking time by waiting
|
||||||
// on requestHandled
|
// on requestHandled
|
||||||
log.Error("request worker handling...")
|
log.Debug("request worker handling...")
|
||||||
<-requestHandled
|
<-requestHandled
|
||||||
log.Error("request worker done!")
|
log.Debug("request worker done!")
|
||||||
receiverRatelimit <- struct{}{} // release
|
receiverRatelimit <- struct{}{} // release
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue