mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
Extend structured logging usage in aggregator (#622)
* Extend structured logging usage in aggregator * Use structured logging in advisories processor * Remove unnecessary inner function * Format * Feat: Add verbose flag to example aggregator toml (in comment) --------- Co-authored-by: JanHoefelmeyer <jan.hoefelmeyer@intevation.de>
This commit is contained in:
parent
cf4cf7c6c1
commit
5709b14650
4 changed files with 36 additions and 30 deletions
|
|
@ -264,8 +264,14 @@ func (c *config) privateOpenPGPKey() (*crypto.Key, error) {
|
|||
return c.key, c.keyErr
|
||||
}
|
||||
|
||||
func (c *config) httpClient(p *provider) util.Client {
|
||||
// httpLog does structured logging in a [util.LoggingClient].
|
||||
func httpLog(method, url string) {
|
||||
slog.Debug("http",
|
||||
"method", method,
|
||||
"url", url)
|
||||
}
|
||||
|
||||
func (c *config) httpClient(p *provider) util.Client {
|
||||
hClient := http.Client{}
|
||||
|
||||
var tlsConfig tls.Config
|
||||
|
|
@ -310,7 +316,10 @@ func (c *config) httpClient(p *provider) util.Client {
|
|||
}
|
||||
|
||||
if c.Verbose {
|
||||
client = &util.LoggingClient{Client: client}
|
||||
client = &util.LoggingClient{
|
||||
Client: client,
|
||||
Log: httpLog,
|
||||
}
|
||||
}
|
||||
|
||||
if p.Rate == nil && c.Rate == nil {
|
||||
|
|
@ -331,7 +340,6 @@ func (c *config) httpClient(p *provider) util.Client {
|
|||
}
|
||||
|
||||
func (c *config) checkProviders() error {
|
||||
|
||||
if !c.AllowSingleProvider && len(c.Providers) < 2 {
|
||||
return errors.New("need at least two providers")
|
||||
}
|
||||
|
|
@ -471,7 +479,6 @@ func (c *config) prepareCertificates() error {
|
|||
|
||||
// prepare prepares internal state of a loaded configuration.
|
||||
func (c *config) prepare() error {
|
||||
|
||||
if len(c.Providers) == 0 {
|
||||
return errors.New("no providers given in configuration")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue