Improve logging

This commit is contained in:
ekzyis 2023-04-17 18:55:08 +02:00
parent 62af7cb4b4
commit c4d917bada
1 changed files with 5 additions and 3 deletions

8
sn.go
View File

@ -170,7 +170,8 @@ func PostStoryToStackerNews(story *Story) {
} }
parentId := upsertLinkResp.Data.UpsertLink.Id parentId := upsertLinkResp.Data.UpsertLink.Id
log.Printf("Created new post on SN: id=%d url=%s\n", parentId, story.Url) log.Println("Created new post on SN")
log.Printf("id=%d title='%s' url=%s\n", parentId, story.Title, story.Url)
comment := fmt.Sprintf( comment := fmt.Sprintf(
"This link was posted by [%s](%s) %s on [HN](%s). It received %d points and %d comments.", "This link was posted by [%s](%s) %s on [HN](%s). It received %d points and %d comments.",
@ -181,8 +182,6 @@ func PostStoryToStackerNews(story *Story) {
story.Score, story.Descendants, story.Score, story.Descendants,
) )
CommentStackerNewsPost(comment, parentId) CommentStackerNewsPost(comment, parentId)
log.Printf("Commented post on SN: parentId=%d text='%s'\n", parentId, comment)
} }
func CommentStackerNewsPost(text string, parentId int) { func CommentStackerNewsPost(text string, parentId int) {
@ -200,6 +199,9 @@ func CommentStackerNewsPost(text string, parentId int) {
} }
resp := MakeStackerNewsRequest(body) resp := MakeStackerNewsRequest(body)
defer resp.Body.Close() defer resp.Body.Close()
log.Println("Commented post on SN")
log.Printf("text='%s' parentId=%d\n", text, parentId)
} }
func FetchStackerNewsUserItems(user string) *[]Item { func FetchStackerNewsUserItems(user string) *[]Item {