- j[:buf][stream] << buf
- if j[:buf][stream].index "\n"
- lines = j[:buf][stream].lines("\n").to_a
- if j[:buf][stream][-1] == "\n"
- j[:buf][stream] = ''
- else
- j[:buf][stream] = lines.pop
- end
+ # Add to a the buffer
+ streambuf << buf
+
+ # Check for at least one complete line
+ if streambuf.index "\n"
+ lines = streambuf.lines("\n").to_a
+
+ # check if the last line is partial or not
+ j[:buf][stream] = if streambuf[-1] == "\n"
+ # nope
+ ''
+ else
+ # Put the partial line back into the buffer
+ lines.pop
+ end
+
+ # Now spool the lines to the log output buffer