本文整理汇总了Golang中github.com/agtorre/gocolorize.Colorize类的典型用法代码示例。如果您正苦于以下问题:Golang Colorize类的具体用法?Golang Colorize怎么用?Golang Colorize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Colorize类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getColorByte
func (l *loggingT) getColorByte(s severity, b []byte) []byte {
var c gocolorize.Colorize
switch s {
case warningLog:
c = gocolorize.NewColor("yellow")
case errorLog:
c = gocolorize.NewColor("red")
case fatalLog:
c = gocolorize.NewColor("magenta")
default:
c = gocolorize.NewColor("green")
}
return []byte(c.Paint(string(b)))
}
示例2: main
func main() {
// one way to define a stateful colorizer
var green gocolorize.Colorize
green.SetColor(gocolorize.Green)
g := green.Paint
// Another way to do it
red := gocolorize.Colorize{Fg: gocolorize.Red}
r := red.Paint
// now with string construction
green_black := gocolorize.Colorize{Fg: gocolorize.Blue}
// toggle attributes
green_black.ToggleUnderline()
b := green_black.Paint
//all in 1 line
c := gocolorize.NewColor("yellow:black").Paint
//r := gocolorize.COLOR_RED
fmt.Println(b("On the twelfth day of Christmas"))
fmt.Println(b("my true love sent to me:"))
fmt.Println(g("Twelve"), c("Drummers"), r("Drumming"))
fmt.Println(g("Eleven"), c("Pipers"), r("Piping"))
fmt.Println(g("Ten"), c("Lords"), r("a Leaping"))
fmt.Println(g("Nine"), c("Ladies"), r("Dancing"))
fmt.Println(g("Eight"), c("Maids"), r("a Milking"))
fmt.Println(g("Seven"), c("Swans"), r("a Swimming"))
fmt.Println(g("Six"), c("Geese"), r("a Laying"))
fmt.Println(g("Five"), c("Golden"), r("Rings"))
fmt.Println(g("Four"), c("Calling"), r("Birds"))
fmt.Println(g("Three"), c("French"), r("Hens"))
fmt.Println(g("Two"), c("Turtle"), r("Doves"))
fmt.Println(b("and a Partridge in a Pear Tree"))
}
示例3: ColorSuccess
func ColorSuccess(message string) string {
success := gocolorize.Colorize{Fg: gocolorize.Green}
return success.Paint(message)
}
示例4: ColorError
func ColorError(message string) string {
err := gocolorize.Colorize{Fg: gocolorize.Red}
err.ToggleBold()
return err.Paint(message)
}
示例5: ColorWarning
func ColorWarning(message string) string {
warning := gocolorize.Colorize{Fg: gocolorize.Yellow}
return warning.Paint(message)
}
示例6: ColorInfo
func ColorInfo(message string) string {
info := gocolorize.Colorize{Fg: gocolorize.Magenta}
return info.Paint(message)
}
示例7: newColorLogger
func newColorLogger(out io.Writer, severity string, color gocolorize.Color) *log.Logger {
c := gocolorize.Colorize{Fg: color}
return log.New(out, c.Paint("severity:"+severity)+"\t", log.Ldate|log.Ltime|log.Lshortfile)
}