Use warn instead of error for packages with no matchers (#113)

* Add warn method to logging system

Signed-off-by: Dan Luhring <dan.luhring@anchore.com>

* Move from error to warn for no matcher scenario

Signed-off-by: Dan Luhring <dan.luhring@anchore.com>
This commit is contained in:
Dan Luhring 2020-08-10 16:03:12 -04:00 committed by GitHub
parent 50d7251a0b
commit 219d8bcf0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package logger
type Logger interface {
Errorf(format string, args ...interface{})
Warnf(format string, args ...interface{})
Infof(format string, args ...interface{})
Info(args ...interface{})
Debugf(format string, args ...interface{})

View file

@ -87,7 +87,7 @@ func (c *controller) findMatches(provider vulnerability.Provider, d distro.Distr
matchers, ok := c.matchers[p.Type]
if !ok {
log.Errorf("no matchers available for package pkg=%s", p)
log.Warnf("no matchers available for package pkg=%s", p)
}
for _, m := range matchers {
matches, err := m.Match(provider, d, p)

View file

@ -8,6 +8,10 @@ func Errorf(format string, args ...interface{}) {
Log.Errorf(format, args...)
}
func Warnf(format string, args ...interface{}) {
Log.Warnf(format, args...)
}
func Infof(format string, args ...interface{}) {
Log.Infof(format, args...)
}

View file

@ -3,6 +3,7 @@ package log
type nopLogger struct{}
func (l *nopLogger) Errorf(format string, args ...interface{}) {}
func (l *nopLogger) Warnf(format string, args ...interface{}) {}
func (l *nopLogger) Infof(format string, args ...interface{}) {}
func (l *nopLogger) Info(args ...interface{}) {}
func (l *nopLogger) Debugf(format string, args ...interface{}) {}

View file

@ -90,6 +90,10 @@ func (l *LogrusLogger) Info(args ...interface{}) {
l.Logger.Info(args...)
}
func (l *LogrusLogger) Warnf(format string, args ...interface{}) {
l.Logger.Warnf(format, args...)
}
func (l *LogrusLogger) Errorf(format string, args ...interface{}) {
l.Logger.Errorf(format, args...)
}
@ -110,6 +114,10 @@ func (l *LogrusNestedLogger) Info(args ...interface{}) {
l.Logger.Info(args...)
}
func (l *LogrusNestedLogger) Warnf(format string, args ...interface{}) {
l.Logger.Warnf(format, args...)
}
func (l *LogrusNestedLogger) Errorf(format string, args ...interface{}) {
l.Logger.Errorf(format, args...)
}