From 426196c23fa4be59ad024f5d6891b1de047581f9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 3 Nov 2021 09:22:49 +0200 Subject: Add integration test for long line splitting - Also fixed a bug regarding this along the way --- internal/io/fs/readfile.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/io/fs') diff --git a/internal/io/fs/readfile.go b/internal/io/fs/readfile.go index e499853..806cd32 100644 --- a/internal/io/fs/readfile.go +++ b/internal/io/fs/readfile.go @@ -13,6 +13,7 @@ import ( "sync" "time" + "github.com/mimecast/dtail/internal/config" "github.com/mimecast/dtail/internal/io/dlog" "github.com/mimecast/dtail/internal/io/line" "github.com/mimecast/dtail/internal/io/pool" @@ -167,7 +168,6 @@ func (f readFile) read(ctx context.Context, fd *os.File, reader *bufio.Reader, rawLines chan *bytes.Buffer, truncate <-chan struct{}) error { var offset uint64 - lineLengthThreshold := 1024 * 1024 // 1mb warnedAboutLongLine := false message := pool.BytesBuffer.Get().(*bytes.Buffer) @@ -214,13 +214,13 @@ func (f readFile) read(ctx context.Context, fd *os.File, reader *bufio.Reader, return nil } default: - // TODO: Add integration test with input file having a very long line. - if message.Len() >= lineLengthThreshold { + if message.Len() >= config.Server.MaxLineLength { if !warnedAboutLongLine { f.serverMessages <- dlog.Common.Warn(f.filePath, "Long log line, splitting into multiple lines") warnedAboutLongLine = true } + message.WriteByte('\n') select { case rawLines <- message: message = pool.BytesBuffer.Get().(*bytes.Buffer) -- cgit v1.2.3