mirror of
https://github.com/astaxie/beego.git
synced 2025-06-12 19:30:39 +00:00
logger color function refactor,easy to read and run more quickly
This commit is contained in:
@ -180,7 +180,7 @@ func initColor() {
|
||||
// 3xx return White
|
||||
// 4xx return Yellow
|
||||
// 5xx return Red
|
||||
func ColorByStatus(cond bool, code int) string {
|
||||
func ColorByStatus(code int) string {
|
||||
once.Do(initColor)
|
||||
switch {
|
||||
case code >= 200 && code < 300:
|
||||
@ -202,7 +202,7 @@ func ColorByStatus(cond bool, code int) string {
|
||||
// PATCH return Green
|
||||
// HEAD return Magenta
|
||||
// OPTIONS return WHITE
|
||||
func ColorByMethod(cond bool, method string) string {
|
||||
func ColorByMethod(method string) string {
|
||||
once.Do(initColor)
|
||||
if c := colorMap[method]; c != "" {
|
||||
return c
|
||||
@ -210,6 +210,10 @@ func ColorByMethod(cond bool, method string) string {
|
||||
return reset
|
||||
}
|
||||
|
||||
func ResetColor() string {
|
||||
return reset
|
||||
}
|
||||
|
||||
// Guard Mutex to guarantee atomic of W32Debug(string) function
|
||||
var mu sync.Mutex
|
||||
|
||||
|
Reference in New Issue
Block a user