8
8
bsmsg "github.com/ipfs/go-bitswap/message"
9
9
pb "github.com/ipfs/go-bitswap/message/pb"
10
10
cid "github.com/ipfs/go-cid"
11
- logging "github.com/ipfs/go-log"
12
11
process "github.com/jbenet/goprocess"
13
12
procctx "github.com/jbenet/goprocess/context"
14
13
)
@@ -41,10 +40,10 @@ func (bs *Bitswap) startWorkers(ctx context.Context, px process.Process) {
41
40
}
42
41
43
42
func (bs * Bitswap ) taskWorker (ctx context.Context , id int ) {
44
- idmap := logging.LoggableMap {"ID" : id }
45
43
defer log .Debug ("bitswap task worker shutting down..." )
44
+ log := log .With ("ID" , id )
46
45
for {
47
- log .Event ( ctx , "Bitswap.TaskWorker.Loop" , idmap )
46
+ log .Debug ( "Bitswap.TaskWorker.Loop" )
48
47
select {
49
48
case nextEnvelope := <- bs .engine .Outbox ():
50
49
select {
@@ -57,13 +56,10 @@ func (bs *Bitswap) taskWorker(ctx context.Context, id int) {
57
56
// TODO: Should only track *useful* messages in ledger
58
57
outgoing := bsmsg .New (false )
59
58
for _ , block := range envelope .Message .Blocks () {
60
- log .Event (ctx , "Bitswap.TaskWorker.Work" , logging .LoggableF (func () map [string ]interface {} {
61
- return logging.LoggableMap {
62
- "ID" : id ,
63
- "Target" : envelope .Peer .Pretty (),
64
- "Block" : block .Cid ().String (),
65
- }
66
- }))
59
+ log .Debugw ("Bitswap.TaskWorker.Work" ,
60
+ "Target" , envelope .Peer ,
61
+ "Block" , block .Cid (),
62
+ )
67
63
outgoing .AddBlock (block )
68
64
}
69
65
for _ , blockPresence := range envelope .Message .BlockPresences () {
@@ -143,9 +139,9 @@ func (bs *Bitswap) provideWorker(px process.Process) {
143
139
// replace token when done
144
140
<- limit
145
141
}()
146
- ev := logging.LoggableMap {"ID" : wid }
147
142
148
- defer log .EventBegin (ctx , "Bitswap.ProvideWorker.Work" , ev , k ).Done ()
143
+ log .Debugw ("Bitswap.ProvideWorker.Start" , "ID" , wid , "cid" , k )
144
+ defer log .Debugw ("Bitswap.ProvideWorker.End" , "ID" , wid , "cid" , k )
149
145
150
146
ctx , cancel := context .WithTimeout (ctx , provideTimeout ) // timeout ctx
151
147
defer cancel ()
@@ -158,8 +154,7 @@ func (bs *Bitswap) provideWorker(px process.Process) {
158
154
// worker spawner, reads from bs.provideKeys until it closes, spawning a
159
155
// _ratelimited_ number of workers to handle each key.
160
156
for wid := 2 ; ; wid ++ {
161
- ev := logging.LoggableMap {"ID" : 1 }
162
- log .Event (ctx , "Bitswap.ProvideWorker.Loop" , ev )
157
+ log .Debug ("Bitswap.ProvideWorker.Loop" )
163
158
164
159
select {
165
160
case <- px .Closing ():
0 commit comments