all repos — searchix @ 94b21b286edff37496a2fe481963625ac01c30a1

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: more structured logging

Alan Pearce
commit

94b21b286edff37496a2fe481963625ac01c30a1

parent

f076b5bd6cb82edd99be50f3dbdd39bb9be2c44e

1 file changed, 4 insertions(+), 3 deletions(-)

changed files
M internal/fetcher/http.gointernal/fetcher/http.go
@@ -4,7 +4,6 @@ import (
"context" "fmt" "io" - "log/slog" "net/http" "strings" "time"
@@ -13,6 +12,7 @@ "go.alanpearce.eu/searchix/internal/config"
"github.com/andybalholm/brotli" "github.com/pkg/errors" + "go.alanpearce.eu/x/log" ) type brotliReadCloser struct {
@@ -33,6 +33,7 @@ }
func fetchFileIfNeeded( ctx context.Context, + log *log.Logger, mtime time.Time, url string, ) (body io.ReadCloser, newMtime time.Time, err error) {
@@ -68,7 +69,7 @@ return
case http.StatusOK: newMtime, err = time.Parse(time.RFC1123, res.Header.Get("Last-Modified")) if err != nil { - slog.Warn( + log.Warn( "could not parse Last-Modified header from response", "value", res.Header.Get("Last-Modified"),
@@ -78,7 +79,7 @@ }
switch ce := res.Header.Get("Content-Encoding"); ce { case "br": - slog.Debug("using brotli encoding") + log.Debug("using brotli encoding") body = newBrotliReader(res.Body) case "", "identity", "gzip": body = res.Body