forked from gobuffalo/buffalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
34 lines (31 loc) · 1.01 KB
/
logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package buffalo
import "github.com/Sirupsen/logrus"
// Logger interface is used throughout Buffalo
// apps to log a whole manner of things.
type Logger interface {
WithField(string, interface{}) Logger
WithFields(map[string]interface{}) Logger
Debugf(string, ...interface{})
Infof(string, ...interface{})
Printf(string, ...interface{})
Warnf(string, ...interface{})
Errorf(string, ...interface{})
Fatalf(string, ...interface{})
Debug(...interface{})
Info(...interface{})
Warn(...interface{})
Error(...interface{})
Fatal(...interface{})
Panic(...interface{})
}
// NewLogger based on the specified log level.
// This logger will log to the STDOUT in a human readable,
// but parseable form.
/*
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
*/
func NewLogger(level string) Logger {
l := logrus.New()
l.Level, _ = logrus.ParseLevel(level)
return &multiLogger{Loggers: []logrus.FieldLogger{l}}
}