mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
88 lines
2 KiB
Go
88 lines
2 KiB
Go
|
package notary
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/go-logr/logr"
|
||
|
notationlog "github.com/notaryproject/notation-go/log"
|
||
|
)
|
||
|
|
||
|
func NotaryLoggerAdapter(logger logr.Logger) notationlog.Logger {
|
||
|
return ¬aryLoggerAdapter{
|
||
|
logger: logger.V(4),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type notaryLoggerAdapter struct {
|
||
|
logger logr.Logger
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Debug(args ...interface{}) {
|
||
|
nla.info(0, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Debugf(format string, args ...interface{}) {
|
||
|
nla.infof(0, format, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Debugln(args ...interface{}) {
|
||
|
nla.infoln(0, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Info(args ...interface{}) {
|
||
|
nla.info(1, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Infof(format string, args ...interface{}) {
|
||
|
nla.infof(1, format, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Infoln(args ...interface{}) {
|
||
|
nla.infoln(1, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Warn(args ...interface{}) {
|
||
|
nla.info(2, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Warnf(format string, args ...interface{}) {
|
||
|
nla.infof(2, format, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Warnln(args ...interface{}) {
|
||
|
nla.infoln(2, args...)
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Error(args ...interface{}) {
|
||
|
nla.logger.Error(errors.New(fmt.Sprint(args...)), "")
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Errorf(format string, args ...interface{}) {
|
||
|
nla.logger.Error(fmt.Errorf(format, args...), "")
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) Errorln(args ...interface{}) {
|
||
|
nla.logger.Error(errors.New(fmt.Sprintln(args...)), "")
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) info(level int, args ...interface{}) {
|
||
|
nla.log(level, fmt.Sprint(args...))
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) infof(level int, format string, args ...interface{}) {
|
||
|
nla.log(level, fmt.Sprintf(format, args...))
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) infoln(level int, args ...interface{}) {
|
||
|
nla.log(level, fmt.Sprintln(args...))
|
||
|
}
|
||
|
|
||
|
func (nla *notaryLoggerAdapter) log(level int, message string) {
|
||
|
logger := nla.logger
|
||
|
if level > 0 {
|
||
|
logger = logger.V(level)
|
||
|
}
|
||
|
logger.Info(message)
|
||
|
}
|