forked from gobuffalo/buffalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_logger.go
99 lines (82 loc) · 1.96 KB
/
multi_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package buffalo
import "github.com/Sirupsen/logrus"
var (
_ Logger = &multiLogger{}
)
type multiLogger struct {
Loggers []logrus.FieldLogger
}
func (m *multiLogger) WithField(key string, value interface{}) Logger {
lgs := []logrus.FieldLogger{}
for _, l := range m.Loggers {
lgs = append(lgs, l.WithField(key, value))
}
return &multiLogger{Loggers: lgs}
}
func (m *multiLogger) WithFields(fields map[string]interface{}) Logger {
lgs := []logrus.FieldLogger{}
for _, l := range m.Loggers {
lgs = append(lgs, l.WithFields(fields))
}
return &multiLogger{Loggers: lgs}
}
func (m *multiLogger) Debugf(format string, args ...interface{}) {
for _, l := range m.Loggers {
l.Debugf(format, args...)
}
}
func (m *multiLogger) Infof(format string, args ...interface{}) {
for _, l := range m.Loggers {
l.Infof(format, args...)
}
}
func (m *multiLogger) Printf(format string, args ...interface{}) {
for _, l := range m.Loggers {
l.Printf(format, args...)
}
}
func (m *multiLogger) Warnf(format string, args ...interface{}) {
for _, l := range m.Loggers {
l.Warnf(format, args...)
}
}
func (m *multiLogger) Errorf(format string, args ...interface{}) {
for _, l := range m.Loggers {
l.Errorf(format, args...)
}
}
func (m *multiLogger) Fatalf(format string, args ...interface{}) {
for _, l := range m.Loggers {
l.Fatalf(format, args...)
}
}
func (m *multiLogger) Debug(args ...interface{}) {
for _, l := range m.Loggers {
l.Debug(args...)
}
}
func (m *multiLogger) Info(args ...interface{}) {
for _, l := range m.Loggers {
l.Info(args...)
}
}
func (m *multiLogger) Warn(args ...interface{}) {
for _, l := range m.Loggers {
l.Warn(args...)
}
}
func (m *multiLogger) Error(args ...interface{}) {
for _, l := range m.Loggers {
l.Error(args...)
}
}
func (m *multiLogger) Fatal(args ...interface{}) {
for _, l := range m.Loggers {
l.Fatal(args...)
}
}
func (m *multiLogger) Panic(args ...interface{}) {
for _, l := range m.Loggers {
l.Panic(args...)
}
}