Skip to content

Commit

Permalink
Merge pull request #52 from subicura/master
Browse files Browse the repository at this point in the history
fix #51
  • Loading branch information
ddollar committed Feb 17, 2015
2 parents 1c127e8 + abbc8f8 commit f0fe977
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions fixtures/multiline/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stdout1: ruby ./stdout.rb
stdout2: ruby ./stdout.rb
13 changes: 13 additions & 0 deletions fixtures/multiline/stdout.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby

$stdout.sync = true

puts "a"
sleep 1
puts "a\nb"
sleep 1
puts "a\nb\nc"
sleep 1
puts "a\nb\nc\nd"
sleep 1
puts "finish!"
21 changes: 13 additions & 8 deletions outlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,25 @@ func (of *OutletFactory) LineReader(wg *sync.WaitGroup, name string, index int,

for {
buf := make([]byte, 1024)
v, _ := reader.Read(buf)

if v == 0 {

if n, err := reader.Read(buf); err != nil {
return
} else {
buf = buf[:n]
}

idx := bytes.IndexByte(buf, '\n')
if idx >= 0 {
buffer.Write(buf[0:idx])
for {
i := bytes.IndexByte(buf, '\n')
if i < 0 {
break
}
buffer.Write(buf[0:i])
of.WriteLine(name, buffer.String(), color, ct.None, isError)
buffer.Reset()
} else {
buffer.Write(buf)
buf = buf[i+1:]
}

buffer.Write(buf)
}
}

Expand Down

0 comments on commit f0fe977

Please sign in to comment.