improve color feature for package glog

This commit is contained in:
John Guo 2021-07-15 21:20:29 +08:00
parent fae4dea37a
commit 92c3c136f9
3 changed files with 17 additions and 6 deletions

View File

@ -9,7 +9,7 @@ package glog
import "github.com/gogf/gf/container/gmap"
const (
// Default group name for instance usage.
// DefaultName is the default group name for instance usage.
DefaultName = "default"
)

View File

@ -43,7 +43,6 @@ const (
defaultFileExpire = time.Minute
pathFilterKey = "/os/glog/glog"
memoryLockPrefixForPrintingToFile = "glog.printToFile:"
mustWithColor = true
)
const (

View File

@ -19,16 +19,28 @@ const (
COLOR_WHITE
)
// Foreground Hi-Intensity text colors
const (
COLOR_HI_BLACK = 90 + iota
COLOR_HI_RED
COLOR_HI_GREEN
COLOR_HI_YELLOW
COLOR_HI_BLUE
COLOR_HI_MAGENTA
COLOR_HI_CYAN
COLOR_HI_WHITE
)
// defaultLevelColor defines the default level and its mapping prefix string.
var defaultLevelColor = map[int]int{
LEVEL_DEBU: COLOR_YELLOW,
LEVEL_INFO: COLOR_GREEN,
LEVEL_NOTI: COLOR_CYAN,
LEVEL_WARN: COLOR_YELLOW,
LEVEL_WARN: COLOR_MAGENTA,
LEVEL_ERRO: COLOR_RED,
LEVEL_CRIT: COLOR_RED,
LEVEL_PANI: COLOR_RED,
LEVEL_FATA: COLOR_RED,
LEVEL_CRIT: COLOR_HI_RED,
LEVEL_PANI: COLOR_HI_RED,
LEVEL_FATA: COLOR_HI_RED,
}
// getColoredStr returns a string that is colored by given color.