Monorepo for Tangled tangled.org
771
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/issues: use structured logging in opengraph.go #9

Summary

  • Replace 5 log.Println calls in appview/issues/opengraph.go with rp.logger.Error using structured key-value pairs.
  • Remove unused "log" import β€” the Issues struct already has a *slog.Logger.
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:wtmr5brxfbwmb666krk4y75r/sh.tangled.repo.pull/3mkccbf2a6b22
+5 -6
Diff #0
+5 -6
appview/issues/opengraph.go
··· 3 3 import ( 4 4 "context" 5 5 "fmt" 6 - "log" 7 6 "net/http" 8 7 "time" 9 8 ··· 17 16 func (rp *Issues) IssueOpenGraphSummary(w http.ResponseWriter, r *http.Request) { 18 17 f, err := rp.repoResolver.Resolve(r) 19 18 if err != nil { 20 - log.Println("failed to get repo and knot", err) 19 + rp.logger.Error("failed to get repo and knot", "err", err) 21 20 return 22 21 } 23 22 24 23 issue, ok := r.Context().Value("issue").(*models.Issue) 25 24 if !ok { 26 - log.Println("issue not found in context") 25 + rp.logger.Error("issue not found in context") 27 26 http.Error(w, "issue not found", http.StatusNotFound) 28 27 return 29 28 } ··· 34 33 orm.FilterContains("scope", tangled.RepoIssueNSID), 35 34 ) 36 35 if err != nil { 37 - log.Println("failed to fetch label definitions") 36 + rp.logger.Error("failed to fetch label definitions", "err", err) 38 37 http.Error(w, "label definitions not found", http.StatusInternalServerError) 39 38 return 40 39 } ··· 100 99 101 100 imageBytes, err := rp.ogreClient.RenderIssueCard(r.Context(), payload) 102 101 if err != nil { 103 - log.Println("failed to render issue card", err) 102 + rp.logger.Error("failed to render issue card", "err", err) 104 103 http.Error(w, "failed to render issue card", http.StatusInternalServerError) 105 104 return 106 105 } ··· 110 109 w.WriteHeader(http.StatusOK) 111 110 _, err = w.Write(imageBytes) 112 111 if err != nil { 113 - log.Println("failed to write issue card", err) 112 + rp.logger.Error("failed to write issue card", "err", err) 114 113 return 115 114 } 116 115 }

History

1 round 0 comments
sign up or login to add to the discussion
matias.tngl.sh submitted #0
1 commit
expand
appview/issues: replace log.Println with structured logging in opengraph.go
merge conflicts detected
expand
  • appview/issues/opengraph.go:3
expand 0 comments