1package logger 2 3import ( 4 "io" 5 6 "github.com/sirupsen/logrus" 7) 8 9var _ Logger = Logrus{} 10var _ FieldLogger = Logrus{} 11var _ Outable = Logrus{} 12 13// Logrus is a Logger implementation backed by sirupsen/logrus 14type Logrus struct { 15 logrus.FieldLogger 16} 17 18// SetOutput will try and set the output of the underlying 19// logrus.FieldLogger if it can 20func (l Logrus) SetOutput(w io.Writer) { 21 if lg, ok := l.FieldLogger.(Outable); ok { 22 lg.SetOutput(w) 23 } 24} 25 26// WithField returns a new Logger with the field added 27func (l Logrus) WithField(s string, i interface{}) FieldLogger { 28 return Logrus{l.FieldLogger.WithField(s, i)} 29} 30 31// WithFields returns a new Logger with the fields added 32func (l Logrus) WithFields(m map[string]interface{}) FieldLogger { 33 return Logrus{l.FieldLogger.WithFields(m)} 34} 35