Merge pull request #225 from desimone/patch-1

provisioners/remote-exec: Use scanner instead of buffer read line
This commit is contained in:
Mitchell Hashimoto 2014-08-25 09:02:58 -07:00
commit b7ec5cc9f8
1 changed files with 6 additions and 7 deletions

View File

@ -245,12 +245,11 @@ func retryFunc(timeout time.Duration, f func() error) error {
// of a remote command to log output for users.
func streamLogs(r io.ReadCloser, name string) {
defer r.Close()
bufR := bufio.NewReader(r)
for {
line, err := bufR.ReadString('\n')
if err != nil {
return
}
log.Printf("remote-exec: %s: %s", name, line)
scanner := bufio.NewScanner(r)
for scanner.Scan() {
log.Printf("remote-exec: %s: %s", name, scanner.Text())
}
if err := scanner.Err(); err != nil {
return
}
}