Monorepo for Tangled tangled.org
807
fork

Configure Feed

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

appview/settings: use structured logging #5

open opened by matias.tngl.sh targeting master from matias.tngl.sh/core: settings-structured-logging

Summary#

  • Replace 5 remaining log.Printf calls in appview/settings/settings.go with structured s.Logger.Error using key-value pairs.
  • Remove unused "log" import (the struct already has Logger *slog.Logger)
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:wtmr5brxfbwmb666krk4y75r/sh.tangled.repo.pull/3mk633r2g7722
+5 -6
Diff #0
+5 -6
appview/settings/settings.go
··· 6 6 "errors" 7 7 "fmt" 8 8 "html" 9 - "log" 10 9 "log/slog" 11 10 "net/http" 12 11 "net/url" ··· 262 261 263 262 punchcardPreferences, err := db.GetPunchcardPreference(s.Db, user.Did) 264 263 if err != nil { 265 - log.Printf("failed to get users punchcard preferences: %s", err) 264 + s.Logger.Error("failed to get punchcard preferences", "err", err) 266 265 } 267 266 268 267 isTnglSh, err := s.isTnglShUser(r.Context(), syntax.DID(user.Did)) ··· 751 750 "/settings/profile?handle=1", 752 751 ) 753 752 if err != nil { 754 - log.Printf("failed to start elevated auth flow: %s", err) 753 + s.Logger.Error("failed to start elevated auth flow", "err", err) 755 754 http.Redirect(w, r, "/settings/profile", http.StatusSeeOther) 756 755 return 757 756 } ··· 791 790 792 791 client, err := s.OAuth.AuthorizedClient(r) 793 792 if err != nil { 794 - log.Printf("failed to get authorized client: %s", err) 793 + s.Logger.Error("failed to get authorized client", "err", err) 795 794 s.Pages.Notice(w, "handle-error", "Failed to authorize. Try logging in again.") 796 795 return 797 796 } ··· 808 807 "/settings/profile?handle=1", 809 808 ) 810 809 if elevErr != nil { 811 - log.Printf("failed to start elevated auth flow: %s", elevErr) 810 + s.Logger.Error("failed to start elevated auth flow", "err", elevErr) 812 811 s.Pages.Notice(w, "handle-error", "Failed to start re-authorization. Try again later.") 813 812 return 814 813 } ··· 817 816 return 818 817 } 819 818 820 - log.Printf("failed to update handle: %s", err) 819 + s.Logger.Error("failed to update handle", "err", err) 821 820 msg := err.Error() 822 821 var apiErr *atclient.APIError 823 822 if errors.As(err, &apiErr) && apiErr.Message != "" {

History

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