Skip to content

Commit

Permalink
fix: set scanner buffer (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
icey-yu committed Jul 30, 2024
1 parent 04c13b5 commit ba25eca
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/third/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
"time"
)

const (
buffer = 10 * 1024 * 1024
)

// UploadLogs uploadLogs.
func (c *Third) UploadLogs(ctx context.Context, line int, ex string, progress Progress) (err error) {
if c.logUploadLock.TryLock() {
Expand Down Expand Up @@ -160,6 +164,9 @@ func readLastNLines(filename string, n int) ([]string, error) {
count := 0

scanner := bufio.NewScanner(f)
buf := make([]byte, buffer)
scanner.Buffer(buf, buffer)

for scanner.Scan() {
lines[count%n] = scanner.Text()
count++
Expand Down

0 comments on commit ba25eca

Please sign in to comment.