From 3923dc7044df48f652288c97a374163a7f84dd25 Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Tue, 17 Oct 2023 11:33:03 +0200 Subject: [PATCH] fix: improve logging for downloader and aggregator * use full name for printing out the used logfile for the downloader. * for debug or verbose, log the timeintervall that will be used for downloader and aggregator. (The checker has this as part of its output already.) --- cmd/csaf_aggregator/config.go | 12 ++++++++++-- cmd/csaf_downloader/config.go | 2 +- cmd/csaf_downloader/downloader.go | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/csaf_aggregator/config.go b/cmd/csaf_aggregator/config.go index 34cfb817..596c0567 100644 --- a/cmd/csaf_aggregator/config.go +++ b/cmd/csaf_aggregator/config.go @@ -12,6 +12,7 @@ import ( "crypto/tls" "errors" "fmt" + "log" "net/http" "os" "runtime" @@ -166,14 +167,21 @@ func (c *config) tooOldForInterims() func(time.Time) bool { // is in the accepted download interval of the provider or // the global config. func (p *provider) ageAccept(c *config) func(time.Time) bool { + var r *models.TimeRange switch { case p.Range != nil: - return p.Range.Contains + r = p.Range case c.Range != nil: - return c.Range.Contains + r = c.Range default: return nil } + + if c.Verbose { + s, _ := r.MarshalJSON() + log.Printf("Setting up filter to accept docs within TimeRange %s", s) + } + return r.Contains } // ignoreFile returns true if the given URL should not be downloaded. diff --git a/cmd/csaf_downloader/config.go b/cmd/csaf_downloader/config.go index 17c85459..0c1ade1f 100644 --- a/cmd/csaf_downloader/config.go +++ b/cmd/csaf_downloader/config.go @@ -214,7 +214,7 @@ func (cfg *config) prepareLogging() error { if err != nil { return err } - log.Printf("using %q for logging\n", *cfg.LogFile) + log.Printf("using %q for logging\n", fname) w = f } ho := slog.HandlerOptions{ diff --git a/cmd/csaf_downloader/downloader.go b/cmd/csaf_downloader/downloader.go index 31c62866..57395771 100644 --- a/cmd/csaf_downloader/downloader.go +++ b/cmd/csaf_downloader/downloader.go @@ -204,6 +204,8 @@ func (d *downloader) download(ctx context.Context, domain string) error { // Do we need time range based filtering? if d.cfg.Range != nil { + slog.Debug("Setting up filter to accept documents within", + "TimeRange", d.cfg.Range) afp.AgeAccept = d.cfg.Range.Contains }