@@ -87,7 +87,7 @@ func (wh *WebHooks) Init(ctx context.Context, config config.Section) (err error)
8787 client := ffresty .NewWithConfig (ctx , * ffrestyConfig )
8888
8989 * wh = WebHooks {
90- ctx : log .WithLogField (ctx , "webhook" , wh . connID ),
90+ ctx : log .WithLogField (ctx , "webhook" , connID ),
9191 capabilities : & events.Capabilities {
9292 BatchDelivery : true ,
9393 },
@@ -139,7 +139,7 @@ func (p *whPayload) firstData() fftypes.JSONObject {
139139}
140140
141141func (wh * WebHooks ) buildPayload (ctx context.Context , sub * core.Subscription , event * core.CombinedEventDataDelivery ) * whPayload {
142- log .L (wh . ctx ).Debugf ("Webhook-> %s event %s on subscription %s" , sub .Options .URL , event .Event .ID , sub .ID )
142+ log .L (ctx ).Debugf ("Webhook-> %s event %s on subscription %s" , sub .Options .URL , event .Event .ID , sub .ID )
143143 withData := sub .Options .WithData != nil && * sub .Options .WithData
144144 options := sub .Options .TransportOptions ()
145145 p := & whPayload {
@@ -402,7 +402,7 @@ func (wh *WebHooks) attemptRequest(ctx context.Context, sub *core.Subscription,
402402 Status : resp .StatusCode (),
403403 Headers : fftypes.JSONObject {},
404404 }
405- log .L (wh . ctx ).Debugf ("Webhook<- %s %s on subscription %s returned %d" , req .method , req .url , sub .ID , res .Status )
405+ log .L (ctx ).Debugf ("Webhook<- %s %s on subscription %s returned %d" , req .method , req .url , sub .ID , res .Status )
406406 header := resp .Header ()
407407 for h := range header {
408408 res .Headers [h ] = header .Get (h )
@@ -440,7 +440,7 @@ func (wh *WebHooks) doDelivery(ctx context.Context, connID string, reply bool, s
440440 if gwErr != nil {
441441 // Generate a bad-gateway error response - we always want to send something back,
442442 // rather than just causing timeouts
443- log .L (wh . ctx ).Errorf ("Failed to invoke webhook: %s" , gwErr )
443+ log .L (ctx ).Errorf ("Failed to invoke webhook: %s on subscription %s " , gwErr , sub . ID )
444444 b , _ := json .Marshal (& fftypes.RESTError {
445445 Error : gwErr .Error (),
446446 })
@@ -453,7 +453,7 @@ func (wh *WebHooks) doDelivery(ctx context.Context, connID string, reply bool, s
453453 }
454454 }
455455 b , _ := json .Marshal (& res )
456- log .L (wh . ctx ).Tracef ("Webhook response: %s" , string (b ))
456+ log .L (ctx ).Tracef ("Webhook response: %s for subscription %s " , string (b ), sub . ID )
457457
458458 // For each event emit a response
459459 for _ , combinedEvent := range events {
@@ -465,7 +465,7 @@ func (wh *WebHooks) doDelivery(ctx context.Context, connID string, reply bool, s
465465 txType = fftypes .FFEnum (strings .ToLower (req .replyTx ))
466466 }
467467 if cb , ok := wh .callbacks .handlers [sub .Namespace ]; ok {
468- log .L (wh . ctx ).Debugf ("Sending reply message for %s CID=%s" , event .ID , event .Message .Header .ID )
468+ log .L (ctx ).Debugf ("Sending reply message for %s CID=%s" , event .ID , event .Message .Header .ID )
469469 cb .DeliveryResponse (connID , & core.EventDeliveryResponse {
470470 ID : event .ID ,
471471 Rejected : false ,
@@ -501,12 +501,13 @@ func (wh *WebHooks) doDelivery(ctx context.Context, connID string, reply bool, s
501501}
502502
503503func (wh * WebHooks ) DeliveryRequest (ctx context.Context , connID string , sub * core.Subscription , event * core.EventDelivery , data core.DataArray ) error {
504+ ctx = log .WithLogField (ctx , "webhook" , wh .connID )
504505 reply := sub .Options .TransportOptions ().GetBool ("reply" )
505506 if reply && event .Message != nil && event .Message .Header .CID != nil {
506507 // We cowardly refuse to dispatch a message that is itself a reply, as it's hard for users to
507508 // avoid loops - and there's no way for us to detect here if a user has configured correctly
508509 // to avoid a loop.
509- log .L (wh . ctx ).Debugf ("Webhook subscription with reply enabled called with reply event '%s'" , event .ID )
510+ log .L (ctx ).Debugf ("Webhook subscription with reply enabled called with reply event '%s'" , event .ID )
510511 if cb , ok := wh .callbacks .handlers [sub .Namespace ]; ok {
511512 cb .DeliveryResponse (connID , & core.EventDeliveryResponse {
512513 ID : event .ID ,
@@ -540,6 +541,7 @@ func (wh *WebHooks) DeliveryRequest(ctx context.Context, connID string, sub *cor
540541}
541542
542543func (wh * WebHooks ) BatchDeliveryRequest (ctx context.Context , connID string , sub * core.Subscription , events []* core.CombinedEventDataDelivery ) error {
544+ ctx = log .WithLogField (ctx , "webhook" , wh .connID )
543545 reply := sub .Options .TransportOptions ().GetBool ("reply" )
544546 if reply {
545547 nonReplyEvents := []* core.CombinedEventDataDelivery {}
@@ -549,7 +551,7 @@ func (wh *WebHooks) BatchDeliveryRequest(ctx context.Context, connID string, sub
549551 // avoid loops - and there's no way for us to detect here if a user has configured correctly
550552 // to avoid a loop.
551553 if event .Message != nil && event .Message .Header .CID != nil {
552- log .L (wh . ctx ).Debugf ("Webhook subscription with reply enabled called with reply event '%s'" , event .ID )
554+ log .L (ctx ).Debugf ("Webhook subscription with reply enabled called with reply event '%s'" , event .ID )
553555 if cb , ok := wh .callbacks .handlers [sub .Namespace ]; ok {
554556 cb .DeliveryResponse (connID , & core.EventDeliveryResponse {
555557 ID : event .ID ,
0 commit comments