Skip to content

Commit

Permalink
Bug Fix #57: Too long log lines caused output to stop.
Browse files Browse the repository at this point in the history
  • Loading branch information
F1bonacc1 committed Jan 28, 2024
1 parent e7dbe22 commit cc5a927
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
11 changes: 11 additions & 0 deletions issues/issue_57/long_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env python3

import datetime

cntr=0
line = "="
while True:
print("long line number {0}: {1}".format(cntr, line))
cntr += 1
line += line

2 changes: 1 addition & 1 deletion issues/issue_57/process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ log_level: debug

processes:
bad_script:
command: "./too_chatty.py"
command: "./long_log.py"

_pc_log:
command: "tail -f -n100 process-compose-${USER}.log"
Expand Down
23 changes: 13 additions & 10 deletions src/app/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,19 @@ func (p *Process) handleInput(pipe io.WriteCloser) {
}

func (p *Process) handleOutput(pipe io.ReadCloser, handler func(message string)) {
outscanner := bufio.NewScanner(pipe)
//outscanner.Buffer(make([]byte, 0, 1024), 1024*1024*10)
outscanner.Split(bufio.ScanLines)
for outscanner.Scan() {
handler(outscanner.Text())
}
if err := outscanner.Err(); err != nil {
log.Err(err).
Str("process", p.getName()).
Msg("error reading from stdout")
reader := bufio.NewReader(pipe)
for {
line, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
break
}
log.Err(err).
Str("process", p.getName()).
Msg("error reading from stdout")
break
}
handler(strings.TrimSuffix(line, "\n"))
}
}

Expand Down

0 comments on commit cc5a927

Please sign in to comment.