Commit cee7d2d1 authored by Dirk McCormick's avatar Dirk McCormick

refactor: adjust log levels

parent ddf64ae2
......@@ -14,9 +14,11 @@ import (
logging "github.com/ipfs/go-log"
peer "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
"go.uber.org/zap"
)
var log = logging.Logger("bitswap")
var sflog = log.Desugar()
const (
defaultRebroadcastInterval = 30 * time.Second
......@@ -452,6 +454,11 @@ func (mq *MessageQueue) simulateDontHaveWithTimeout(msg bsmsg.BitSwapMessage) {
}
func (mq *MessageQueue) logOutgoingMessage(msg bsmsg.BitSwapMessage) {
// Save some CPU cycles and allocations if log level is higher than debug
if ce := sflog.Check(zap.DebugLevel, "Bitswap -> send wants"); ce == nil {
return
}
self := mq.network.Self()
entries := msg.Wantlist()
for _, e := range entries {
......
......@@ -15,9 +15,11 @@ import (
logging "github.com/ipfs/go-log"
peer "github.com/libp2p/go-libp2p-core/peer"
loggables "github.com/libp2p/go-libp2p-loggables"
"go.uber.org/zap"
)
var log = logging.Logger("bs:sess")
var sflog = log.Desugar()
const (
broadcastLiveWantsLimit = 64
......@@ -194,8 +196,11 @@ func (s *Session) ReceiveFrom(from peer.ID, ks []cid.Cid, haves []cid.Cid, dontH
}
func (s *Session) logReceiveFrom(from peer.ID, interestedKs []cid.Cid, haves []cid.Cid, dontHaves []cid.Cid) {
// log.Debugf("Ses%d<-%s: %d blocks, %d haves, %d dont haves\n",
// s.id, from, len(interestedKs), len(wantedHaves), len(wantedDontHaves))
// Save some CPU cycles if log level is higher than debug
if ce := sflog.Check(zap.DebugLevel, "Bitswap <- rcv message"); ce == nil {
return
}
for _, c := range interestedKs {
log.Debugw("Bitswap <- block", "local", s.self, "from", from, "cid", c, "session", s.id)
}
......@@ -336,7 +341,7 @@ func (s *Session) broadcastWantHaves(ctx context.Context, wants []cid.Cid) {
// Search for providers who have the first want in the list.
// Typically if the provider has the first block they will have
// the rest of the blocks also.
log.Infof("Ses%d: FindMorePeers with want %s (1st of %d wants)", s.id, wants[0], len(wants))
log.Debugf("Ses%d: FindMorePeers with want %s (1st of %d wants)", s.id, wants[0], len(wants))
s.findMorePeers(ctx, wants[0])
}
s.resetIdleTick()
......
......@@ -7,12 +7,14 @@ import (
bssim "github.com/ipfs/go-bitswap/internal/sessioninterestmanager"
"github.com/ipfs/go-bitswap/internal/sessionmanager"
bsswl "github.com/ipfs/go-bitswap/internal/sessionwantlist"
"gopkg.in/src-d/go-log.v1"
logging "github.com/ipfs/go-log"
cid "github.com/ipfs/go-cid"
peer "github.com/libp2p/go-libp2p-core/peer"
)
var log = logging.Logger("bitswap")
// PeerHandler sends wants / cancels to other peers
type PeerHandler interface {
// Connected is called when a peer connects, with any initial want-haves
......@@ -76,7 +78,7 @@ func (wm *WantManager) ReceiveFrom(ctx context.Context, p peer.ID, blks []cid.Ci
// BroadcastWantHaves is called when want-haves should be broadcast to all
// connected peers (as part of session discovery)
func (wm *WantManager) BroadcastWantHaves(ctx context.Context, ses uint64, wantHaves []cid.Cid) {
log.Infof("BroadcastWantHaves session%d: %s", ses, wantHaves)
log.Debugf("BroadcastWantHaves session%d: %s", ses, wantHaves)
// Record broadcast wants
wm.bcwl.Add(wantHaves, ses)
......
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