Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Abingcbc committed Sep 16, 2024
1 parent 8c1ad10 commit fd478b7
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions test/engine/setup/dockercompose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"crypto/sha256"
"fmt"
"io"
"os"
"os/exec"
"strconv"
Expand Down Expand Up @@ -236,8 +237,22 @@ func (c *ComposeBooter) CopyCoreLogs() {
}
defer file.Close()
buf := make([]byte, 1024)
n, _ := file.Read(buf)
fmt.Println(string(buf[:n]))
for {
// 从文件中读取内容到缓冲区
n, err := file.Read(buf)
if err != nil && err != io.EOF {
fmt.Println("Error reading file:", err)
return
}

// 如果读取到文件结束,则退出循环
if n == 0 {
break
}

// 打印读取到的内容
fmt.Print(string(buf[:n]))
}
fmt.Println("========================================")
time.Sleep(5 * time.Second)
cmd = exec.Command("docker", "cp", c.logtailID+":/ilogtail/logtail_plugin.LOG", config.LogDir)
Expand All @@ -254,8 +269,22 @@ func (c *ComposeBooter) CopyCoreLogs() {
}
defer file.Close()
buf = make([]byte, 1024)
n, _ = file.Read(buf)
fmt.Println(string(buf[:n]))
for {
// 从文件中读取内容到缓冲区
n, err := file.Read(buf)
if err != nil && err != io.EOF {
fmt.Println("Error reading file:", err)
return
}

// 如果读取到文件结束,则退出循环
if n == 0 {
break
}

// 打印读取到的内容
fmt.Print(string(buf[:n]))
}
fmt.Println("========================================")
time.Sleep(5 * time.Second)
}
Expand Down

0 comments on commit fd478b7

Please sign in to comment.