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
···
import (
"fmt"
-
"log"
"net/http"
"strings"
···
)
func (s *State) Login(w http.ResponseWriter, r *http.Request) {
+
l := s.logger.With("handler", "Login")
+
switch r.Method {
case http.MethodGet:
returnURL := r.URL.Query().Get("return_url")
···
// basic handle validation
if !strings.Contains(handle, ".") {
-
log.Println("invalid handle format", "raw", handle)
+
l.Error("invalid handle format", "raw", handle)
s.pages.Notice(
w,
"login-msg",
···
}
func (s *State) Logout(w http.ResponseWriter, r *http.Request) {
+
l := s.logger.With("handler", "Logout")
+
err := s.oauth.DeleteSession(w, r)
if err != nil {
-
log.Println("failed to logout", "err", err)
+
l.Error("failed to logout", "err", err)
} else {
-
log.Println("logged out successfully")
+
l.Info("logged out successfully")
}
s.pages.HxRedirect(w, "/login")
NEW
cmd/spindle/main.go
···
import (
"context"
+
"log/slog"
"os"
-
"tangled.org/core/log"
+
tlog "tangled.org/core/log"
"tangled.org/core/spindle"
_ "tangled.org/core/tid"
)
func main() {
-
ctx := log.NewContext(context.Background(), "spindle")
+
logger := tlog.New("spindl3")
+
slog.SetDefault(logger)
+
+
ctx := context.Background()
+
ctx = tlog.IntoContext(ctx, logger)
+
err := spindle.Run(ctx)
if err != nil {
-
log.FromContext(ctx).Error("error running spindle", "error", err)
+
logger.Error("error running spindle", "error", err)
os.Exit(-1)
}
}