github.com/ashleymcnamara/buffalo@v0.8.0/logger.go (about) 1 package buffalo 2 3 import "github.com/Sirupsen/logrus" 4 5 // Logger interface is used throughout Buffalo 6 // apps to log a whole manner of things. 7 type Logger interface { 8 WithField(string, interface{}) Logger 9 WithFields(map[string]interface{}) Logger 10 Debugf(string, ...interface{}) 11 Infof(string, ...interface{}) 12 Printf(string, ...interface{}) 13 Warnf(string, ...interface{}) 14 Errorf(string, ...interface{}) 15 Fatalf(string, ...interface{}) 16 Debug(...interface{}) 17 Info(...interface{}) 18 Warn(...interface{}) 19 Error(...interface{}) 20 Fatal(...interface{}) 21 Panic(...interface{}) 22 } 23 24 var _ Logger = logrusWrapper{} 25 26 type logrusWrapper struct { 27 logrus.FieldLogger 28 } 29 30 func (l logrusWrapper) WithField(s string, i interface{}) Logger { 31 return logrusWrapper{l.FieldLogger.WithField(s, i)} 32 } 33 34 func (l logrusWrapper) WithFields(m map[string]interface{}) Logger { 35 return logrusWrapper{l.FieldLogger.WithFields(m)} 36 } 37 38 // NewLogger based on the specified log level. 39 // This logger will log to the STDOUT in a human readable, 40 // but parseable form. 41 /* 42 Example: time="2016-12-01T21:02:07-05:00" level=info duration=225.283µs human_size="106 B" method=GET path="/" render=199.79µs request_id=2265736089 size=106 status=200 43 */ 44 func NewLogger(level string) Logger { 45 l := logrus.New() 46 l.Level, _ = logrus.ParseLevel(level) 47 l.Formatter = &logrus.TextFormatter{} 48 return logrusWrapper{l} 49 }