Exemplo n.º 1
0
Arquivo: logger.go Projeto: sqp/godock
// 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...)...)
}
Exemplo n.º 2
0
// Colored set colored text content for given row.
//
func (line Line) Colored(row int, newcolor, text string) {
	origsize := len(text)
	line.SetColSize(row, origsize) // Size of text without formating.
	if newcolor == "" {
		line.content[row] = text
	} else {
		line.content[row] = color.Colored(text, newcolor)
		line.colorDelta[row] += len(line.content[row]) - origsize
	}
}
Exemplo n.º 3
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
}
Exemplo n.º 4
0
Arquivo: logger.go Projeto: sqp/godock
// 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...)
}