示例#1
0
文件: util.go 项目: kevbook/hk
func colorizeMessage(color, prefix, message string, args ...interface{}) string {
	prefResult := ""
	if prefix != "" {
		prefResult = ansi.Color(prefix, color+"+b") + " " + ansi.ColorCode("reset")
	}
	return prefResult + ansi.Color(fmt.Sprintf(message, args...), color) + ansi.ColorCode("reset")
}
示例#2
0
文件: pg_helper.go 项目: kevbook/hk
func (f *fullDBInfo) MaintenanceString() string {
	valstr, _ := f.DBInfo.Info.GetString("Maintenance")
	if valstr != "" && valstr != "not required" {
		return " " + ansi.Color("!!", "red+b") + ansi.ColorCode("reset")
	}
	return ""
}
示例#3
0
文件: log.go 项目: kevbook/hk
func (c *colorizer) Writeln(p string) (n int, err error) {
	if c.filter.MatchString(p) {
		submatches := c.filter.FindStringSubmatch(p)
		return fmt.Fprintln(c.writer, ansi.Color(submatches[1], c.resolve(submatches[2]))+ansi.ColorCode("reset")+submatches[3])
	}

	return fmt.Fprintln(c.writer, p)
}