filterOutput 过滤输出
(output, filter string)
| 564 | |
| 565 | // filterOutput 过滤输出 |
| 566 | func (tm *FileTaskManager) filterOutput(output, filter string) string { |
| 567 | if filter == "" || output == "" { |
| 568 | return output |
| 569 | } |
| 570 | |
| 571 | regex, err := regexp.Compile(filter) |
| 572 | if err != nil { |
| 573 | return output |
| 574 | } |
| 575 | |
| 576 | lines := strings.Split(output, "\n") |
| 577 | var filteredLines []string |
| 578 | |
| 579 | for _, line := range lines { |
| 580 | if regex.MatchString(line) { |
| 581 | filteredLines = append(filteredLines, line) |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | return strings.Join(filteredLines, "\n") |
| 586 | } |
| 587 | |
| 588 | // limitLines 限制行数 |
| 589 | func (tm *FileTaskManager) limitLines(output string, maxLines int) string { |