-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
47 lines (37 loc) · 1.04 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
35
36
37
38
39
40
41
42
43
44
45
46
47
package walrus
import (
"github.com/ThreeDotsLabs/watermill"
"github.com/sirupsen/logrus"
)
// Force implementation check.
var _ watermill.LoggerAdapter = &Logger{}
type Logger struct {
entry logrus.FieldLogger
}
func New() watermill.LoggerAdapter {
return &Logger{
entry: logrus.StandardLogger(),
}
}
func NewWithLogger(l logrus.FieldLogger) watermill.LoggerAdapter {
return &Logger{
entry: l,
}
}
func (l *Logger) Error(msg string, err error, fields watermill.LogFields) {
l.entry.WithFields(logrus.Fields(fields)).Error(msg, err)
}
func (l *Logger) Info(msg string, fields watermill.LogFields) {
l.entry.WithFields(logrus.Fields(fields)).Info(msg)
}
func (l *Logger) Debug(msg string, fields watermill.LogFields) {
l.entry.WithFields(logrus.Fields(fields)).Debug(msg)
}
func (l *Logger) Trace(msg string, fields watermill.LogFields) {
l.entry.WithFields(logrus.Fields(fields)).Trace(msg)
}
func (l *Logger) With(fields watermill.LogFields) watermill.LoggerAdapter {
return &Logger{
entry: l.entry.WithFields(logrus.Fields(fields)),
}
}