Commit da21d99f authored by Brian Tiger Chow's avatar Brian Tiger Chow

log(dht) log a couple events to demonstrate API

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 9c553435
......@@ -18,6 +18,7 @@ import (
kb "github.com/jbenet/go-ipfs/routing/kbucket"
u "github.com/jbenet/go-ipfs/util"
ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
"github.com/jbenet/go-ipfs/util/elog"
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
......@@ -25,7 +26,7 @@ import (
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
var log = u.Logger("dht")
var log = elog.Logger("dht")
const doPinging = false
......@@ -152,6 +153,7 @@ func (dht *IpfsDHT) HandleMessage(ctx context.Context, mes msg.NetMessage) msg.N
dht.Update(mPeer)
// Print out diagnostic
log.Event(ctx, "foo", dht.self, mPeer, pmes)
log.Debugf("%s got message type: '%s' from %s",
dht.self, pb.Message_MessageType_name[int32(pmes.GetType())], mPeer)
......@@ -197,6 +199,7 @@ func (dht *IpfsDHT) sendRequest(ctx context.Context, p peer.Peer, pmes *pb.Messa
start := time.Now()
// Print out diagnostic
log.Event(ctx, "sentMessage", dht.self, p, pmes)
log.Debugf("Sent message type: '%s' to %s",
pb.Message_MessageType_name[int32(pmes.GetType())], p)
......
......@@ -65,3 +65,11 @@ func (m *Message) SetClusterLevel(level int) {
lvl := int32(level)
m.ClusterLevelRaw = &lvl
}
func (m *Message) Loggable() map[string]interface{} {
return map[string]interface{}{
"message": map[string]string{
"type": m.Type.String(),
},
}
}
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