diff options
| author | Paul Buetow <paul@buetow.org> | 2021-11-03 09:22:49 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2021-11-03 09:22:49 +0200 |
| commit | 426196c23fa4be59ad024f5d6891b1de047581f9 (patch) | |
| tree | 9024ac46e2fcd9ad1dd6c9ba14286e1b1c514726 /internal/io | |
| parent | 69b4659b2e644506476a7285970121b3fc98c15b (diff) | |
Add integration test for long line splitting - Also fixed a bug regarding this along the way
Diffstat (limited to 'internal/io')
| -rw-r--r-- | internal/io/fs/readfile.go | 6 |
1 files changed, 3 insertions, 3 deletions
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) |
