Feat: auth middleware for complex request
This commit is contained in:
@@ -33,13 +33,28 @@ var colors = map[string]func(a ...interface{}) string{
|
||||
"Debug": color.New(color.FgWhite).Add(color.Bold).SprintFunc(),
|
||||
}
|
||||
|
||||
// 不同级别前缀与时间的间隔,保持宽度一致
|
||||
var spaces = map[string]string{
|
||||
"Warning": "",
|
||||
"Panic": " ",
|
||||
"Error": " ",
|
||||
"Info": " ",
|
||||
"Debug": " ",
|
||||
}
|
||||
|
||||
// Println 打印
|
||||
func (ll *Logger) Println(prefix string, msg string) {
|
||||
// TODO Release时去掉
|
||||
color.NoColor = false
|
||||
|
||||
c := color.New()
|
||||
_, _ = c.Printf("%s %s %s\n", colors[prefix]("["+prefix+"]"), time.Now().Format("2006-01-02 15:04:05"), msg)
|
||||
_, _ = c.Printf(
|
||||
"%s%s %s %s\n",
|
||||
colors[prefix]("["+prefix+"]"),
|
||||
spaces[prefix],
|
||||
time.Now().Format("2006-01-02 15:04:05"),
|
||||
msg,
|
||||
)
|
||||
}
|
||||
|
||||
// Panic 极端错误
|
||||
|
||||
Reference in New Issue
Block a user