mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-09-11 17:15:44 +08:00
fix: Fix container log download ANSI control code garbled issue (#9479)
This commit is contained in:
parent
b20411f8f1
commit
54ca40bbcd
1 changed files with 4 additions and 1 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -1064,9 +1065,11 @@ func (u *ContainerService) DownloadContainerLogs(containerType, container, since
|
|||
errCh := make(chan error)
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
var ansiRegex = regexp.MustCompile(`\x1b\[[0-9;?]*[A-Za-z]|\x1b=|\x1b>`)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if _, err := tempFile.WriteString(line + "\n"); err != nil {
|
||||
cleanLine := ansiRegex.ReplaceAllString(line, "")
|
||||
if _, err := tempFile.WriteString(cleanLine + "\n"); err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue