1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

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.)
This commit is contained in:
Bernhard Reiter 2023-10-17 11:33:03 +02:00
parent 666913e61e
commit 3923dc7044
No known key found for this signature in database
GPG key ID: 2B7BA3BF9BC3A554
3 changed files with 13 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import (
"crypto/tls" "crypto/tls"
"errors" "errors"
"fmt" "fmt"
"log"
"net/http" "net/http"
"os" "os"
"runtime" "runtime"
@ -166,14 +167,21 @@ func (c *config) tooOldForInterims() func(time.Time) bool {
// is in the accepted download interval of the provider or // is in the accepted download interval of the provider or
// the global config. // the global config.
func (p *provider) ageAccept(c *config) func(time.Time) bool { func (p *provider) ageAccept(c *config) func(time.Time) bool {
var r *models.TimeRange
switch { switch {
case p.Range != nil: case p.Range != nil:
return p.Range.Contains r = p.Range
case c.Range != nil: case c.Range != nil:
return c.Range.Contains r = c.Range
default: default:
return nil 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. // ignoreFile returns true if the given URL should not be downloaded.

View file

@ -214,7 +214,7 @@ func (cfg *config) prepareLogging() error {
if err != nil { if err != nil {
return err return err
} }
log.Printf("using %q for logging\n", *cfg.LogFile) log.Printf("using %q for logging\n", fname)
w = f w = f
} }
ho := slog.HandlerOptions{ ho := slog.HandlerOptions{

View file

@ -204,6 +204,8 @@ func (d *downloader) download(ctx context.Context, domain string) error {
// Do we need time range based filtering? // Do we need time range based filtering?
if d.cfg.Range != nil { if d.cfg.Range != nil {
slog.Debug("Setting up filter to accept documents within",
"TimeRange", d.cfg.Range)
afp.AgeAccept = d.cfg.Range.Contains afp.AgeAccept = d.cfg.Range.Contains
} }