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

Merge pull request #481 from csaf-poc/improve_logging2

fix: improve logging for downloader and aggregator
This commit is contained in:
JanHoefelmeyer 2023-10-18 09:02:18 +02:00 committed by GitHub
commit 81edb6ccbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"log"
"net/http"
"os"
"runtime"
@ -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.

View file

@ -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{

View file

@ -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
}