提交 8e460d3f 作者: Hector Sanjuan

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

License: MIT
Signed-off-by: 's avatarHector Sanjuan <code@hector.link>
上级 fba14485
......@@ -32,6 +32,7 @@ import (
repo "github.com/ipfs/go-ipfs/repo"
config "github.com/ipfs/go-ipfs/repo/config"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
)
// log is the command logger
......@@ -66,7 +67,7 @@ type cmdInvocation struct {
func main() {
rand.Seed(time.Now().UnixNano())
runtime.GOMAXPROCS(3) // FIXME rm arbitrary choice for n
ctx := context.Background()
ctx := logging.ContextWithLoggable(context.Background(), loggables.Uuid("session"))
var err error
var invoc cmdInvocation
defer invoc.close()
......
......@@ -25,6 +25,7 @@ import (
wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
flags "github.com/ipfs/go-ipfs/flags"
"github.com/ipfs/go-ipfs/thirdparty/delay"
loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
)
var log = logging.Logger("bitswap")
......@@ -164,6 +165,7 @@ func (bs *Bitswap) GetBlock(parent context.Context, k key.Key) (*blocks.Block, e
ctx, cancelFunc := context.WithCancel(parent)
ctx = logging.ContextWithLoggable(ctx, loggables.Uuid("GetBlockRequest"))
log.Event(ctx, "Bitswap.GetBlockRequest.Start", &k)
defer log.Event(ctx, "Bitswap.GetBlockRequest.End", &k)
......
......@@ -16,6 +16,7 @@ import (
routing "github.com/ipfs/go-ipfs/routing"
pb "github.com/ipfs/go-ipfs/routing/dht/pb"
proxy "github.com/ipfs/go-ipfs/routing/supernode/proxy"
loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
)
var log = logging.Logger("supernode")
......@@ -38,6 +39,7 @@ func NewClient(px proxy.Proxy, h host.Host, ps peer.Peerstore, local peer.ID) (*
}
func (c *Client) FindProvidersAsync(ctx context.Context, k key.Key, max int) <-chan peer.PeerInfo {
logging.ContextWithLoggable(ctx, loggables.Uuid("findProviders"))
defer log.EventBegin(ctx, "findProviders", &k).Done()
ch := make(chan peer.PeerInfo)
go func() {
......
......@@ -14,6 +14,7 @@ import (
key "github.com/ipfs/go-ipfs/blocks/key"
dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
kbucket "github.com/ipfs/go-ipfs/routing/kbucket"
loggables "github.com/ipfs/go-ipfs/thirdparty/loggables"
)
const ProtocolSNR = "/ipfs/supernoderouting"
......@@ -159,6 +160,7 @@ func (px *standard) sendRequest(ctx context.Context, m *dhtpb.Message, remote pe
return nil, err
}
e.Append(logging.Pair("response", response))
e.Append(logging.Pair("uuid", loggables.Uuid("foo")))
return response, nil
}
......
......@@ -9,6 +9,8 @@ package loggables
import (
"net"
uuid "github.com/satori/go.uuid"
ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log"
......@@ -31,6 +33,12 @@ func Error(e error) logging.Loggable {
}
}
func Uuid(key string) logging.Metadata {
return logging.Metadata{
key: uuid.NewV4().String(),
}
}
// Dial metadata is metadata for dial events
func Dial(sys string, lid, rid peer.ID, laddr, raddr ma.Multiaddr) DeferredMap {
m := DeferredMap{}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论