2016-09-26 16:12:13 +00:00
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
2016-09-29 17:40:46 +00:00
|
|
|
"github.com/influxdata/mrfusion"
|
2016-09-26 16:12:13 +00:00
|
|
|
)
|
|
|
|
|
2016-09-29 17:40:46 +00:00
|
|
|
// LogrusLogger is a mrfusion.Logger that uses logrus to process logs
|
|
|
|
type logrusLogger struct {
|
|
|
|
l *logrus.Entry
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ll *logrusLogger) Info(items ...interface{}) {
|
|
|
|
ll.l.Info(items...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ll *logrusLogger) Warn(items ...interface{}) {
|
|
|
|
ll.l.Warn(items...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ll *logrusLogger) Debug(items ...interface{}) {
|
|
|
|
ll.l.Debug(items...)
|
|
|
|
}
|
2016-09-26 16:12:13 +00:00
|
|
|
|
2016-09-29 17:40:46 +00:00
|
|
|
func (ll *logrusLogger) Panic(items ...interface{}) {
|
|
|
|
ll.l.Panic(items...)
|
2016-09-26 16:12:13 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 17:40:46 +00:00
|
|
|
func (ll *logrusLogger) Error(items ...interface{}) {
|
|
|
|
ll.l.Error(items...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ll *logrusLogger) WithField(key string, value interface{}) mrfusion.Logger {
|
|
|
|
return &logrusLogger{ll.l.WithField(key, value)}
|
|
|
|
}
|
|
|
|
|
|
|
|
func New() mrfusion.Logger {
|
|
|
|
logger := &logrus.Logger{
|
2016-09-26 16:12:13 +00:00
|
|
|
Out: os.Stderr,
|
|
|
|
Formatter: new(logrus.TextFormatter),
|
|
|
|
Hooks: make(logrus.LevelHooks),
|
|
|
|
Level: logrus.DebugLevel,
|
|
|
|
}
|
2016-09-29 17:40:46 +00:00
|
|
|
|
|
|
|
return &logrusLogger{
|
|
|
|
l: logrus.NewEntry(logger),
|
|
|
|
}
|
2016-09-26 16:12:13 +00:00
|
|
|
}
|