logger: add SetOutput method

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
Adphi 2022-07-01 22:09:20 +02:00
parent 3fb566cb80
commit d8443ee470
Signed by: adphi
GPG Key ID: 46BE4062DB2397FF

View File

@ -29,6 +29,8 @@ type Logger interface {
SetLevel(level logrus.Level) Logger SetLevel(level logrus.Level) Logger
WriterLevel(level logrus.Level) *io.PipeWriter WriterLevel(level logrus.Level) *io.PipeWriter
SetOutput(w io.Writer) Logger
Debugf(format string, args ...interface{}) Debugf(format string, args ...interface{})
Infof(format string, args ...interface{}) Infof(format string, args ...interface{})
Printf(format string, args ...interface{}) Printf(format string, args ...interface{})
@ -205,3 +207,15 @@ func (l *logger) Logr() logr.Logger {
func (l *logger) FieldLogger() logrus.FieldLogger { func (l *logger) FieldLogger() logrus.FieldLogger {
return l.fl return l.fl
} }
func (l *logger) SetOutput(w io.Writer) Logger {
switch t := l.fl.(type) {
case *logrus.Logger:
t.SetOutput(w)
return l
case *logrus.Entry:
t.Logger.SetOutput(w)
return l
}
panic(fmt.Sprintf("unexpected logger type %T", l.fl))
}