refactor: improve error logs

main
sundowndev 2021-08-31 10:59:45 +02:00
parent 1157138af1
commit 199259eb3d
2 changed files with 8 additions and 2 deletions

View File

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

View File

@ -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"])
}