]> Cypherpunks repositories - gostls13.git/commitdiff
log/syslog: report errors from write
authorRob Pike <r@golang.org>
Wed, 22 May 2013 19:45:52 +0000 (12:45 -0700)
committerRob Pike <r@golang.org>
Wed, 22 May 2013 19:45:52 +0000 (12:45 -0700)
Fixes #5541.
This time for sure.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/9668043

src/pkg/log/syslog/syslog.go

index 8bdd9825e1cdb045800047c12a9cc5df1d4e2d65..e04a2eb553099f4f6e0ec20d39d1089e816d4b91 100644 (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
 }