From 92c3c136f9b2d9a660cbd016591483f1de71ca77 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 15 Jul 2021 21:20:29 +0800 Subject: [PATCH] improve color feature for package glog --- os/glog/glog_instance.go | 2 +- os/glog/glog_logger.go | 1 - os/glog/glog_logger_color.go | 20 ++++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/os/glog/glog_instance.go b/os/glog/glog_instance.go index f53e3e37d..42c741a03 100644 --- a/os/glog/glog_instance.go +++ b/os/glog/glog_instance.go @@ -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" ) diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index be9a4c210..3a87e9aab 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -43,7 +43,6 @@ const ( defaultFileExpire = time.Minute pathFilterKey = "/os/glog/glog" memoryLockPrefixForPrintingToFile = "glog.printToFile:" - mustWithColor = true ) const ( diff --git a/os/glog/glog_logger_color.go b/os/glog/glog_logger_color.go index 6ab51a0f3..98bf966c5 100644 --- a/os/glog/glog_logger_color.go +++ b/os/glog/glog_logger_color.go @@ -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.