diff --git a/bin/bunyan b/bin/bunyan index 70bee22..4e1eb03 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -206,7 +206,7 @@ function emitNextRecord(opts, stylize) } } - if (!ready) { + if (!ready || minfile === undefined) { for (ofile in streams) { if (!streams[ofile].stream || streams[ofile].done) continue; @@ -703,6 +703,7 @@ function processFile(file, opts, stylize, callback) { streams[file].stream = stream; stream.on('error', function (err) { + streams[file].done = true; callback(err); }); @@ -726,11 +727,13 @@ function processFile(file, opts, stylize, callback) { }); stream.on('end', function () { + streams[file].done = true; if (leftover) { handleLogLine(file, leftover, opts, stylize); leftover = ''; + } else { + emitNextRecord(opts, stylize); } - streams[file].done = true; callback(); }); } diff --git a/test/corpus/log1.log b/test/corpus/log1.log new file mode 100644 index 0000000..1482e98 --- /dev/null +++ b/test/corpus/log1.log @@ -0,0 +1,4 @@ +{"name":"agent1","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T16:57:55.586Z","v":0} +{"name":"agent1","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T17:02:49.339Z","v":0} +{"name":"agent1","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T17:02:49.404Z","v":0} +{"name":"agent1","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T17:02:49.404Z","v":0} diff --git a/test/corpus/log2.log b/test/corpus/log2.log new file mode 100644 index 0000000..e636081 --- /dev/null +++ b/test/corpus/log2.log @@ -0,0 +1,5 @@ +{"name":"agent2","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T16:58:55.586Z","v":0} +{"name":"agent2","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T17:01:49.339Z","v":0} +{"name":"agent2","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T17:02:47.404Z","v":0} +{"name":"agent2","pid":73267,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T17:02:57.404Z","v":0} +{"name":"agent2","pid":76156,"hostname":"headnode","level":30,"msg":"message","time":"2012-05-08T17:08:01.105Z","v":0}