示例#1
0
文件: apps.go 项目: naveenholla/deis
// printLogs prints each log line with a color matched to its category.
func printLogs(logs string) error {
	for _, log := range strings.Split(strings.Trim(logs, `\n`), `\n`) {
		category := "unknown"
		parts := strings.Split(strings.Split(log, ": ")[0], " ")
		if len(parts) >= 2 {
			category = parts[1]
		}
		colorVars := map[string]string{
			"Color": chooseColor(category),
			"Log":   log,
		}
		fmt.Println(prettyprint.ColorizeVars("{{.V.Color}}{{.V.Log}}{{.C.Default}}", colorVars))
	}

	return nil
}
示例#2
0
文件: apps.go 项目: rsackler/deis
// AppLogs returns the logs from an app.
func AppLogs(appID string, lines int) error {
	c, appID, err := load(appID)

	if err != nil {
		return err
	}

	logs, err := apps.Logs(c, appID, lines)

	if err != nil {
		return err
	}

	for _, log := range strings.Split(strings.Trim(logs, `\n`), `\n`) {
		catagory := strings.Split(strings.Split(log, ": ")[0], " ")[1]
		colorVars := map[string]string{
			"Color": chooseColor(catagory),
			"Log":   log,
		}
		fmt.Println(prettyprint.ColorizeVars("{{.V.Color}}{{.V.Log}}{{.C.Default}}", colorVars))
	}

	return nil
}