diff options
Diffstat (limited to 'internal/fetcher')
-rw-r--r-- | internal/fetcher/channel.go | 6 | ||||
-rw-r--r-- | internal/fetcher/download.go | 8 | ||||
-rw-r--r-- | internal/fetcher/http.go | 7 | ||||
-rw-r--r-- | internal/fetcher/main.go | 4 | ||||
-rw-r--r-- | internal/fetcher/nixpkgs-channel.go | 8 |
5 files changed, 17 insertions, 16 deletions
diff --git a/internal/fetcher/channel.go b/internal/fetcher/channel.go index 2bde631..8f0aa03 100644 --- a/internal/fetcher/channel.go +++ b/internal/fetcher/channel.go @@ -3,7 +3,6 @@ package fetcher import ( "context" "fmt" - "log/slog" "os" "os/exec" "path" @@ -13,6 +12,7 @@ import ( "go.alanpearce.eu/searchix/internal/config" "go.alanpearce.eu/searchix/internal/index" + "go.alanpearce.eu/x/log" "github.com/pkg/errors" ) @@ -20,12 +20,12 @@ import ( type ChannelFetcher struct { Source *config.Source SourceFile string - Logger *slog.Logger + Logger *log.Logger } func NewChannelFetcher( source *config.Source, - logger *slog.Logger, + logger *log.Logger, ) (*ChannelFetcher, error) { switch source.Importer { case config.Options: diff --git a/internal/fetcher/download.go b/internal/fetcher/download.go index 941a683..a34c838 100644 --- a/internal/fetcher/download.go +++ b/internal/fetcher/download.go @@ -3,24 +3,24 @@ package fetcher import ( "context" "fmt" - "log/slog" "net/url" "go.alanpearce.eu/searchix/internal/config" "go.alanpearce.eu/searchix/internal/index" "github.com/pkg/errors" + "go.alanpearce.eu/x/log" ) type DownloadFetcher struct { Source *config.Source SourceFile string - Logger *slog.Logger + Logger *log.Logger } func NewDownloadFetcher( source *config.Source, - logger *slog.Logger, + logger *log.Logger, ) (*DownloadFetcher, error) { switch source.Importer { case config.Options: @@ -59,7 +59,7 @@ func (i *DownloadFetcher) FetchIfNeeded( i.Logger.Debug("preparing to fetch URL", "url", fetchURL) - body, mtime, err := fetchFileIfNeeded(ctx, sourceUpdated, fetchURL) + body, mtime, err := fetchFileIfNeeded(ctx, i.Logger, sourceUpdated, fetchURL) if err != nil { i.Logger.Warn("failed to fetch file", "url", fetchURL, "error", err) diff --git a/internal/fetcher/http.go b/internal/fetcher/http.go index c848dc9..c5ec8fc 100644 --- a/internal/fetcher/http.go +++ b/internal/fetcher/http.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "log/slog" "net/http" "strings" "time" @@ -13,6 +12,7 @@ import ( "github.com/andybalholm/brotli" "github.com/pkg/errors" + "go.alanpearce.eu/x/log" ) type brotliReadCloser struct { @@ -33,6 +33,7 @@ func (r *brotliReadCloser) Close() error { 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 @@ func fetchFileIfNeeded( 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 @@ func fetchFileIfNeeded( 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 diff --git a/internal/fetcher/main.go b/internal/fetcher/main.go index fcc04a9..ac40ead 100644 --- a/internal/fetcher/main.go +++ b/internal/fetcher/main.go @@ -3,10 +3,10 @@ package fetcher import ( "context" "io" - "log/slog" "go.alanpearce.eu/searchix/internal/config" "go.alanpearce.eu/searchix/internal/index" + "go.alanpearce.eu/x/log" "github.com/pkg/errors" ) @@ -23,7 +23,7 @@ type Fetcher interface { func New( source *config.Source, - logger *slog.Logger, + logger *log.Logger, ) (fetcher Fetcher, err error) { switch source.Fetcher { case config.ChannelNixpkgs: diff --git a/internal/fetcher/nixpkgs-channel.go b/internal/fetcher/nixpkgs-channel.go index ca33ae6..6f8ca63 100644 --- a/internal/fetcher/nixpkgs-channel.go +++ b/internal/fetcher/nixpkgs-channel.go @@ -3,18 +3,18 @@ package fetcher import ( "context" "fmt" - "log/slog" "net/url" "go.alanpearce.eu/searchix/internal/config" "go.alanpearce.eu/searchix/internal/index" "github.com/pkg/errors" + "go.alanpearce.eu/x/log" ) type NixpkgsChannelFetcher struct { Source *config.Source - Logger *slog.Logger + Logger *log.Logger } func makeChannelURL(channel string, subPath string) (string, error) { @@ -25,7 +25,7 @@ func makeChannelURL(channel string, subPath string) (string, error) { func NewNixpkgsChannelFetcher( source *config.Source, - logger *slog.Logger, + logger *log.Logger, ) (*NixpkgsChannelFetcher, error) { switch source.Importer { case config.Options, config.Packages: @@ -66,7 +66,7 @@ func (i *NixpkgsChannelFetcher) FetchIfNeeded( } i.Logger.Debug("attempting to fetch file", "url", fetchURL) - body, mtime, err := fetchFileIfNeeded(ctx, sourceMeta.Updated, fetchURL) + body, mtime, err := fetchFileIfNeeded(ctx, i.Logger, sourceMeta.Updated, fetchURL) if err != nil { i.Logger.Warn("failed to fetch file", "url", fetchURL, "error", err) |