@cryptotaxi247 / kubo / commits / 8e460d3fe

Restore go-log.Uuid() calls as loggables.Uuid() calls

License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>

Hector Sanjuan committed May 5, 2016 at 00:54 UTC 8e460d3fed05d0afe286676dc983c95b41640ad8
5 files changed +16 -1
cmd/ipfs/main.go
+2 -1
@@ -32,6 +32,7 @@ import (
32 repo "github.com/ipfs/go-ipfs/repo"
33 config "github.com/ipfs/go-ipfs/repo/config"
34 fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
35 + loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
36 )
37
38 // log is the command logger
@@ -66,7 +67,7 @@ type cmdInvocation struct {
67 func main() {
68 rand.Seed(time.Now().UnixNano())
69 runtime.GOMAXPROCS(3) // FIXME rm arbitrary choice for n
69 - ctx := context.Background()
70 + ctx := logging.ContextWithLoggable(context.Background(), loggables.Uuid("session"))
71 var err error
72 var invoc cmdInvocation
73 defer invoc.close()
exchange/bitswap/bitswap.go
+2
@@ -25,6 +25,7 @@ import (
25 wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
26 flags "github.com/ipfs/go-ipfs/flags"
27 "github.com/ipfs/go-ipfs/thirdparty/delay"
28 + loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
29 )
30
31 var log = logging.Logger("bitswap")
@@ -164,6 +165,7 @@ func (bs *Bitswap) GetBlock(parent context.Context, k key.Key) (*blocks.Block, e
165
166 ctx, cancelFunc := context.WithCancel(parent)
167
168 + ctx = logging.ContextWithLoggable(ctx, loggables.Uuid("GetBlockRequest"))
169 log.Event(ctx, "Bitswap.GetBlockRequest.Start", &k)
170 defer log.Event(ctx, "Bitswap.GetBlockRequest.End", &k)
171
routing/supernode/client.go
+2
@@ -16,6 +16,7 @@ import (
16 routing "github.com/ipfs/go-ipfs/routing"
17 pb "github.com/ipfs/go-ipfs/routing/dht/pb"
18 proxy "github.com/ipfs/go-ipfs/routing/supernode/proxy"
19 + loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
20 )
21
22 var log = logging.Logger("supernode")
@@ -38,6 +39,7 @@ func NewClient(px proxy.Proxy, h host.Host, ps peer.Peerstore, local peer.ID) (*
39 }
40
41 func (c *Client) FindProvidersAsync(ctx context.Context, k key.Key, max int) <-chan peer.PeerInfo {
42 + logging.ContextWithLoggable(ctx, loggables.Uuid("findProviders"))
43 defer log.EventBegin(ctx, "findProviders", &k).Done()
44 ch := make(chan peer.PeerInfo)
45 go func() {
routing/supernode/proxy/standard.go
+2
@@ -14,6 +14,7 @@ import (
14 key "github.com/ipfs/go-ipfs/blocks/key"
15 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
16 kbucket "github.com/ipfs/go-ipfs/routing/kbucket"
17 + loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
18 )
19
20 const ProtocolSNR = "/ipfs/supernoderouting"
@@ -159,6 +160,7 @@ func (px *standard) sendRequest(ctx context.Context, m *dhtpb.Message, remote pe
160 return nil, err
161 }
162 e.Append(logging.Pair("response", response))
163 + e.Append(logging.Pair("uuid", loggables.Uuid("foo")))
164 return response, nil
165 }
166
thirdparty/loggables/loggables.go
+8
@@ -9,6 +9,8 @@ package loggables
9 import (
10 "net"
11
12 + uuid "github.com/satori/go.uuid"
13 +
14 ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
15
16 logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
@@ -31,6 +33,12 @@ func Error(e error) logging.Loggable {
33 }
34 }
35
36 +func Uuid(key string) logging.Metadata {
37 + return logging.Metadata{
38 + key: uuid.NewV4().String(),
39 + }
40 +}
41 +
42 // Dial metadata is metadata for dial events
43 func Dial(sys string, lid, rid peer.ID, laddr, raddr ma.Multiaddr) DeferredMap {
44 m := DeferredMap{}