| 107 | } |
| 108 | |
| 109 | func TaskLog() *tview.TextView { |
| 110 | log := tview.NewTextView().SetDynamicColors(true).ScrollToEnd() |
| 111 | if logs.LogFilePath == "" { |
| 112 | log.SetText("log file not found") |
| 113 | return log |
| 114 | } |
| 115 | f, err := os.Open(logs.LogFilePath) |
| 116 | if err != nil { |
| 117 | log.SetText(fmt.Sprintf("read log file err:\n%s", err)) |
| 118 | return log |
| 119 | } |
| 120 | lines := []string{} |
| 121 | lineNum := 0 |
| 122 | scanner := bufio.NewScanner(f) |
| 123 | color := "white" |
| 124 | for scanner.Scan() { |
| 125 | lineNum++ |
| 126 | line := scanner.Text() |
| 127 | if i := strings.Index(line, " "); i != -1 { |
| 128 | if c, ok := colorLogMap[line[:i]]; ok { |
| 129 | color = c |
| 130 | line = fmt.Sprintf("%s[%s%s[white]", color, color, line[1:]) |
| 131 | } |
| 132 | } |
| 133 | line = fmt.Sprintf("%s%s[white]", color, line) |
| 134 | lines = append(lines, fmt.Sprintf("[grey]%d:[white]%s", lineNum, line)) |
| 135 | } |
| 136 | log.SetText(strings.Join(lines, "\r\n")) |
| 137 | return log |
| 138 | } |
| 139 | |
| 140 | func DepTree(report format.Report) *tview.TreeView { |
| 141 | |