use anchore/go-logger interface

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2022-02-05 12:04:36 -05:00
parent e474b2f23c
commit 69692ad901
10 changed files with 48 additions and 217 deletions
+6 -1
View File
@@ -3,7 +3,7 @@ Package log contains the singleton object and helper functions for facilitating
*/
package log
import "github.com/anchore/syft/syft/logger"
import "github.com/anchore/go-logger"
// Log is the singleton used to facilitate logging internally within syft
var Log logger.Logger = &nopLogger{}
@@ -47,3 +47,8 @@ func Debugf(format string, args ...interface{}) {
func Debug(args ...interface{}) {
Log.Debug(args...)
}
// WithFields returns a message logger with multiple key-value fields.
func WithFields(fields ...interface{}) logger.MessageLogger {
return Log.WithFields(fields...)
}
+14 -8
View File
@@ -1,12 +1,18 @@
package log
import (
"github.com/anchore/go-logger"
)
type nopLogger struct{}
func (l *nopLogger) Errorf(format string, args ...interface{}) {}
func (l *nopLogger) Error(args ...interface{}) {}
func (l *nopLogger) Warnf(format string, args ...interface{}) {}
func (l *nopLogger) Warn(args ...interface{}) {}
func (l *nopLogger) Infof(format string, args ...interface{}) {}
func (l *nopLogger) Info(args ...interface{}) {}
func (l *nopLogger) Debugf(format string, args ...interface{}) {}
func (l *nopLogger) Debug(args ...interface{}) {}
func (l *nopLogger) Errorf(format string, args ...interface{}) {}
func (l *nopLogger) Error(args ...interface{}) {}
func (l *nopLogger) Warnf(format string, args ...interface{}) {}
func (l *nopLogger) Warn(args ...interface{}) {}
func (l *nopLogger) Infof(format string, args ...interface{}) {}
func (l *nopLogger) Info(args ...interface{}) {}
func (l *nopLogger) Debugf(format string, args ...interface{}) {}
func (l *nopLogger) Debug(args ...interface{}) {}
func (l *nopLogger) WithFields(fields ...interface{}) logger.MessageLogger { return l }
func (l *nopLogger) Nested(fields ...interface{}) logger.Logger { return l }