mirror of
https://github.com/linka-cloud/grpc.git
synced 2024-12-22 17:00:45 +00:00
logger: add SetOutput method
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
3fb566cb80
commit
d8443ee470
@ -29,6 +29,8 @@ type Logger interface {
|
||||
SetLevel(level logrus.Level) Logger
|
||||
WriterLevel(level logrus.Level) *io.PipeWriter
|
||||
|
||||
SetOutput(w io.Writer) Logger
|
||||
|
||||
Debugf(format string, args ...interface{})
|
||||
Infof(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 {
|
||||
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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user