Improve loggin for publishing

This commit is contained in:
Peter Stuifzand 2020-11-29 22:22:26 +01:00
parent bcde001866
commit cae5011ff0

View File

@ -50,7 +50,7 @@ func (handler *subscriptionHandler) handlePublish(w http.ResponseWriter, r *http
}
for _, sub := range subs {
log.Printf("publish: creating post to %s\n", sub.Callback)
log.Printf("publish: preparing post to %s\n", sub.Callback)
postReq, err := http.NewRequest("POST", sub.Callback, strings.NewReader(string(feedContent)))
if err != nil {
log.Printf("could not creating request to %s: %s", sub.Callback, err)
@ -69,12 +69,13 @@ func (handler *subscriptionHandler) handlePublish(w http.ResponseWriter, r *http
signature := mac.Sum(nil)
postReq.Header.Add("X-Hub-Signature", fmt.Sprintf("sha1=%x", signature))
}
log.Printf("publish: send post to %s\n", sub.Callback)
postRes, err := client.Do(postReq)
if err != nil {
log.Printf("could not publish to %s: %s", sub.Callback, err)
continue
}
log.Printf("publish: post send to %s\n", sub.Callback)
log.Printf("publish: post sent to %s\n", sub.Callback)
log.Println("Response:")
_ = postRes.Write(os.Stdout)
}