-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogger.go
127 lines (98 loc) · 3.19 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package logger
import (
"fmt"
)
const (
defaultSkip = 3
)
type Logger struct {
core *Core
scope string
caller bool
skip int
}
// ToDo: GetLogger with same the scope value for different the skip value
func (l *Logger) GetLogger(scope string) *Logger {
return l.core.GetLogger(scope)
}
func (l *Logger) Skip(skip int) *Logger {
l.skip = skip + defaultSkip
return l
}
func (l *Logger) Print(messages ...interface{}) {
l.core.print(InfoLevel, l.scope, l.skip, messages)
}
func (l *Logger) Println(messages ...interface{}) {
l.core.print(InfoLevel, l.scope, l.skip, messages)
}
func (l *Logger) Printf(format string, args ...interface{}) {
l.core.printf(InfoLevel, l.scope, l.skip, format, args)
}
func (l *Logger) Debug(messages ...interface{}) {
l.core.print(DebugLevel, l.scope, l.skip, messages)
}
func (l *Logger) Debugf(format string, args ...interface{}) {
l.core.printf(DebugLevel, l.scope, l.skip, format, args)
}
func (l *Logger) Debugv(message string, keysValues ...interface{}) {
l.core.printv(DebugLevel, l.scope, l.skip, message, keysValues)
}
func (l *Logger) Info(messages ...interface{}) {
l.core.print(InfoLevel, l.scope, l.skip, messages)
}
func (l *Logger) Infof(format string, args ...interface{}) {
l.core.printf(InfoLevel, l.scope, l.skip, format, args)
}
func (l *Logger) Infov(message string, keysValues ...interface{}) {
l.core.printv(InfoLevel, l.scope, l.skip, message, keysValues)
}
func (l *Logger) Warn(messages ...interface{}) {
l.core.print(WarnLevel, l.scope, l.skip, messages)
}
func (l *Logger) Warnf(format string, args ...interface{}) {
l.core.printf(WarnLevel, l.scope, l.skip, format, args)
}
func (l *Logger) Warnv(message string, keysValues ...interface{}) {
l.core.printv(WarnLevel, l.scope, l.skip, message, keysValues)
}
func (l *Logger) Error(messages ...interface{}) {
l.core.print(ErrorLevel, l.scope, l.skip, messages)
}
func (l *Logger) Errorf(format string, args ...interface{}) {
l.core.printf(ErrorLevel, l.scope, l.skip, format, args)
}
func (l *Logger) Errorv(message string, keysValues ...interface{}) {
l.core.printv(ErrorLevel, l.scope, l.skip, message, keysValues)
}
func (l *Logger) Fatal(messages ...interface{}) {
l.core.print(FatalLevel, l.scope, l.skip, messages)
l.core.exit()
}
func (l *Logger) Fatalln(messages ...interface{}) {
l.core.print(FatalLevel, l.scope, l.skip, messages)
l.core.exit()
}
func (l *Logger) Fatalf(format string, args ...interface{}) {
l.core.printf(FatalLevel, l.scope, l.skip, format, args)
l.core.exit()
}
func (l *Logger) Fatalv(message string, keysValues ...interface{}) {
l.core.printv(FatalLevel, l.scope, l.skip, message, keysValues)
l.core.exit()
}
func (l *Logger) Panic(messages ...interface{}) {
l.core.print(PanicLevel, l.scope, l.skip, messages)
panic(messages)
}
func (l *Logger) Panicln(messages ...interface{}) {
l.core.print(PanicLevel, l.scope, l.skip, messages)
panic(messages)
}
func (l *Logger) Panicf(format string, args ...interface{}) {
l.core.printf(PanicLevel, l.scope, l.skip, format, args)
panic(fmt.Sprintf(format, args...))
}
func (l *Logger) Panicv(message string, keysValues ...interface{}) {
l.core.printv(PanicLevel, l.scope, l.skip, message, keysValues)
panic(message)
}