@@ -63,12 +63,13 @@ type whResponse struct {
6363func (wh * WebHooks ) Name () string { return "webhooks" }
6464
6565func (wh * WebHooks ) Init (ctx context.Context , config config.Section ) (err error ) {
66+ connID := fftypes .ShortID ()
6667 * wh = WebHooks {
67- ctx : ctx ,
68+ ctx : log . WithLogField ( ctx , "webhook" , wh . connID ) ,
6869 capabilities : & events.Capabilities {},
6970 callbacks : make (map [string ]events.Callbacks ),
7071 client : ffresty .New (ctx , config ),
71- connID : fftypes . ShortID () ,
72+ connID : connID ,
7273 }
7374 return nil
7475}
@@ -85,7 +86,9 @@ func (wh *WebHooks) Capabilities() *events.Capabilities {
8586
8687func (wh * WebHooks ) buildRequest (options fftypes.JSONObject , firstData fftypes.JSONObject ) (req * whRequest , err error ) {
8788 req = & whRequest {
88- r : wh .client .R ().SetDoNotParseResponse (true ),
89+ r : wh .client .R ().
90+ SetDoNotParseResponse (true ).
91+ SetContext (wh .ctx ),
8992 url : options .GetString ("url" ),
9093 method : options .GetString ("method" ),
9194 forceJSON : options .GetBool ("json" ),
@@ -223,8 +226,10 @@ func (wh *WebHooks) attemptRequest(sub *core.Subscription, event *core.EventDeli
223226 }
224227 }
225228
229+ log .L (wh .ctx ).Debugf ("Webhook-> %s %s event %s on subscription %s" , req .method , req .url , event .ID , sub .ID )
226230 resp , err := req .r .Execute (req .method , req .url )
227231 if err != nil {
232+ log .L (wh .ctx ).Errorf ("Webhook<-! %s %s event %s on subscription %s failed: %s" , req .method , req .url , event .ID , sub .ID , err )
228233 return nil , nil , err
229234 }
230235 defer func () { _ = resp .RawBody ().Close () }()
@@ -233,6 +238,7 @@ func (wh *WebHooks) attemptRequest(sub *core.Subscription, event *core.EventDeli
233238 Status : resp .StatusCode (),
234239 Headers : fftypes.JSONObject {},
235240 }
241+ log .L (wh .ctx ).Infof ("Webhook<- %s %s event %s on subscription %s returned %d" , req .method , req .url , event .ID , sub .ID , res .Status )
236242 header := resp .Header ()
237243 for h := range header {
238244 res .Headers [h ] = header .Get (h )
@@ -292,6 +298,7 @@ func (wh *WebHooks) doDelivery(connID string, reply bool, sub *core.Subscription
292298 txType = fftypes .FFEnum (strings .ToLower (req .replyTx ))
293299 }
294300 if cb , ok := wh .callbacks [sub .Namespace ]; ok {
301+ log .L (wh .ctx ).Tracef ("Sending reply message in response to webhook message %s" , event .Message .Header .ID )
295302 cb .DeliveryResponse (connID , & core.EventDeliveryResponse {
296303 ID : event .ID ,
297304 Rejected : false ,
0 commit comments