MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / TaskLog

Function TaskLog

cmd/ui/ui.go:109–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107}
108
109func 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
140func DepTree(report format.Report) *tview.TreeView {
141

Callers 1

OpenUIFunction · 0.85

Calls 2

ScanMethod · 0.80
IndexMethod · 0.80

Tested by

no test coverage detected