Skip to content

Commit

Permalink
fix: improve logging for downloader and aggregator
Browse files Browse the repository at this point in the history
 * 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.)
  • Loading branch information
bernhardreiter committed Oct 17, 2023
1 parent 666913e commit 3923dc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions cmd/csaf_aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"log"
"net/http"
"os"
"runtime"
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cmd/csaf_downloader/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 2 additions & 0 deletions cmd/csaf_downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3923dc7

Please sign in to comment.