Monorepo for Tangled tangled.org

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

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3m2rmwxo3f222
+16 -7
Interdiff #0 โ†’ #1
appview/db/db.go

This file has not been changed.

appview/ingester.go

This file has not been changed.

appview/issues/issues.go

This file has not been changed.

appview/labels/labels.go

This file has not been changed.

appview/notifications/notifications.go

This file has not been changed.

appview/pages/pages.go

This file has not been changed.

appview/pipelines/pipelines.go

This file has not been changed.

appview/pulls/pulls.go

This file has not been changed.

appview/repo/index.go

This file has not been changed.

appview/repo/repo.go

This file has not been changed.

appview/signup/signup.go

This file has not been changed.

appview/state/knotstream.go

This file has not been changed.

appview/state/router.go

This file has not been changed.

appview/state/spindlestream.go

This file has not been changed.

appview/state/state.go

This file has not been changed.

cmd/appview/main.go

This file has not been changed.

go.mod

This file has not been changed.

go.sum

This file has not been changed.

jetstream/jetstream.go

This file has not been changed.

nix/gomod2nix.toml

This file has not been changed.

xrpc/serviceauth/service_auth.go

This file has not been changed.

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

History

2 rounds 0 comments
sign up or login to add to the discussion
oppi.li submitted #1
1 commit
expand
appview: improve the logging situation a bit
expand 0 comments
closed without merging
oppi.li submitted #0
1 commit
expand
appview: improve the logging situation a bit
1/3 failed, 2/3 success
expand
expand 0 comments