From a0277789493f3a757f63d941387656e81567d5a9 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Tue, 6 Jun 2023 16:52:31 +0200 Subject: [PATCH] assume we receive logs by lines and don't ignore those without EOL Signed-off-by: Nicolas De Loof --- pkg/utils/writer.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/utils/writer.go b/pkg/utils/writer.go index 83f0bf5c3cb..762d7ce1277 100644 --- a/pkg/utils/writer.go +++ b/pkg/utils/writer.go @@ -43,11 +43,14 @@ func (s *splitWriter) Write(b []byte) (int, error) { for { b = s.buffer.Bytes() index := bytes.Index(b, []byte{'\n'}) - if index < 0 { + if index > 0 { + line := s.buffer.Next(index + 1) + s.consumer(string(line[:len(line)-1])) + } else { + s.consumer(s.buffer.String()) + s.buffer.Reset() break } - line := s.buffer.Next(index + 1) - s.consumer(string(line[:len(line)-1])) } return n, nil }