mirror of
https://github.com/beego/bee.git
synced 2025-07-04 21:50:18 +00:00
Update LICENSE
This commit is contained in:
18
util.go
18
util.go
@ -20,6 +20,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Go is a basic promise implementation: it wraps calls a function in a goroutine
|
||||
@ -55,6 +56,11 @@ const (
|
||||
Magenta
|
||||
//NRed = uint8(31) // Normal
|
||||
EndColor = "\033[0m"
|
||||
|
||||
TRAC = "TRAC"
|
||||
ERRO = "ERRO"
|
||||
WARN = "WARN"
|
||||
SUCC = "SUCC"
|
||||
)
|
||||
|
||||
// ColorLog colors log and print to stdout.
|
||||
@ -78,7 +84,6 @@ func ColorLogS(format string, a ...interface{}) string {
|
||||
var clog string
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
|
||||
// Level.
|
||||
i := strings.Index(log, "]")
|
||||
if log[0] == '[' && i > -1 {
|
||||
@ -125,20 +130,21 @@ func ColorLogS(format string, a ...interface{}) string {
|
||||
log = clog + log
|
||||
}
|
||||
|
||||
return log
|
||||
return strings.TrimPrefix(
|
||||
time.Now().Format("2006-01-02 03:04:05 "), "20") + log
|
||||
}
|
||||
|
||||
// getColorLevel returns colored level string by given level.
|
||||
func getColorLevel(level string) string {
|
||||
level = strings.ToUpper(level)
|
||||
switch level {
|
||||
case "TRAC":
|
||||
case TRAC:
|
||||
return fmt.Sprintf("\033[%dm%s\033[0m", Blue, level)
|
||||
case "ERRO":
|
||||
case ERRO:
|
||||
return fmt.Sprintf("\033[%dm%s\033[0m", Red, level)
|
||||
case "WARN":
|
||||
case WARN:
|
||||
return fmt.Sprintf("\033[%dm%s\033[0m", Magenta, level)
|
||||
case "SUCC":
|
||||
case SUCC:
|
||||
return fmt.Sprintf("\033[%dm%s\033[0m", Green, level)
|
||||
default:
|
||||
return level
|
||||
|
Reference in New Issue
Block a user