Commit f62acec4 authored by Juan Benet's avatar Juan Benet

Merge pull request #1701 from ipfs/feat/extract-logging

extract logging
parents 2d917bab d7ed6e95
......@@ -22,10 +22,10 @@ import (
wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
peer "github.com/ipfs/go-ipfs/p2p/peer"
"github.com/ipfs/go-ipfs/thirdparty/delay"
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)
var log = eventlog.Logger("bitswap")
var log = logging.Logger("bitswap")
const (
// maxProvidersPerRequest specifies the maximum number of providers desired
......@@ -151,7 +151,7 @@ func (bs *Bitswap) GetBlock(parent context.Context, k key.Key) (*blocks.Block, e
ctx, cancelFunc := context.WithCancel(parent)
ctx = eventlog.ContextWithLoggable(ctx, eventlog.Uuid("GetBlockRequest"))
ctx = logging.ContextWithLoggable(ctx, logging.Uuid("GetBlockRequest"))
log.Event(ctx, "Bitswap.GetBlockRequest.Start", &k)
defer log.Event(ctx, "Bitswap.GetBlockRequest.End", &k)
......
......@@ -10,7 +10,7 @@ import (
bsmsg "github.com/ipfs/go-ipfs/exchange/bitswap/message"
wl "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
peer "github.com/ipfs/go-ipfs/p2p/peer"
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)
// TODO consider taking responsibility for other types of requests. For
......@@ -43,7 +43,7 @@ import (
// whatever it sees fit to produce desired outcomes (get wanted keys
// quickly, maintain good relationships with peers, etc).
var log = eventlog.Logger("engine")
var log = logging.Logger("engine")
const (
// outboxChanBuffer must be 0 to prevent stale messages from being sent
......
......@@ -9,10 +9,10 @@ import (
inet "github.com/ipfs/go-ipfs/p2p/net"
peer "github.com/ipfs/go-ipfs/p2p/peer"
routing "github.com/ipfs/go-ipfs/routing"
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)
var log = eventlog.Logger("bitswap_network")
var log = logging.Logger("bitswap_network")
// NewFromIpfsHost returns a BitSwapNetwork supported by underlying IPFS host
func NewFromIpfsHost(host host.Host, r routing.IpfsRouting) BitSwapNetwork {
......
......@@ -9,7 +9,7 @@ import (
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key "github.com/ipfs/go-ipfs/blocks/key"
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0"
)
var TaskWorkerCount = 8
......@@ -45,7 +45,7 @@ func (bs *Bitswap) startWorkers(px process.Process, ctx context.Context) {
}
func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
idmap := eventlog.LoggableMap{"ID": id}
idmap := logging.LoggableMap{"ID": id}
defer log.Info("bitswap task worker shutting down...")
for {
log.Event(ctx, "Bitswap.TaskWorker.Loop", idmap)
......@@ -56,7 +56,7 @@ func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
if !ok {
continue
}
log.Event(ctx, "Bitswap.TaskWorker.Work", eventlog.LoggableMap{
log.Event(ctx, "Bitswap.TaskWorker.Work", logging.LoggableMap{
"ID": id,
"Target": envelope.Peer.Pretty(),
"Block": envelope.Block.Multihash.B58String(),
......@@ -77,7 +77,7 @@ func (bs *Bitswap) provideWorker(px process.Process) {
limiter := ratelimit.NewRateLimiter(px, provideWorkerMax)
limitedGoProvide := func(k key.Key, wid int) {
ev := eventlog.LoggableMap{"ID": wid}
ev := logging.LoggableMap{"ID": wid}
limiter.LimitedGo(func(px process.Process) {
ctx := procctx.OnClosingContext(px) // derive ctx from px
......@@ -96,7 +96,7 @@ func (bs *Bitswap) provideWorker(px process.Process) {
// _ratelimited_ number of workers to handle each key.
limiter.Go(func(px process.Process) {
for wid := 2; ; wid++ {
ev := eventlog.LoggableMap{"ID": 1}
ev := logging.LoggableMap{"ID": 1}
log.Event(procctx.OnClosingContext(px), "Bitswap.ProvideWorker.Loop", ev)
select {
......@@ -158,7 +158,7 @@ func (bs *Bitswap) providerConnector(parent context.Context) {
log.Warning("Received batch request for zero blocks")
continue
}
log.Event(parent, "Bitswap.ProviderConnector.Work", eventlog.LoggableMap{"Keys": keys})
log.Event(parent, "Bitswap.ProviderConnector.Work", logging.LoggableMap{"Keys": keys})
// NB: Optimization. Assumes that providers of key[0] are likely to
// be able to provide for all keys. This currently holds true in most
......
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