log/syslog: report errors from write

Fixes #5541.
This time for sure.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/9668043
This commit is contained in:
Rob Pike 2013-05-22 12:45:52 -07:00
parent dbee8ad0f9
commit e17a6d4b9d
1 changed files with 7 additions and 1 deletions

View File

@ -258,9 +258,15 @@ func (w *Writer) write(p Priority, msg string) (int, error) {
}
timestamp := time.Now().Format(time.RFC3339)
fmt.Fprintf(w.conn, "<%d>%s %s %s[%d]: %s%s",
_, err := fmt.Fprintf(w.conn, "<%d>%s %s %s[%d]: %s%s",
p, timestamp, w.hostname,
w.tag, os.Getpid(), msg, nl)
if err != nil {
return 0, err
}
// Note: return the length of the input, not the number of
// bytes printed by Fprintf, because this must behave like
// an io.Writer.
return len(msg), nil
}