Commit 50ab623e authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

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.
parent 3bac90de
...@@ -211,7 +211,7 @@ func (bs *bitswap) sendWantlistMsgToPeers(ctx context.Context, m bsmsg.BitSwapMe ...@@ -211,7 +211,7 @@ func (bs *bitswap) sendWantlistMsgToPeers(ctx context.Context, m bsmsg.BitSwapMe
go func(p peer.ID) { go func(p peer.ID) {
defer wg.Done() defer wg.Done()
if err := bs.send(ctx, p, m); err != nil { if err := bs.send(ctx, p, m); err != nil {
log.Error(err) // TODO remove if too verbose log.Debug(err) // TODO remove if too verbose
} }
}(peerToQuery) }(peerToQuery)
} }
...@@ -258,7 +258,7 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context, entries []wantli ...@@ -258,7 +258,7 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context, entries []wantli
err := bs.sendWantlistToPeers(ctx, sendToPeers) err := bs.sendWantlistToPeers(ctx, sendToPeers)
if err != nil { if err != nil {
log.Errorf("sendWantlistToPeers error: %s", err) log.Debugf("sendWantlistToPeers error: %s", err)
} }
} }
...@@ -268,12 +268,12 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg ...@@ -268,12 +268,12 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
defer log.EventBegin(ctx, "receiveMessage", p, incoming).Done() defer log.EventBegin(ctx, "receiveMessage", p, incoming).Done()
if p == "" { if p == "" {
log.Error("Received message from nil peer!") log.Debug("Received message from nil peer!")
// TODO propagate the error upward // TODO propagate the error upward
return "", nil return "", nil
} }
if incoming == nil { if incoming == nil {
log.Error("Got nil bitswap message!") log.Debug("Got nil bitswap message!")
// TODO propagate the error upward // TODO propagate the error upward
return "", nil return "", nil
} }
...@@ -287,7 +287,7 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg ...@@ -287,7 +287,7 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
for _, block := range incoming.Blocks() { for _, block := range incoming.Blocks() {
hasBlockCtx, _ := context.WithTimeout(ctx, hasBlockTimeout) hasBlockCtx, _ := context.WithTimeout(ctx, hasBlockTimeout)
if err := bs.HasBlock(hasBlockCtx, block); err != nil { if err := bs.HasBlock(hasBlockCtx, block); err != nil {
log.Error(err) log.Debug(err)
} }
} }
var keys []u.Key var keys []u.Key
...@@ -308,7 +308,7 @@ func (bs *bitswap) PeerConnected(p peer.ID) { ...@@ -308,7 +308,7 @@ func (bs *bitswap) PeerConnected(p peer.ID) {
close(peers) close(peers)
err := bs.sendWantlistToPeers(context.TODO(), peers) err := bs.sendWantlistToPeers(context.TODO(), peers)
if err != nil { if err != nil {
log.Errorf("error sending wantlist: %s", err) log.Debugf("error sending wantlist: %s", err)
} }
} }
...@@ -329,13 +329,13 @@ func (bs *bitswap) cancelBlocks(ctx context.Context, bkeys []u.Key) { ...@@ -329,13 +329,13 @@ func (bs *bitswap) cancelBlocks(ctx context.Context, bkeys []u.Key) {
for _, p := range bs.engine.Peers() { for _, p := range bs.engine.Peers() {
err := bs.send(ctx, p, message) err := bs.send(ctx, p, message)
if err != nil { if err != nil {
log.Errorf("Error sending message: %s", err) log.Debugf("Error sending message: %s", err)
} }
} }
} }
func (bs *bitswap) ReceiveError(err error) { func (bs *bitswap) ReceiveError(err error) {
log.Errorf("Bitswap ReceiveError: %s", err) log.Debugf("Bitswap ReceiveError: %s", err)
// TODO log the network error // TODO log the network error
// TODO bubble the network error up to the parent context/error logger // TODO bubble the network error up to the parent context/error logger
} }
...@@ -413,7 +413,7 @@ func (bs *bitswap) clientWorker(parent context.Context) { ...@@ -413,7 +413,7 @@ func (bs *bitswap) clientWorker(parent context.Context) {
providers := bs.network.FindProvidersAsync(child, keys[0], maxProvidersPerRequest) providers := bs.network.FindProvidersAsync(child, keys[0], maxProvidersPerRequest)
err := bs.sendWantlistToPeers(ctx, providers) err := bs.sendWantlistToPeers(ctx, providers)
if err != nil { if err != nil {
log.Errorf("error sending wantlist: %s", err) log.Debugf("error sending wantlist: %s", err)
} }
case <-parent.Done(): case <-parent.Done():
return return
......
...@@ -62,7 +62,7 @@ func (bsnet *impl) SendMessage( ...@@ -62,7 +62,7 @@ func (bsnet *impl) SendMessage(
defer s.Close() defer s.Close()
if err := outgoing.ToNet(s); err != nil { if err := outgoing.ToNet(s); err != nil {
log.Errorf("error: %s", err) log.Debugf("error: %s", err)
return err return err
} }
...@@ -81,13 +81,13 @@ func (bsnet *impl) SendRequest( ...@@ -81,13 +81,13 @@ func (bsnet *impl) SendRequest(
defer s.Close() defer s.Close()
if err := outgoing.ToNet(s); err != nil { if err := outgoing.ToNet(s); err != nil {
log.Errorf("error: %s", err) log.Debugf("error: %s", err)
return nil, err return nil, err
} }
incoming, err := bsmsg.FromNet(s) incoming, err := bsmsg.FromNet(s)
if err != nil { if err != nil {
log.Errorf("error: %s", err) log.Debugf("error: %s", err)
return incoming, err return incoming, err
} }
...@@ -150,7 +150,7 @@ func (bsnet *impl) handleNewStream(s inet.Stream) { ...@@ -150,7 +150,7 @@ func (bsnet *impl) handleNewStream(s inet.Stream) {
received, err := bsmsg.FromNet(s) received, err := bsmsg.FromNet(s)
if err != nil { if err != nil {
go bsnet.receiver.ReceiveError(err) go bsnet.receiver.ReceiveError(err)
log.Errorf("bitswap net handleNewStream from %s error: %s", s.Conn().RemotePeer(), err) log.Debugf("bitswap net handleNewStream from %s error: %s", s.Conn().RemotePeer(), err)
return return
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment