2024-05-16 16:19:36 +00:00
|
|
|
package console_fmt
|
|
|
|
|
|
|
|
import (
|
2024-05-20 06:20:13 +00:00
|
|
|
"git.ma-al.com/maal-libraries/observer/pkg/level"
|
2024-05-16 16:19:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
ColorReset = "\033[0m"
|
|
|
|
ColorRed = "\033[31m"
|
|
|
|
ColorGreen = "\033[32m"
|
|
|
|
ColorYellow = "\033[33m"
|
|
|
|
ColorBlue = "\033[34m"
|
|
|
|
ColorPurple = "\033[35m"
|
|
|
|
ColorCyan = "\033[36m"
|
|
|
|
ColorWhite = "\033[37m"
|
|
|
|
ColorBlackOnYellow = "\033[43m\033[30m"
|
|
|
|
ColorWhiteOnRed = "\033[37m\033[41m"
|
|
|
|
ColorWhiteOnRedBlinking = "\033[37m\033[41m\033[5m"
|
|
|
|
ColorBold = "\033[1m"
|
|
|
|
)
|
|
|
|
|
2024-05-17 13:31:35 +00:00
|
|
|
func Bold(txt string) string {
|
|
|
|
return ColorBold + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
2024-05-16 16:19:36 +00:00
|
|
|
func Red(txt string) string {
|
|
|
|
return ColorRed + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func Green(txt string) string {
|
|
|
|
return ColorGreen + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func Yellow(txt string) string {
|
|
|
|
return ColorYellow + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func Blue(txt string) string {
|
|
|
|
return ColorBlue + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func Purple(txt string) string {
|
|
|
|
return ColorPurple + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func Cyan(txt string) string {
|
|
|
|
return ColorCyan + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func White(txt string) string {
|
|
|
|
return ColorWhite + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func BlackOnYellow(txt string) string {
|
|
|
|
return ColorBlackOnYellow + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func WhiteOnRed(txt string) string {
|
|
|
|
return ColorWhiteOnRed + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func WhiteOnRedBlinking(txt string) string {
|
|
|
|
return ColorWhiteOnRedBlinking + txt + ColorReset
|
|
|
|
}
|
|
|
|
|
|
|
|
func SeverityLevelToColor(lvl level.SeverityLevel) string {
|
|
|
|
switch lvl {
|
|
|
|
case level.TRACE:
|
|
|
|
return ColorWhite
|
|
|
|
case level.DEBUG:
|
|
|
|
return ColorPurple
|
|
|
|
case level.INFO:
|
|
|
|
return ColorBlue
|
|
|
|
case level.WARN:
|
|
|
|
return ColorYellow
|
|
|
|
case level.ERR:
|
|
|
|
return ColorRed
|
|
|
|
case level.CRIT:
|
|
|
|
return ColorBlackOnYellow
|
|
|
|
case level.ALERT:
|
|
|
|
return ColorWhiteOnRed
|
|
|
|
default:
|
|
|
|
return ColorWhite
|
|
|
|
}
|
|
|
|
}
|