-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
log_custom.go
103 lines (83 loc) · 2.77 KB
/
log_custom.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
100
101
102
103
package wails
// CustomLogger is a wrapper object to logrus
type CustomLogger struct {
prefix string
errorOnly bool
}
func newCustomLogger(prefix string) *CustomLogger {
return &CustomLogger{
prefix: "[" + prefix + "] ",
}
}
// Info level message
func (c *CustomLogger) Info(message string) {
logger.Info(c.prefix + message)
}
// Infof - formatted message
func (c *CustomLogger) Infof(message string, args ...interface{}) {
logger.Infof(c.prefix+message, args...)
}
// InfoFields - message with fields
func (c *CustomLogger) InfoFields(message string, fields Fields) {
logger.WithFields(map[string]interface{}(fields)).Info(c.prefix + message)
}
// Debug level message
func (c *CustomLogger) Debug(message string) {
logger.Debug(c.prefix + message)
}
// Debugf - formatted message
func (c *CustomLogger) Debugf(message string, args ...interface{}) {
logger.Debugf(c.prefix+message, args...)
}
// DebugFields - message with fields
func (c *CustomLogger) DebugFields(message string, fields Fields) {
logger.WithFields(map[string]interface{}(fields)).Debug(c.prefix + message)
}
// Warn level message
func (c *CustomLogger) Warn(message string) {
logger.Warn(c.prefix + message)
}
// Warnf - formatted message
func (c *CustomLogger) Warnf(message string, args ...interface{}) {
logger.Warnf(c.prefix+message, args...)
}
// WarnFields - message with fields
func (c *CustomLogger) WarnFields(message string, fields Fields) {
logger.WithFields(map[string]interface{}(fields)).Warn(c.prefix + message)
}
// Error level message
func (c *CustomLogger) Error(message string) {
logger.Error(c.prefix + message)
}
// Errorf - formatted message
func (c *CustomLogger) Errorf(message string, args ...interface{}) {
logger.Errorf(c.prefix+message, args...)
}
// ErrorFields - message with fields
func (c *CustomLogger) ErrorFields(message string, fields Fields) {
logger.WithFields(map[string]interface{}(fields)).Error(c.prefix + message)
}
// Fatal level message
func (c *CustomLogger) Fatal(message string) {
logger.Fatal(c.prefix + message)
}
// Fatalf - formatted message
func (c *CustomLogger) Fatalf(message string, args ...interface{}) {
logger.Fatalf(c.prefix+message, args...)
}
// FatalFields - message with fields
func (c *CustomLogger) FatalFields(message string, fields Fields) {
logger.WithFields(map[string]interface{}(fields)).Fatal(c.prefix + message)
}
// Panic level message
func (c *CustomLogger) Panic(message string) {
logger.Panic(c.prefix + message)
}
// Panicf - formatted message
func (c *CustomLogger) Panicf(message string, args ...interface{}) {
logger.Panicf(c.prefix+message, args...)
}
// PanicFields - message with fields
func (c *CustomLogger) PanicFields(message string, fields Fields) {
logger.WithFields(map[string]interface{}(fields)).Panic(c.prefix + message)
}