Skip to content

Commit

Permalink
assume we receive logs by lines and don't ignore those without EOL
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Jun 6, 2023
1 parent 629c9f6 commit a027778
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/utils/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit a027778

Please sign in to comment.