Skip to content

Commit c9b1e66

Browse files
committed
Implemented reader framing
1 parent 56afe2d commit c9b1e66

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/log.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ Log.prototype = {
104104
*/
105105

106106
read: function(){
107-
var self = this;
107+
var buf = ''
108+
, self = this;
108109
this.stream.setEncoding('ascii');
109110
this.stream.on('data', function(chunk){
110-
chunk.split('\n').map(function(line){
111+
buf += chunk;
112+
if ('\n' != buf[buf.length - 1]) return;
113+
buf.split('\n').map(function(line){
111114
if (!line.length) return;
112115
var captures = line.match(/^\[([^\]]+)\] (\w+) (.*)/);
113116
var obj = {
@@ -118,6 +121,7 @@ Log.prototype = {
118121
};
119122
self.emit('line', obj);
120123
});
124+
buf = '';
121125
});
122126
},
123127

0 commit comments

Comments
 (0)