@@ -360,7 +360,7 @@ func (r *runner) initCache(opts flag.Options) error {
360
360
if err != nil {
361
361
return xerrors .Errorf ("unable to initialize the cache: %w" , err )
362
362
}
363
- log .Logger . Debugf ( "cache dir: %s" , fsutils .CacheDir ())
363
+ log .Debug ( "Cache dir" , log . String ( "dir" , fsutils .CacheDir () ))
364
364
365
365
if opts .Reset {
366
366
defer cacheClient .Close ()
@@ -400,12 +400,12 @@ func Run(ctx context.Context, opts flag.Options, targetKind TargetKind) (err err
400
400
401
401
defer func () {
402
402
if errors .Is (err , context .DeadlineExceeded ) {
403
- log .Logger . Warn ("Increase --timeout value" )
403
+ log .Warn ("Increase --timeout value" )
404
404
}
405
405
}()
406
406
407
407
if opts .GenerateDefaultConfig {
408
- log .Logger . Info ("Writing the default config to trivy-default.yaml..." )
408
+ log .Info ("Writing the default config to trivy-default.yaml..." )
409
409
return viper .SafeWriteConfigAs ("trivy-default.yaml" )
410
410
}
411
411
@@ -484,7 +484,8 @@ func disabledAnalyzers(opts flag.Options) []analyzer.Type {
484
484
// Filter only enabled misconfiguration scanners
485
485
ma , err := filterMisconfigAnalyzers (opts .MisconfigScanners , analyzer .TypeConfigFiles )
486
486
if err != nil {
487
- log .Logger .Errorf ("Invalid misconfig scanners specified: %s defaulting to use all misconfig scanners" , opts .MisconfigScanners )
487
+ log .Error ("Invalid misconfiguration scanners specified, defaulting to use all misconfig scanners" ,
488
+ log .Any ("scanners" , opts .MisconfigScanners ))
488
489
} else {
489
490
analyzers = append (analyzers , ma ... )
490
491
}
@@ -528,7 +529,7 @@ func filterMisconfigAnalyzers(included, all []analyzer.Type) ([]analyzer.Type, e
528
529
return nil , xerrors .Errorf ("invalid misconfiguration scanner specified %s valid scanners: %s" , missing , all )
529
530
}
530
531
531
- log .Logger . Debugf ("Enabling misconfiguration scanners: %s" , included )
532
+ log .Debug ("Enabling misconfiguration scanners" , log . Any ( "scanners" , included ) )
532
533
return lo .Without (all , included ... ), nil
533
534
}
534
535
@@ -569,28 +570,28 @@ func initScannerConfig(opts flag.Options, cacheClient cache.Cache) (ScannerConfi
569
570
}
570
571
571
572
if len (opts .ImageConfigScanners ) != 0 {
572
- log .Logger . Infof ("Container image config scanners: %q" , opts .ImageConfigScanners )
573
+ log .Info ("Container image config scanners" , log . Any ( "scanners" , opts .ImageConfigScanners ) )
573
574
}
574
575
575
576
if opts .Scanners .Enabled (types .VulnerabilityScanner ) {
576
- log .Logger . Info ("Vulnerability scanning is enabled" )
577
- log .Logger . Debugf ("Vulnerability type: %s" , scanOptions .VulnType )
577
+ log .Info ("Vulnerability scanning is enabled" )
578
+ log .Debug ("Vulnerability type" , log . Any ( "type" , scanOptions .VulnType ) )
578
579
}
579
580
580
581
// ScannerOption is filled only when config scanning is enabled.
581
582
var configScannerOptions misconf.ScannerOption
582
583
if opts .Scanners .Enabled (types .MisconfigScanner ) || opts .ImageConfigScanners .Enabled (types .MisconfigScanner ) {
583
- log .Logger . Info ("Misconfiguration scanning is enabled" )
584
+ log .Info ("Misconfiguration scanning is enabled" )
584
585
585
586
var downloadedPolicyPaths []string
586
587
var disableEmbedded bool
587
588
downloadedPolicyPaths , err := operation .InitBuiltinPolicies (context .Background (), opts .CacheDir , opts .Quiet , opts .SkipPolicyUpdate , opts .MisconfOptions .PolicyBundleRepository , opts .RegistryOpts ())
588
589
if err != nil {
589
590
if ! opts .SkipPolicyUpdate {
590
- log .Logger . Errorf ("Falling back to embedded policies: %s " , err )
591
+ log .Error ("Falling back to embedded policies" , log . Err ( err ) )
591
592
}
592
593
} else {
593
- log .Logger . Debug ("Policies successfully loaded from disk" )
594
+ log .Debug ("Policies successfully loaded from disk" )
594
595
disableEmbedded = true
595
596
}
596
597
configScannerOptions = misconf.ScannerOption {
@@ -617,18 +618,18 @@ func initScannerConfig(opts flag.Options, cacheClient cache.Cache) (ScannerConfi
617
618
// Do not load config file for secret scanning
618
619
if opts .Scanners .Enabled (types .SecretScanner ) {
619
620
ver := canonicalVersion (opts .AppVersion )
620
- log .Logger . Info ("Secret scanning is enabled" )
621
- log .Logger . Info ("If your scanning is slow, please try '--scanners vuln' to disable secret scanning" )
622
- log .Logger . Infof ("Please see also https://aquasecurity.github.io/trivy/%s/docs/scanner/secret/#recommendation for faster secret detection" , ver )
621
+ log .Info ("Secret scanning is enabled" )
622
+ log .Info ("If your scanning is slow, please try '--scanners vuln' to disable secret scanning" )
623
+ log .Infof ("Please see also https://aquasecurity.github.io/trivy/%s/docs/scanner/secret/#recommendation for faster secret detection" , ver )
623
624
} else {
624
625
opts .SecretConfigPath = ""
625
626
}
626
627
627
628
if opts .Scanners .Enabled (types .LicenseScanner ) {
628
629
if opts .LicenseFull {
629
- log .Logger . Info ("Full license scanning is enabled" )
630
+ log .Info ("Full license scanning is enabled" )
630
631
} else {
631
- log .Logger . Info ("License scanning is enabled" )
632
+ log .Info ("License scanning is enabled" )
632
633
}
633
634
}
634
635
0 commit comments