@@ -62,14 +62,14 @@ func (p *BroadcastProcessor) handle(msg Content) {
62
62
msg .ReceiveChan <- shardResponse {
63
63
err : OutOfOrderErr {},
64
64
}
65
- p .log ("msg: out of order" , "err" , OutOfOrderErr {}, "method" , msg .CurrentMethod , "from" , msg .SenderAddr )
65
+ p .log ("msg: out of order" , OutOfOrderErr {}, "method" , msg .CurrentMethod , "from" , msg .SenderAddr )
66
66
} else {
67
67
msg .ReceiveChan <- shardResponse {
68
68
err : nil ,
69
69
reqCtx : p .cancellationCtx ,
70
70
enqueueBroadcast : p .enqueueBroadcast ,
71
71
}
72
- p .log ("msg: processed" , "err" , nil , "method" , msg .CurrentMethod , "from" , msg .SenderAddr )
72
+ p .log ("msg: processed" , nil , "method" , msg .CurrentMethod , "from" , msg .SenderAddr )
73
73
}
74
74
}
75
75
defer func () {
@@ -83,15 +83,15 @@ func (p *BroadcastProcessor) handle(msg Content) {
83
83
//close(p.broadcastChan)
84
84
//close(p.sendChan)
85
85
p .emptyChannels (metadata )
86
- p .log ("processor stopped" , "err" , nil , "started" , p .started , "ended" , p .ended )
86
+ p .log ("processor stopped" , nil , "started" , p .started , "ended" , p .ended )
87
87
}()
88
88
for {
89
89
select {
90
90
case <- p .ctx .Done ():
91
91
return
92
92
case bMsg := <- p .broadcastChan :
93
93
if p .broadcastID != bMsg .BroadcastID {
94
- p .log ("broadcast: wrong BroadcastID" , "err" , BroadcastIDErr {}, "type" , bMsg .MsgType .String (), "stopping" , false )
94
+ p .log ("broadcast: wrong BroadcastID" , BroadcastIDErr {}, "type" , bMsg .MsgType .String (), "stopping" , false )
95
95
continue
96
96
}
97
97
switch bMsg .MsgType {
@@ -116,7 +116,7 @@ func (p *BroadcastProcessor) handle(msg Content) {
116
116
new .ReceiveChan <- shardResponse {
117
117
err : BroadcastIDErr {},
118
118
}
119
- p .log ("msg: wrong BroadcastID" , "err" , BroadcastIDErr {}, "method" , new .CurrentMethod , "from" , new .SenderAddr )
119
+ p .log ("msg: wrong BroadcastID" , BroadcastIDErr {}, "method" , new .CurrentMethod , "from" , new .SenderAddr )
120
120
continue
121
121
}
122
122
if new .IsCancellation {
@@ -126,7 +126,7 @@ func (p *BroadcastProcessor) handle(msg Content) {
126
126
new .ReceiveChan <- shardResponse {
127
127
err : nil ,
128
128
}
129
- p .log ("msg: received cancellation" , "err" , nil , "method" , new .CurrentMethod , "from" , new .SenderAddr )
129
+ p .log ("msg: received cancellation" , nil , "method" , new .CurrentMethod , "from" , new .SenderAddr )
130
130
continue
131
131
}
132
132
@@ -137,7 +137,7 @@ func (p *BroadcastProcessor) handle(msg Content) {
137
137
new .ReceiveChan <- shardResponse {
138
138
err : ClientReqAlreadyReceivedErr {},
139
139
}
140
- p .log ("msg: duplicate client req" , "err" , ClientReqAlreadyReceivedErr {}, "method" , new .CurrentMethod , "from" , new .SenderAddr )
140
+ p .log ("msg: duplicate client req" , ClientReqAlreadyReceivedErr {}, "method" , new .CurrentMethod , "from" , new .SenderAddr )
141
141
continue
142
142
}
143
143
// important to set this option to prevent duplicate client reqs.
@@ -155,7 +155,7 @@ func (p *BroadcastProcessor) handle(msg Content) {
155
155
}
156
156
p .cancellationCtxCancel ()
157
157
}()
158
- p .log ("msg: received client req" , "err" , nil , "method" , new .CurrentMethod , "from" , new .SenderAddr )
158
+ p .log ("msg: received client req" , nil , "method" , new .CurrentMethod , "from" , new .SenderAddr )
159
159
}
160
160
161
161
metadata .update (new )
@@ -174,7 +174,7 @@ func (p *BroadcastProcessor) handle(msg Content) {
174
174
err : err ,
175
175
}
176
176
// slog.Info("receive: late", "err", err, "id", p.broadcastID)
177
- p .log ("msg: late msg" , "err" , err , "method" , new .CurrentMethod , "from" , new .SenderAddr )
177
+ p .log ("msg: late msg" , err , "method" , new .CurrentMethod , "from" , new .SenderAddr )
178
178
return
179
179
}
180
180
if ! p .isInOrder (new .CurrentMethod ) {
@@ -183,26 +183,26 @@ func (p *BroadcastProcessor) handle(msg Content) {
183
183
new .ReceiveChan <- shardResponse {
184
184
err : OutOfOrderErr {},
185
185
}
186
- p .log ("msg: out of order" , "err" , OutOfOrderErr {}, "method" , new .CurrentMethod , "from" , new .SenderAddr )
186
+ p .log ("msg: out of order" , OutOfOrderErr {}, "method" , new .CurrentMethod , "from" , new .SenderAddr )
187
187
continue
188
188
}
189
189
new .ReceiveChan <- shardResponse {
190
190
err : nil ,
191
191
reqCtx : p .cancellationCtx ,
192
192
enqueueBroadcast : p .enqueueBroadcast ,
193
193
}
194
- p .log ("msg: processed" , "err" , nil , "method" , new .CurrentMethod , "from" , new .SenderAddr )
194
+ p .log ("msg: processed" , nil , "method" , new .CurrentMethod , "from" , new .SenderAddr )
195
195
}
196
196
}
197
197
}
198
198
199
199
func (p * BroadcastProcessor ) handleCancellation (bMsg Msg , metadata * metadata ) bool {
200
200
if bMsg .Cancellation .end {
201
- p .log ("broadcast: broadcast.Done() called" , "err" , nil , "type" , bMsg .MsgType .String (), "stopping" , true )
201
+ p .log ("broadcast: broadcast.Done() called" , nil , "type" , bMsg .MsgType .String (), "stopping" , true )
202
202
return true
203
203
}
204
204
if ! metadata .SentCancellation {
205
- p .log ("broadcast: sent cancellation" , "err" , nil , "type" , bMsg .MsgType .String (), "stopping" , false )
205
+ p .log ("broadcast: sent cancellation" , nil , "type" , bMsg .MsgType .String (), "stopping" , false )
206
206
metadata .SentCancellation = true
207
207
go p .router .Send (p .broadcastID , "" , "" , bMsg .Cancellation )
208
208
}
@@ -216,16 +216,22 @@ func (p *BroadcastProcessor) handleBroadcast(bMsg Msg, methods []string, metadat
216
216
return false
217
217
}
218
218
p .router .Send (p .broadcastID , metadata .OriginAddr , metadata .OriginMethod , bMsg .Msg )
219
- p .log ("broadcast: sending broadcast" , "err" , nil , "type" , bMsg .MsgType .String (), "stopping" , false , "isBroadcastCall" , metadata .isBroadcastCall ())
219
+ p .log ("broadcast: sending broadcast" , nil , "type" , bMsg .MsgType .String (), "method" , bMsg . Method , "stopping" , false , "isBroadcastCall" , metadata .isBroadcastCall ())
220
220
221
221
p .updateOrder (bMsg .Method )
222
222
p .dispatchOutOfOrderMsgs ()
223
223
return true
224
224
}
225
225
226
- func (p * BroadcastProcessor ) log (msg string , args ... any ) {
226
+ func (p * BroadcastProcessor ) log (msg string , err error , args ... any ) {
227
227
if p .logger != nil {
228
- p .logger .Debug (msg , args ... )
228
+ if err != nil {
229
+ args = append (args , "err" , err .Error ())
230
+ p .logger .Error (msg , args ... )
231
+ } else {
232
+ args = append (args , "err" , nil )
233
+ p .logger .Info (msg , args ... )
234
+ }
229
235
}
230
236
}
231
237
@@ -234,7 +240,7 @@ func (p *BroadcastProcessor) handleReply(bMsg Msg, metadata *metadata) bool {
234
240
if metadata .isBroadcastCall () {
235
241
go p .router .Send (p .broadcastID , metadata .OriginAddr , metadata .OriginMethod , bMsg .Reply )
236
242
// the request is done becuase we have sent a reply to the client
237
- p .log ("broadcast: sending reply to client" , "err" , nil , "type" , bMsg .MsgType .String (), "stopping" , true , "isBroadcastCall" , metadata .isBroadcastCall ())
243
+ p .log ("broadcast: sending reply to client" , nil , "type" , bMsg .MsgType .String (), "stopping" , true , "isBroadcastCall" , metadata .isBroadcastCall ())
238
244
return true
239
245
}
240
246
// QuorumCall if origin addr is empty.
@@ -254,11 +260,11 @@ func (p *BroadcastProcessor) handleReply(bMsg Msg, metadata *metadata) bool {
254
260
// the request is not done yet because we have not replied to
255
261
// the client.
256
262
//slog.Info("reply: late", "err", err, "id", p.broadcastID)
257
- p .log ("broadcast: failed to send reply to client" , "err" , err , "type" , bMsg .MsgType .String (), "stopping" , false , "isBroadcastCall" , metadata .isBroadcastCall ())
263
+ p .log ("broadcast: failed to send reply to client" , err , "type" , bMsg .MsgType .String (), "stopping" , false , "isBroadcastCall" , metadata .isBroadcastCall ())
258
264
return false
259
265
}
260
266
// the request is done becuase we have sent a reply to the client
261
- p .log ("broadcast: sending reply to client" , "err" , err , "type" , bMsg .MsgType .String (), "stopping" , true , "isBroadcastCall" , metadata .isBroadcastCall ())
267
+ p .log ("broadcast: sending reply to client" , err , "type" , bMsg .MsgType .String (), "stopping" , true , "isBroadcastCall" , metadata .isBroadcastCall ())
262
268
return true
263
269
}
264
270
@@ -419,7 +425,7 @@ func (r *BroadcastProcessor) dispatchOutOfOrderMsgs() {
419
425
if order <= r .orderIndex {
420
426
for _ , msg := range msgs {
421
427
msg .Run (r .cancellationCtx , r .enqueueBroadcast )
422
- r .log ("msg: dispatching out of order msg" , "err" , nil , "method" , msg .CurrentMethod , "from" , msg .SenderAddr )
428
+ r .log ("msg: dispatching out of order msg" , nil , "method" , msg .CurrentMethod , "from" , msg .SenderAddr )
423
429
}
424
430
handledMethods = append (handledMethods , method )
425
431
}
0 commit comments