示例#1
0
文件: logger.go 项目: 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...)...)
}
示例#2
0
文件: logger.go 项目: 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...)
}
示例#3
0
文件: logger.go 项目: sqp/godock
// Warn test and log the error as Warning type. Return true if an error was found.
//
func Warn(e error, msg string) (fail bool) {
	return l(e, color.Yellow("Warning"), msg)
}
示例#4
0
文件: logger.go 项目: sqp/godock
// SetPrefix set the prefix of the logger display.
//
func SetPrefix(pre string) {
	std.SetPrefix(color.Yellow("[" + pre + "] "))
	log.SetPrefix(color.Yellow("[" + pre + "] "))
	log.SetFlags(log.Ltime)
}