back interdiff of round #1 and #0

appview: improve the logging situation a bit #654

closed
opened by oppi.li targeting master from push-nsovyllpxlwk

needs a lot more work, but we now inject slog in several places.

Signed-off-by: oppiliappan me@oppi.li

files
appview
cmd
appview
spindle
jetstream
nix
xrpc
serviceauth
ERROR
appview/db/db.go

Failed to calculate interdiff for this file.

ERROR
appview/ingester.go

Failed to calculate interdiff for this file.

ERROR
appview/issues/issues.go

Failed to calculate interdiff for this file.

ERROR
appview/labels/labels.go

Failed to calculate interdiff for this file.

ERROR
appview/notifications/notifications.go

Failed to calculate interdiff for this file.

ERROR
appview/pages/pages.go

Failed to calculate interdiff for this file.

ERROR
appview/pipelines/pipelines.go

Failed to calculate interdiff for this file.

ERROR
appview/pulls/pulls.go

Failed to calculate interdiff for this file.

ERROR
appview/repo/index.go

Failed to calculate interdiff for this file.

ERROR
appview/repo/repo.go

Failed to calculate interdiff for this file.

ERROR
appview/signup/signup.go

Failed to calculate interdiff for this file.

ERROR
appview/state/knotstream.go

Failed to calculate interdiff for this file.

ERROR
appview/state/router.go

Failed to calculate interdiff for this file.

ERROR
appview/state/spindlestream.go

Failed to calculate interdiff for this file.

ERROR
appview/state/state.go

Failed to calculate interdiff for this file.

ERROR
cmd/appview/main.go

Failed to calculate interdiff for this file.

ERROR
go.mod

Failed to calculate interdiff for this file.

ERROR
go.sum

Failed to calculate interdiff for this file.

ERROR
jetstream/jetstream.go

Failed to calculate interdiff for this file.

ERROR
nix/gomod2nix.toml

Failed to calculate interdiff for this file.

ERROR
xrpc/serviceauth/service_auth.go

Failed to calculate interdiff for this file.

NEW
appview/state/login.go
··· 2 3 import ( 4 "fmt" 5 - "log" 6 "net/http" 7 "strings" 8 ··· 10 ) 11 12 func (s *State) Login(w http.ResponseWriter, r *http.Request) { 13 switch r.Method { 14 case http.MethodGet: 15 returnURL := r.URL.Query().Get("return_url") ··· 32 33 // basic handle validation 34 if !strings.Contains(handle, ".") { 35 - log.Println("invalid handle format", "raw", handle) 36 s.pages.Notice( 37 w, 38 "login-msg", ··· 52 } 53 54 func (s *State) Logout(w http.ResponseWriter, r *http.Request) { 55 err := s.oauth.DeleteSession(w, r) 56 if err != nil { 57 - log.Println("failed to logout", "err", err) 58 } else { 59 - log.Println("logged out successfully") 60 } 61 62 s.pages.HxRedirect(w, "/login")
··· 2 3 import ( 4 "fmt" 5 "net/http" 6 "strings" 7 ··· 9 ) 10 11 func (s *State) Login(w http.ResponseWriter, r *http.Request) { 12 + l := s.logger.With("handler", "Login") 13 + 14 switch r.Method { 15 case http.MethodGet: 16 returnURL := r.URL.Query().Get("return_url") ··· 33 34 // basic handle validation 35 if !strings.Contains(handle, ".") { 36 + l.Error("invalid handle format", "raw", handle) 37 s.pages.Notice( 38 w, 39 "login-msg", ··· 53 } 54 55 func (s *State) Logout(w http.ResponseWriter, r *http.Request) { 56 + l := s.logger.With("handler", "Logout") 57 + 58 err := s.oauth.DeleteSession(w, r) 59 if err != nil { 60 + l.Error("failed to logout", "err", err) 61 } else { 62 + l.Info("logged out successfully") 63 } 64 65 s.pages.HxRedirect(w, "/login")
NEW
cmd/spindle/main.go
··· 2 3 import ( 4 "context" 5 "os" 6 7 - "tangled.org/core/log" 8 "tangled.org/core/spindle" 9 _ "tangled.org/core/tid" 10 ) 11 12 func main() { 13 - ctx := log.NewContext(context.Background(), "spindle") 14 err := spindle.Run(ctx) 15 if err != nil { 16 - log.FromContext(ctx).Error("error running spindle", "error", err) 17 os.Exit(-1) 18 } 19 }
··· 2 3 import ( 4 "context" 5 + "log/slog" 6 "os" 7 8 + tlog "tangled.org/core/log" 9 "tangled.org/core/spindle" 10 _ "tangled.org/core/tid" 11 ) 12 13 func main() { 14 + logger := tlog.New("spindl3") 15 + slog.SetDefault(logger) 16 + 17 + ctx := context.Background() 18 + ctx = tlog.IntoContext(ctx, logger) 19 + 20 err := spindle.Run(ctx) 21 if err != nil { 22 + logger.Error("error running spindle", "error", err) 23 os.Exit(-1) 24 } 25 }