forked from zubroide/gorm-crud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
68 lines (54 loc) · 1.78 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gorm_crud
type LoggerInterface interface {
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Print(args ...interface{})
}
func NewLoggerWithMeta(logger LoggerInterface, meta ...interface{}) LoggerInterface {
return &LoggerWithMeta{meta: meta, logger: logger}
}
type LoggerWithMeta struct {
meta []interface{}
logger LoggerInterface
}
func (l *LoggerWithMeta) Debug(args ...interface{}) {
l.logger.Debug(append(l.meta, args))
}
func (l *LoggerWithMeta) Debugf(format string, args ...interface{}) {
l.logger.Debugf(format, append(l.meta, args))
}
func (l *LoggerWithMeta) Info(args ...interface{}) {
l.logger.Info(append(l.meta, args))
}
func (l *LoggerWithMeta) Infof(format string, args ...interface{}) {
l.logger.Infof(format, append(l.meta, args))
}
func (l *LoggerWithMeta) Warn(args ...interface{}) {
l.logger.Warn(append(l.meta, args))
}
func (l *LoggerWithMeta) Warnf(format string, args ...interface{}) {
l.logger.Warnf(format, append(l.meta, args))
}
func (l *LoggerWithMeta) Error(args ...interface{}) {
l.logger.Error(append(l.meta, args))
}
func (l *LoggerWithMeta) Errorf(format string, args ...interface{}) {
l.logger.Errorf(format, append(l.meta, args))
}
func (l *LoggerWithMeta) Fatal(args ...interface{}) {
l.logger.Fatal(append(l.meta, args))
}
func (l *LoggerWithMeta) Fatalf(format string, args ...interface{}) {
l.logger.Fatalf(format, append(l.meta, args))
}
func (l *LoggerWithMeta) Print(args ...interface{}) {
l.logger.Debug(append(l.meta, args))
}