-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
63 lines (49 loc) · 1.42 KB
/
interface.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
package logging
import (
"context"
"github.com/sirupsen/logrus"
)
type FatalLogger interface {
Fatalf(format string, args ...interface{})
}
func NewInternalLogger() *InternalLogger {
return &InternalLogger{
parent: logrus.New().WithContext(context.TODO()),
}
}
// InternalLogger is separating our codebase from logging implementation
type InternalLogger struct {
parent *logrus.Entry
}
func (l *InternalLogger) Debug(args ...interface{}) {
l.parent.Debug(args...)
}
func (l *InternalLogger) Info(args ...interface{}) {
l.parent.Info(args...)
}
func (l *InternalLogger) Warning(args ...interface{}) {
l.parent.Warning(args...)
}
func (l *InternalLogger) Error(args ...interface{}) {
l.parent.Error(args...)
}
func (l *InternalLogger) Debugf(format string, args ...interface{}) {
l.parent.Debugf(format, args...)
}
func (l *InternalLogger) Infof(format string, args ...interface{}) {
l.parent.Infof(format, args...)
}
func (l *InternalLogger) Warningf(format string, args ...interface{}) {
l.parent.Warningf(format, args...)
}
func (l *InternalLogger) Fatalf(format string, args ...interface{}) {
l.parent.Fatalf(format, args...)
}
func (l *InternalLogger) Errorf(format string, args ...interface{}) {
l.parent.Errorf(format, args...)
}
func (l *InternalLogger) ForkWithFields(ctx context.Context, fields map[string]interface{}) *InternalLogger {
return &InternalLogger{
l.parent.WithContext(ctx).WithFields(fields),
}
}