mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
u.DOut -> log.Debug
and other logging switches. I kept the u.PErr and u.POut in cli commands, as those do need to write raw output directly.
This commit is contained in:
parent
c6ffaa4a77
commit
972c0f7b4b
10
core/core.go
10
core/core.go
@ -213,12 +213,12 @@ func initIdentity(cfg *config.Config, online bool) (*peer.Peer, error) {
|
||||
func initConnections(ctx context.Context, cfg *config.Config, pstore peer.Peerstore, route *dht.IpfsDHT) {
|
||||
for _, p := range cfg.Bootstrap {
|
||||
if p.PeerID == "" {
|
||||
u.PErr("error: peer does not include PeerID. %v\n", p)
|
||||
log.Error("error: peer does not include PeerID. %v", p)
|
||||
}
|
||||
|
||||
maddr, err := ma.NewMultiaddr(p.Address)
|
||||
if err != nil {
|
||||
u.PErr("error: %v\n", err)
|
||||
log.Error("%s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -227,12 +227,12 @@ func initConnections(ctx context.Context, cfg *config.Config, pstore peer.Peerst
|
||||
npeer.AddAddress(maddr)
|
||||
|
||||
if err = pstore.Put(npeer); err != nil {
|
||||
u.PErr("Bootstrapping error: %v\n", err)
|
||||
log.Error("Bootstrapping error: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if _, err = route.Connect(ctx, npeer); err != nil {
|
||||
u.PErr("Bootstrapping error: %v\n", err)
|
||||
log.Error("Bootstrapping error: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -244,6 +244,6 @@ func (n *IpfsNode) PinDagNode(nd *merkledag.Node) error {
|
||||
|
||||
// PinDagNodeRecursively ensures a given node is stored persistently locally
|
||||
func (n *IpfsNode) PinDagNodeRecursively(nd *merkledag.Node, depth int) error {
|
||||
u.DOut("Pinning node recursively. Currently No-Op\n")
|
||||
log.Debug("Pinning node recursively. Currently No-Op")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -19,6 +19,8 @@ import (
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
var log = u.Logger("crypto")
|
||||
|
||||
var ErrBadKeyType = errors.New("invalid or unsupported key type")
|
||||
|
||||
const (
|
||||
@ -97,7 +99,7 @@ func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error) {
|
||||
}
|
||||
|
||||
pubKey := elliptic.Marshal(curve, x, y)
|
||||
u.PErr("GenerateEKeyPair %d\n", len(pubKey))
|
||||
log.Debug("GenerateEKeyPair %d", len(pubKey))
|
||||
|
||||
done := func(theirPub []byte) ([]byte, error) {
|
||||
// Verify and unpack node's public key.
|
||||
|
||||
@ -23,6 +23,8 @@ import (
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
var log = u.Logger("handshake")
|
||||
|
||||
// List of supported ECDH curves
|
||||
var SupportedExchanges = "P-256,P-224,P-384,P-521"
|
||||
|
||||
@ -49,7 +51,7 @@ func (s *SecurePipe) handshake() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// u.DOut("handshake: %s <--> %s\n", s.local, s.remote)
|
||||
log.Debug("handshake: %s <--> %s", s.local, s.remote)
|
||||
myPubKey, err := s.local.PubKey.Bytes()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -101,7 +103,7 @@ func (s *SecurePipe) handshake() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.DOut("%s Remote Peer Identified as %s\n", s.local, s.remote)
|
||||
log.Debug("%s Remote Peer Identified as %s", s.local, s.remote)
|
||||
|
||||
exchange, err := selectBest(SupportedExchanges, proposeResp.GetExchanges())
|
||||
if err != nil {
|
||||
@ -205,7 +207,7 @@ func (s *SecurePipe) handshake() error {
|
||||
return errors.New("Negotiation failed.")
|
||||
}
|
||||
|
||||
u.DOut("%s handshake: Got node id: %s\n", s.local, s.remote)
|
||||
log.Debug("%s handshake: Got node id: %s", s.local, s.remote)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -233,7 +235,7 @@ func (s *SecurePipe) handleSecureIn(hashType string, tIV, tCKey, tMKey []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
// u.DOut("[peer %s] secure in [from = %s] %d\n", s.local, s.remote, len(data))
|
||||
// log.Debug("[peer %s] secure in [from = %s] %d", s.local, s.remote, len(data))
|
||||
if len(data) <= macSize {
|
||||
continue
|
||||
}
|
||||
@ -281,7 +283,7 @@ func (s *SecurePipe) handleSecureOut(hashType string, mIV, mCKey, mMKey []byte)
|
||||
copy(buff[len(data):], myMac.Sum(nil))
|
||||
myMac.Reset()
|
||||
|
||||
// u.DOut("[peer %s] secure out [to = %s] %d\n", s.local, s.remote, len(buff))
|
||||
// log.Debug("[peer %s] secure out [to = %s] %d", s.local, s.remote, len(buff))
|
||||
s.insecure.Out <- buff
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ func (dl *DaemonListener) handleConnection(conn net.Conn) {
|
||||
return
|
||||
}
|
||||
|
||||
u.DOut("Got command: %v\n", command)
|
||||
log.Debug("Got command: %v", command)
|
||||
switch command.Command {
|
||||
case "add":
|
||||
err = commands.Add(dl.node, command.Args, command.Opts, conn)
|
||||
|
||||
@ -15,6 +15,8 @@ import (
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
var log = u.Logger("bitswap")
|
||||
|
||||
// NetMessageSession initializes a BitSwap session that communicates over the
|
||||
// provided NetMessage service
|
||||
func NetMessageSession(parent context.Context, p *peer.Peer, s bsnet.NetMessageService, directory bsnet.Routing, d ds.Datastore, nice bool) exchange.Interface {
|
||||
@ -61,7 +63,7 @@ type bitswap struct {
|
||||
//
|
||||
// TODO ensure only one active request per key
|
||||
func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error) {
|
||||
u.DOut("Get Block %v\n", k)
|
||||
log.Debug("Get Block %v", k)
|
||||
|
||||
ctx, cancelFunc := context.WithCancel(parent)
|
||||
bs.wantlist.Add(k)
|
||||
@ -77,7 +79,7 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error)
|
||||
}
|
||||
message.AppendWanted(k)
|
||||
for iiiii := range peersToQuery {
|
||||
// u.DOut("bitswap got peersToQuery: %s\n", iiiii)
|
||||
// log.Debug("bitswap got peersToQuery: %s", iiiii)
|
||||
go func(p *peer.Peer) {
|
||||
response, err := bs.sender.SendRequest(ctx, p, message)
|
||||
if err != nil {
|
||||
@ -110,7 +112,7 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error)
|
||||
// HasBlock announces the existance of a block to bitswap, potentially sending
|
||||
// it to peers (Partners) whose WantLists include it.
|
||||
func (bs *bitswap) HasBlock(ctx context.Context, blk blocks.Block) error {
|
||||
u.DOut("Has Block %v\n", blk.Key())
|
||||
log.Debug("Has Block %v", blk.Key())
|
||||
bs.wantlist.Remove(blk.Key())
|
||||
bs.sendToPeersThatWant(ctx, blk)
|
||||
return bs.routing.Provide(ctx, blk.Key())
|
||||
@ -119,7 +121,7 @@ func (bs *bitswap) HasBlock(ctx context.Context, blk blocks.Block) error {
|
||||
// TODO(brian): handle errors
|
||||
func (bs *bitswap) ReceiveMessage(ctx context.Context, p *peer.Peer, incoming bsmsg.BitSwapMessage) (
|
||||
*peer.Peer, bsmsg.BitSwapMessage) {
|
||||
u.DOut("ReceiveMessage from %v\n", p.Key())
|
||||
log.Debug("ReceiveMessage from %v", p.Key())
|
||||
|
||||
if p == nil {
|
||||
// TODO propagate the error upward
|
||||
@ -173,10 +175,10 @@ func (bs *bitswap) send(ctx context.Context, p *peer.Peer, m bsmsg.BitSwapMessag
|
||||
}
|
||||
|
||||
func (bs *bitswap) sendToPeersThatWant(ctx context.Context, block blocks.Block) {
|
||||
u.DOut("Sending %v to peers that want it\n", block.Key())
|
||||
log.Debug("Sending %v to peers that want it", block.Key())
|
||||
for _, p := range bs.strategy.Peers() {
|
||||
if bs.strategy.BlockIsWantedByPeer(block.Key(), p) {
|
||||
u.DOut("%v wants %v\n", p, block.Key())
|
||||
log.Debug("%v wants %v", p, block.Key())
|
||||
if bs.strategy.ShouldSendBlockToPeer(block.Key(), p) {
|
||||
message := bsmsg.New()
|
||||
message.AppendBlock(block)
|
||||
|
||||
@ -106,7 +106,7 @@ func (s *Node) Attr() fuse.Attr {
|
||||
Blocks: uint64(len(s.Nd.Links)),
|
||||
}
|
||||
default:
|
||||
u.PErr("Invalid data type.")
|
||||
log.Error("Invalid data type.")
|
||||
return fuse.Attr{}
|
||||
}
|
||||
}
|
||||
@ -143,7 +143,7 @@ func (s *Node) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) {
|
||||
|
||||
// ReadAll reads the object data as file data
|
||||
func (s *Node) ReadAll(intr fs.Intr) ([]byte, fuse.Error) {
|
||||
u.DOut("Read node.\n")
|
||||
log.Debug("Read node.")
|
||||
r, err := uio.NewDagReader(s.Nd, s.Ipfs.DAG)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -12,6 +12,8 @@ import (
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
var log = u.Logger("conn")
|
||||
|
||||
// ChanBuffer is the size of the buffer in the Conn Chan
|
||||
const ChanBuffer = 10
|
||||
|
||||
@ -87,7 +89,7 @@ func (c *Conn) newChans() error {
|
||||
|
||||
// Close closes the connection, and associated channels.
|
||||
func (c *Conn) Close() error {
|
||||
u.DOut("Closing Conn.\n")
|
||||
log.Debug("Closing Conn with %v", c.Peer)
|
||||
if c.Conn == nil {
|
||||
return fmt.Errorf("Already closed") // already closed
|
||||
}
|
||||
|
||||
@ -11,6 +11,8 @@ import (
|
||||
proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
|
||||
)
|
||||
|
||||
var log = u.Logger("muxer")
|
||||
|
||||
// Protocol objects produce + consume raw data. They are added to the Muxer
|
||||
// with a ProtocolID, which is added to outgoing payloads. Muxer properly
|
||||
// encapsulates and decapsulates when interfacing with its Protocols. The
|
||||
@ -125,21 +127,21 @@ func (m *Muxer) handleIncomingMessage(m1 msg.NetMessage) {
|
||||
|
||||
data, pid, err := unwrapData(m1.Data())
|
||||
if err != nil {
|
||||
u.PErr("muxer de-serializing error: %v\n", err)
|
||||
log.Error("muxer de-serializing error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
m2 := msg.New(m1.Peer(), data)
|
||||
proto, found := m.Protocols[pid]
|
||||
if !found {
|
||||
u.PErr("muxer unknown protocol %v\n", pid)
|
||||
log.Error("muxer unknown protocol %v", pid)
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case proto.GetPipe().Incoming <- m2:
|
||||
case <-m.ctx.Done():
|
||||
u.PErr("%v\n", m.ctx.Err())
|
||||
log.Error("%s", m.ctx.Err())
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -167,7 +169,7 @@ func (m *Muxer) handleOutgoingMessages(pid ProtocolID, proto Protocol) {
|
||||
func (m *Muxer) handleOutgoingMessage(pid ProtocolID, m1 msg.NetMessage) {
|
||||
data, err := wrapData(m1.Data(), pid)
|
||||
if err != nil {
|
||||
u.PErr("muxer serializing error: %v\n", err)
|
||||
log.Error("muxer serializing error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +136,7 @@ func TestSimultMuxer(t *testing.T) {
|
||||
m := msg.New(peer1, []byte(s))
|
||||
mux1.Protocols[pid].GetPipe().Outgoing <- m
|
||||
counts[pid][0][0]++
|
||||
u.DOut("sent %v\n", s)
|
||||
// log.Debug("sent %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ func TestSimultMuxer(t *testing.T) {
|
||||
m := msg.New(peer1, d)
|
||||
mux1.Incoming <- m
|
||||
counts[pid][1][0]++
|
||||
u.DOut("sent %v\n", s)
|
||||
// log.Debug("sent %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ func TestSimultMuxer(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
u.DOut("got %v\n", string(data))
|
||||
// log.Debug("got %v", string(data))
|
||||
counts[pid][1][1]++
|
||||
|
||||
case <-ctx.Done():
|
||||
@ -180,7 +180,7 @@ func TestSimultMuxer(t *testing.T) {
|
||||
select {
|
||||
case m := <-mux1.Protocols[pid].GetPipe().Incoming:
|
||||
counts[pid][0][1]++
|
||||
u.DOut("got %v\n", string(m.Data()))
|
||||
// log.Debug("got %v", string(m.Data()))
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ import (
|
||||
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
||||
)
|
||||
|
||||
var log = u.Logger("service")
|
||||
|
||||
// ErrNoResponse is returned by Service when a Request did not get a response,
|
||||
// and no other error happened
|
||||
var ErrNoResponse = errors.New("no response to request")
|
||||
@ -82,7 +84,7 @@ func (s *Service) sendMessage(ctx context.Context, m msg.NetMessage, rid Request
|
||||
return err
|
||||
}
|
||||
|
||||
// u.DOut("Service send message [to = %s]\n", m.Peer())
|
||||
// log.Debug("Service send message [to = %s]", m.Peer())
|
||||
|
||||
// send message
|
||||
m2 := msg.New(m.Peer(), data)
|
||||
@ -169,14 +171,14 @@ func (s *Service) handleIncomingMessage(ctx context.Context, m msg.NetMessage) {
|
||||
// unwrap the incoming message
|
||||
data, rid, err := unwrapData(m.Data())
|
||||
if err != nil {
|
||||
u.PErr("de-serializing error: %v\n", err)
|
||||
log.Error("de-serializing error: %v", err)
|
||||
}
|
||||
m2 := msg.New(m.Peer(), data)
|
||||
|
||||
// if it's a request (or has no RequestID), handle it
|
||||
if rid == nil || rid.IsRequest() {
|
||||
if s.Handler == nil {
|
||||
u.PErr("service dropped msg: %v\n", m)
|
||||
log.Error("service dropped msg: %v", m)
|
||||
return // no handler, drop it.
|
||||
}
|
||||
|
||||
@ -187,7 +189,7 @@ func (s *Service) handleIncomingMessage(ctx context.Context, m msg.NetMessage) {
|
||||
if r1 != nil {
|
||||
err := s.sendMessage(ctx, r1, rid.Response())
|
||||
if err != nil {
|
||||
u.PErr("error sending response message: %v\n", err)
|
||||
log.Error("error sending response message: %v", err)
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -195,7 +197,7 @@ func (s *Service) handleIncomingMessage(ctx context.Context, m msg.NetMessage) {
|
||||
|
||||
// Otherwise, it is a response. handle it.
|
||||
if !rid.IsResponse() {
|
||||
u.PErr("RequestID should identify a response here.\n")
|
||||
log.Error("RequestID should identify a response here.")
|
||||
}
|
||||
|
||||
key := RequestKey(m.Peer().ID, RequestID(rid))
|
||||
@ -204,7 +206,7 @@ func (s *Service) handleIncomingMessage(ctx context.Context, m msg.NetMessage) {
|
||||
s.RequestsLock.RUnlock()
|
||||
|
||||
if !found {
|
||||
u.PErr("no request key %v (timeout?)\n", []byte(key))
|
||||
log.Error("no request key %v (timeout?)", []byte(key))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
spipe "github.com/jbenet/go-ipfs/crypto/spipe"
|
||||
conn "github.com/jbenet/go-ipfs/net/conn"
|
||||
msg "github.com/jbenet/go-ipfs/net/message"
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
|
||||
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
||||
)
|
||||
@ -26,7 +25,7 @@ func (s *Swarm) listen() error {
|
||||
if err != nil {
|
||||
hasErr = true
|
||||
retErr.Errors[i] = err
|
||||
u.PErr("Failed to listen on: %s [%s]", addr, err)
|
||||
log.Error("Failed to listen on: %s [%s]", addr, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,16 +105,16 @@ func (s *Swarm) connSetup(c *conn.Conn) error {
|
||||
}
|
||||
|
||||
if c.Peer != nil {
|
||||
u.DOut("Starting connection: %s\n", c.Peer)
|
||||
log.Debug("Starting connection: %s", c.Peer)
|
||||
} else {
|
||||
u.DOut("Starting connection: [unknown peer]\n")
|
||||
log.Debug("Starting connection: [unknown peer]")
|
||||
}
|
||||
|
||||
if err := s.connSecure(c); err != nil {
|
||||
return fmt.Errorf("Conn securing error: %v", err)
|
||||
}
|
||||
|
||||
u.DOut("Secured connection: %s\n", c.Peer)
|
||||
log.Debug("Secured connection: %s", c.Peer)
|
||||
|
||||
// add address of connection to Peer. Maybe it should happen in connSecure.
|
||||
c.Peer.AddAddress(c.Addr)
|
||||
@ -184,7 +183,7 @@ func (s *Swarm) fanOut() {
|
||||
continue
|
||||
}
|
||||
|
||||
// u.DOut("[peer: %s] Sent message [to = %s]\n", s.local, msg.Peer())
|
||||
// log.Debug("[peer: %s] Sent message [to = %s]", s.local, msg.Peer())
|
||||
|
||||
// queue it in the connection's buffer
|
||||
conn.Secure.Out <- msg.Data()
|
||||
@ -212,7 +211,7 @@ func (s *Swarm) fanIn(c *conn.Conn) {
|
||||
goto out
|
||||
}
|
||||
|
||||
// u.DOut("[peer: %s] Received message [from = %s]\n", s.local, c.Peer)
|
||||
// log.Debug("[peer: %s] Received message [from = %s]", s.local, c.Peer)
|
||||
|
||||
msg := msg.New(c.Peer, data)
|
||||
s.Incoming <- msg
|
||||
|
||||
@ -15,6 +15,8 @@ import (
|
||||
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
|
||||
)
|
||||
|
||||
var log = u.Logger("swarm")
|
||||
|
||||
// ErrAlreadyOpen signals that a connection to a peer is already open.
|
||||
var ErrAlreadyOpen = errors.New("Error: Connection to this peer already open.")
|
||||
|
||||
|
||||
@ -40,11 +40,11 @@ func (s *Resolver) ResolvePath(fpath string) (*merkledag.Node, error) {
|
||||
// first element in the path is a b58 hash (for now)
|
||||
h, err := mh.FromB58String(parts[0])
|
||||
if err != nil {
|
||||
u.DOut("given path element is not a base58 string.\n")
|
||||
log.Debug("given path element is not a base58 string.\n")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
u.DOut("Resolve dag get.\n")
|
||||
log.Debug("Resolve dag get.\n")
|
||||
nd, err := s.DAG.Get(u.Key(h))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -3,7 +3,6 @@ package dht
|
||||
import (
|
||||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
|
||||
peer "github.com/jbenet/go-ipfs/peer"
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
func newMessage(typ Message_MessageType, key string, level int) *Message {
|
||||
@ -42,7 +41,7 @@ func peersToPBPeers(peers []*peer.Peer) []*Message_Peer {
|
||||
func (m *Message) GetClusterLevel() int {
|
||||
level := m.GetClusterLevelRaw() - 1
|
||||
if level < 0 {
|
||||
u.DErr("GetClusterLevel: no routing level specified, assuming 0\n")
|
||||
log.Error("GetClusterLevel: no routing level specified, assuming 0")
|
||||
level = 0
|
||||
}
|
||||
return int(level)
|
||||
|
||||
@ -3,8 +3,6 @@ package dht
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
u "github.com/jbenet/go-ipfs/util"
|
||||
)
|
||||
|
||||
type logDhtRPC struct {
|
||||
@ -31,9 +29,9 @@ func (l *logDhtRPC) EndLog() {
|
||||
func (l *logDhtRPC) Print() {
|
||||
b, err := json.Marshal(l)
|
||||
if err != nil {
|
||||
u.DOut(err.Error())
|
||||
log.Debug(err.Error())
|
||||
} else {
|
||||
u.DOut(string(b))
|
||||
log.Debug(string(b))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +237,7 @@ func TestNotFound(t *testing.T) {
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
||||
v, err := d.GetValue(ctx, u.Key("hello"))
|
||||
u.DOut("get value got %v\n", v)
|
||||
log.Debug("get value got %v", v)
|
||||
if err != nil {
|
||||
switch err {
|
||||
case u.ErrNotFound:
|
||||
|
||||
@ -156,7 +156,7 @@ func (dht *IpfsDHT) FindProvidersAsync2(ctx context.Context, key u.Key, count in
|
||||
go func(p *peer.Peer) {
|
||||
pmes, err := dht.findProvidersSingle(ctx, p, key, 0)
|
||||
if err != nil {
|
||||
u.PErr("%v\n", err)
|
||||
log.Error("%s", err)
|
||||
return
|
||||
}
|
||||
dht.addPeerListAsync(key, pmes.GetProviderPeers(), ps, count, peerOut)
|
||||
@ -207,11 +207,11 @@ func (dht *IpfsDHT) FindProviders(ctx context.Context, key u.Key) ([]*peer.Peer,
|
||||
// handle providers
|
||||
provs := pmes.GetProviderPeers()
|
||||
if provs != nil {
|
||||
u.DOut("Got providers back from findProviders call!\n")
|
||||
log.Debug("Got providers back from findProviders call!")
|
||||
return dht.addProviders(key, provs), nil
|
||||
}
|
||||
|
||||
u.DOut("Didnt get providers, just closer peers.\n")
|
||||
log.Debug("Didnt get providers, just closer peers.")
|
||||
closer := pmes.GetCloserPeers()
|
||||
if len(closer) == 0 {
|
||||
level++
|
||||
@ -220,7 +220,7 @@ func (dht *IpfsDHT) FindProviders(ctx context.Context, key u.Key) ([]*peer.Peer,
|
||||
|
||||
np, err := dht.peerFromInfo(closer[0])
|
||||
if err != nil {
|
||||
u.DOut("no peerFromInfo")
|
||||
log.Debug("no peerFromInfo")
|
||||
level++
|
||||
continue
|
||||
}
|
||||
@ -293,7 +293,7 @@ func (dht *IpfsDHT) findPeerMultiple(ctx context.Context, id peer.ID) (*peer.Pee
|
||||
query := newQuery(u.Key(id), func(ctx context.Context, p *peer.Peer) (*dhtQueryResult, error) {
|
||||
pmes, err := dht.findPeerSingle(ctx, p, id, routeLevel)
|
||||
if err != nil {
|
||||
u.DErr("getPeer error: %v\n", err)
|
||||
log.Error("%s getPeer error: %v", dht.self, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ func (dht *IpfsDHT) findPeerMultiple(ctx context.Context, id peer.ID) (*peer.Pee
|
||||
for i, fp := range plist {
|
||||
nxtp, err := dht.peerFromInfo(fp)
|
||||
if err != nil {
|
||||
u.DErr("findPeer error: %v\n", err)
|
||||
log.Error("%s findPeer error: %v", dht.self, err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ func copyPeersFromList(target ID, peerArr peerSorterArr, peerList *list.List) pe
|
||||
}
|
||||
peerArr = append(peerArr, &pd)
|
||||
if e == nil {
|
||||
u.POut("list element was nil.\n")
|
||||
log.Debug("list element was nil.\n")
|
||||
return peerArr
|
||||
}
|
||||
}
|
||||
|
||||
16
util/util.go
16
util/util.go
@ -130,22 +130,6 @@ func POut(format string, a ...interface{}) {
|
||||
fmt.Fprintf(os.Stdout, format, a...)
|
||||
}
|
||||
|
||||
// DErr is a shorthand debug printing function to output to Stderr.
|
||||
// Will only print if Debug is true.
|
||||
func DErr(format string, a ...interface{}) {
|
||||
if Debug {
|
||||
PErr(format, a...)
|
||||
}
|
||||
}
|
||||
|
||||
// DOut is a shorthand debug printing function to output to Stdout.
|
||||
// Will only print if Debug is true.
|
||||
func DOut(format string, a ...interface{}) {
|
||||
if Debug {
|
||||
POut(format, a...)
|
||||
}
|
||||
}
|
||||
|
||||
var loggers = map[string]*logging.Logger{}
|
||||
|
||||
// SetupLogging will initialize the logger backend and set the flags.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user