Beispiel #1
0
// Format returns a formatted message in the given color with endline.
//
func Format(col, sender, msg string, more ...interface{}) string {
	return fmt.Sprintln(append([]interface{}{
		time.Now().Format("15:04:05"),
		color.Yellow(sender),
		strhelp.Bracket(color.Colored(msg, col))},
		more...)...)
}
Beispiel #2
0
// String formats the fields content with colored output.
//
func (fields Fields) String() string {
	fields = append([]Field{
		{Name, cdglobal.AppVersion},
		{"  go       ", fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)},
	}, List...)

	if cdglobal.BuildDate != "" {
		fields = append(fields,
			Field{"  Compiled ", cdglobal.BuildDate},
			Field{"  Git Hash ", cdglobal.GitHash},
		)
	}

	out := ""
	for _, line := range fields {
		out += strhelp.Bracket(color.Colored(line.K, color.FgGreen)) + " " + line.V + "\n"
	}
	return out
}
Beispiel #3
0
// Render displays the msg argument in the given color. The colored message is
// passed with others to classic println.
//
func Render(col, msg string, more ...interface{}) {
	// println(, list...)
	list := append([]interface{}{time.Now().Format("15:04:05"), color.Yellow(caller()), strhelp.Bracket(color.Colored(msg, col))}, more...)
	fmt.Println(list...)
	// log.Println(list...)
}