log errors in scanner and manually close logging pipe if we hit an error in the scanner

This commit is contained in:
Megan Marsh 2019-11-11 09:19:35 -08:00
parent 88530a7944
commit 60cf4f6014
1 changed files with 4 additions and 0 deletions

4
log.go
View File

@ -43,6 +43,10 @@ func logOutput() (logOutput io.Writer, err error) {
}
os.Stderr.WriteString(fmt.Sprint(scanner.Text() + "\n"))
}
if err := scanner.Err(); err != nil {
os.Stderr.WriteString(err.Error())
w.Close()
}
}(scanner)
logOutput = w
}