From c0e20780391743a2665a82b78eede7a88d44b0d6 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 16 Apr 2023 21:50:57 +0200 Subject: [PATCH] Add logging --- sn.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sn.go b/sn.go index 036cf7a..a4bffb8 100644 --- a/sn.go +++ b/sn.go @@ -118,6 +118,7 @@ func FetchStackerNewsDupes(url string) *[]Dupe { func PostStoryToStackerNews(story *Story) { dupes := FetchStackerNewsDupes(story.Url) if len(*dupes) > 0 { + log.Printf("%s was already posted. Skipping.\n", story.Url) return } @@ -141,8 +142,10 @@ func PostStoryToStackerNews(story *Story) { if err != nil { log.Fatal("Error decoding dupes JSON:", err) } - parentId := upsertLinkResp.Data.UpsertLink.Id + + log.Printf("Created new post on SN: id=%d url=%s\n", parentId, story.Url) + comment := fmt.Sprintf( "This link was posted by [%s](%s) %s on [HN](%s). It received %d points and %d comments.", story.By, @@ -152,6 +155,9 @@ func PostStoryToStackerNews(story *Story) { story.Score, story.Descendants, ) CommentStackerNewsPost(comment, parentId) + + log.Printf("Commented post on SN: parentId=%d text='%s'\n", parentId, comment) + } func CommentStackerNewsPost(text string, parentId int) {