Compare commits

...

4 Commits

Author SHA1 Message Date
85ac5fb6f2 Show more internal information about pq error
All checks were successful
continuous-integration/drone/push Build is passing
2020-11-29 22:33:17 +01:00
cae5011ff0 Improve loggin for publishing 2020-11-29 22:22:26 +01:00
bcde001866 Fix typo 2020-11-29 22:19:39 +01:00
925fbfc476 Show date in log times 2020-11-29 22:19:19 +01:00
3 changed files with 10 additions and 5 deletions

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)
}

View File

@ -12,7 +12,7 @@ import (
)
func init() {
log.SetFlags(log.Ltime | log.Lshortfile)
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
}
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -33,7 +33,7 @@ type Stat struct {
func main() {
hostPort := flag.String("http", ":80", "host and port to listen on")
baseURL := flag.String("baseurl", "", "baseurl that the server should response with")
database := flag.String("database", "localhost:9999", "database hostpost")
database := flag.String("database", "localhost:9999", "database host:port")
flag.Parse()
log.Printf("Using arguments http=%s baseurl=%s database=%s", *hostPort, *baseURL, *database)

View File

@ -4,7 +4,8 @@ import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
"github.com/davecgh/go-spew/spew"
"github.com/lib/pq"
)
type postgres struct {
@ -31,6 +32,9 @@ func (s *postgres) Subscribe(topic string, sub Subscriber) error {
sub.LeaseSeconds,
sub.Secret,
)
if e, ok := err.(pq.Error); ok {
spew.Dump(e)
}
return err
}