Skip to content

Commit

Permalink
Merge pull request #481 from csaf-poc/improve_logging2
Browse files Browse the repository at this point in the history
fix: improve logging for downloader and aggregator
  • Loading branch information
JanHoefelmeyer authored Oct 18, 2023
2 parents abc8b10 + 8f6e6ee commit 81edb6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 11 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,22 @@ 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 {
log.Printf(
"Setting up filter to accept advisories within time range %s to %s\n",
r[0].Format(time.RFC3339), r[1].Format(time.RFC3339))
}
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 advisories within",
"timerange", d.cfg.Range)
afp.AgeAccept = d.cfg.Range.Contains
}

Expand Down

0 comments on commit 81edb6c

Please sign in to comment.