-
Notifications
You must be signed in to change notification settings - Fork 7
/
print_darwin.go
217 lines (188 loc) · 6.15 KB
/
print_darwin.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
package log
import "fmt"
//Trace级别的打印信息,输入要打印的内容,会自动换行
func Trace(v ...interface{}) {
trace := loggers[Leveltrace]
s := fmt.Sprint(v...)
message := joint(lTrace, s, colorGreen)
trace.Println(message)
}
//Trace级别的打印信息,第一个参数输入格式,第二个参数输入要打印的内容,类似fmt.Printf
func Tracef(format string, v ...interface{}) {
trace := loggers[Leveltrace]
s := fmt.Sprintf(format, v...)
message := joint(lTrace, s, colorGreen)
trace.Println(message)
}
//Info级别的打印信息,输入要打印的内容,会自动换行
func Info(v ...interface{}) {
info := loggers[Levelinfo]
s := fmt.Sprint(v...)
message := joint(lInfo, s, colorBlue)
info.Println(message)
}
//Infof级别的打印信息,第一个参数输入格式,第二个参数输入要打印的内容,类似fmt.Printf
func Infof(format string, v ...interface{}) {
info := loggers[Levelinfo]
s := fmt.Sprintf(format, v...)
message := joint(lInfo, s, colorBlue)
info.Println(message)
}
//Debug级别的打印信息,输入要打印的内容,会自动换行
func Debug(v ...interface{}) {
debug := loggers[Leveldebug]
s := fmt.Sprint(v...)
message := joint(lDebug, s, colorDarkblue)
debug.Println(message)
}
//Debug级别的打印信息,第一个参数输入格式,第二个参数输入要打印的内容,类似fmt.Printf
func Debugf(format string, v ...interface{}) {
debug := loggers[Leveldebug]
s := fmt.Sprintf(format, v...)
message := joint(lDebug, s, colorDarkblue)
debug.Println(message)
}
//Warn级别的打印信息,输入要打印的内容,会自动换行
func Warn(v ...interface{}) {
warn := loggers[Levelwarn]
s := fmt.Sprint(v...)
message := joint(lWarn, s, colorYellow)
warn.Println(message)
}
//Warn级别的打印信息,第一个参数输入格式,第二个参数输入要打印的内容,类似fmt.Printf
func Warnf(format string, v ...interface{}) {
warn := loggers[Levelwarn]
s := fmt.Sprintf(format, v...)
message := joint(lWarn, s, colorYellow)
warn.Println(message)
}
//Error级别的打印信息,输入要打印的内容,会自动换行
func Error(v ...interface{}) {
e := loggers[Levelerror]
s := fmt.Sprint(v...)
message := joint(lError, s, colorRed)
e.Println(message)
}
//Errorf级别的打印信息,第一个参数输入格式,第二个参数输入要打印的内容,类似fmt.Printf
func Errorf(format string, v ...interface{}) {
e := loggers[Levelerror]
s := fmt.Sprintf(format, v...)
message := joint(lError, s, colorRed)
e.Println(message)
}
//Panic级别的打印信息,输入要打印的内容,会自动换行
// 执行Panic,递归执行每层的defer后中断程序
func Panic(v ...interface{}) {
p := loggers[Levelpanic]
s := fmt.Sprint(v...)
message := joint(lPanic, s, colorRed)
p.Panicln(message)
}
//Panicf级别的打印信息,第一个参数输入格式,第二个参数输入要打印的内容
// 输出错误信息后,执行Panic(),递归执行每层的defer后中断程序
func Panicf(format string, v ...interface{}) {
p := loggers[Levelpanic]
s := fmt.Sprintf(format, v...)
message := joint(lPanic, s, colorRed)
p.Panicln(message)
}
//Fatal级别的打印信息,输入要打印的内容,会自动换行
// 输出错误信息后,直接执行os.exit(1)中断程序
func Fatal(v ...interface{}) {
falat := loggers[Levelfatal]
s := fmt.Sprint(v...)
message := joint(lFatal, s, colorPurple)
falat.Fatalln(message)
}
//Fatal级别的打印信息,第一个参数输入格式,第二个参数输入要打印的内容
// 输出错误信息后,直接执行os.exit(1)中断程序
func Fatalf(format string, v ...interface{}) {
falat := loggers[Levelfatal]
s := fmt.Sprintf(format, v...)
message := joint(lFatal, s, colorPurple)
falat.Fatalln(message)
}
func (l mylog) Trace(v ...interface{}) {
trace := l.loggers[Leveltrace]
s := fmt.Sprint(v...)
message := l.joint(lTrace, s, colorGreen)
trace.Println(message)
}
func (l mylog) Tracef(format string, v ...interface{}) {
trace := l.loggers[Leveltrace]
s := fmt.Sprintf(format, v...)
message := l.joint(lTrace, s, colorGreen)
trace.Println(message)
}
func (l mylog) Info(v ...interface{}) {
info := l.loggers[Levelinfo]
s := fmt.Sprint(v...)
message := l.joint(lInfo, s, colorBlue)
info.Println(message)
}
func (l mylog) Infof(format string, v ...interface{}) {
info := l.loggers[Levelinfo]
s := fmt.Sprintf(format, v...)
message := l.joint(lInfo, s, colorBlue)
info.Println(message)
}
func (l mylog) Debug(v ...interface{}) {
debug := l.loggers[Leveldebug]
s := fmt.Sprint(v...)
message := l.joint(lDebug, s, colorDarkblue)
debug.Println(message)
}
func (l mylog) Debugf(format string, v ...interface{}) {
debug := l.loggers[Leveldebug]
s := fmt.Sprintf(format, v...)
message := l.joint(lDebug, s, colorDarkblue)
debug.Println(message)
}
func (l mylog) Warn(v ...interface{}) {
warn := l.loggers[Levelwarn]
s := fmt.Sprint(v...)
message := l.joint(lWarn, s, colorYellow)
warn.Println(message)
}
func (l mylog) Warnf(format string, v ...interface{}) {
warn := l.loggers[Levelwarn]
s := fmt.Sprintf(format, v...)
message := l.joint(lWarn, s, colorYellow)
warn.Println(message)
}
func (l mylog) Error(v ...interface{}) {
e := l.loggers[Levelerror]
s := fmt.Sprint(v...)
message := l.joint(lError, s, colorRed)
e.Println(message)
}
func (l mylog) Errorf(format string, v ...interface{}) {
e := l.loggers[Levelerror]
s := fmt.Sprintf(format, v...)
message := l.joint(lError, s, colorRed)
e.Println(message)
}
func (l mylog) Panic(v ...interface{}) {
p := l.loggers[Levelpanic]
s := fmt.Sprint(v...)
message := l.joint(lPanic, s, colorRed)
p.Panicln(message)
}
func (l mylog) Panicf(format string, v ...interface{}) {
p := l.loggers[Levelpanic]
s := fmt.Sprintf(format, v...)
message := l.joint(lPanic, s, colorRed)
p.Panicln(message)
}
func (l mylog) Fatal(v ...interface{}) {
falat := l.loggers[Levelfatal]
s := fmt.Sprint(v...)
message := l.joint(lFatal, s, colorPurple)
falat.Fatalln(message)
}
func (l mylog) Fatalf(format string, v ...interface{}) {
falat := l.loggers[Levelfatal]
s := fmt.Sprintf(format, v...)
message := l.joint(lFatal, s, colorPurple)
falat.Fatalln(message)
}