From 199259eb3d6012debeeee8914c5f2c3fe1bf82d0 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Tue, 31 Aug 2021 10:59:45 +0200 Subject: [PATCH] refactor: improve error logs --- pkg/cmd/scan.go | 4 ++-- pkg/cmd/scan/output/config.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/scan.go b/pkg/cmd/scan.go index 6cf9909d..456949a2 100644 --- a/pkg/cmd/scan.go +++ b/pkg/cmd/scan.go @@ -259,7 +259,7 @@ func scanRun(opts *pkg.ScanOptions) error { validOutput := false for _, o := range opts.Output { if err = output.GetOutput(o, opts.Quiet).Write(analysis); err != nil { - logrus.Errorf("Computing output %s://%s failed: %v", o.Key, o.Options["path"], err.Error()) + logrus.Errorf("Error writing to output %s: %v", o.String(), err.Error()) continue } validOutput = true @@ -267,7 +267,7 @@ func scanRun(opts *pkg.ScanOptions) error { // Fallback to console output if all output failed if !validOutput { - logrus.Debug("All outputs failed to compute, fallback to console output") + logrus.Debug("All outputs failed, fallback to console output") if err = output.NewConsole().Write(analysis); err != nil { return err } diff --git a/pkg/cmd/scan/output/config.go b/pkg/cmd/scan/output/config.go index 634c045c..2a08a5eb 100644 --- a/pkg/cmd/scan/output/config.go +++ b/pkg/cmd/scan/output/config.go @@ -1,6 +1,12 @@ package output +import "fmt" + type OutputConfig struct { Key string Path string } + +func (o *OutputConfig) String() string { + return fmt.Sprintf("%s://%s", o.Key, o.Options["path"]) +}