mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
828807bddb
* feat: add a new debug logger Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * fix: duplicate first messages Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * feat: add checks in info() Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * add debug logger to notary package Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * feat: update info func Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * feat: add error func Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * feat: update wrapper to use right fmt functions Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * fix: use sprintln not sprint Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * feat: remove V(4) Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * refactor: removed common code Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * Update pkg/notary/log.go Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * Update pkg/notary/log.go Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * Update pkg/notary/log.go Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * fix: update names Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * Update pkg/notary/log.go Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * feat: add verbosity levels Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * Update pkg/notary/log.go Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * fix: lint Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> * feat: use errors new Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> --------- Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com> Co-authored-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
87 lines
2 KiB
Go
87 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)
|
|
}
|