server: ensure last lines are always logged

This commit is contained in:
Matthew Penner 2022-01-19 18:22:34 -07:00
parent 13a9ee9474
commit c27e06bcb9
No known key found for this signature in database
GPG Key ID: 31311906AD4CF6D6

View File

@ -68,6 +68,8 @@ func ScanReader(r io.Reader, callback func(line []byte)) error {
return err
}
}
// Ensure that the scanner is always able to read the last line.
_, _ = buf.Write([]byte("\r\n"))
// Publish the line for this loop. Break on new-line characters so every line is sent as a single
// output event, otherwise you get funky handling in the browser console.
s := bufio.NewScanner(buf)