Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log/syslog: write() does not return error so reconnects won't work #5541

Closed
gopherbot opened this issue May 22, 2013 · 9 comments
Closed

log/syslog: write() does not return error so reconnects won't work #5541

gopherbot opened this issue May 22, 2013 · 9 comments

Comments

@gopherbot
Copy link

by chiparus:

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

Let a program log to syslog. When you restart the syslog daemon, logging stops. This is
because the write() function does not pass the error (if any) from fmt.Fprintf() to the
caller. In fact, write() always returns nil so errors were never detected.

This little patch fixes it:

diff -r 45468e9eae1f src/pkg/log/syslog/syslog.go
--- a/src/pkg/log/syslog/syslog.go  Wed May 22 18:51:15 2013 +0800
+++ b/src/pkg/log/syslog/syslog.go  Wed May 22 14:57:31 2013 +0200
@@ -258,10 +258,9 @@
    }
 
    timestamp := time.Now().Format(time.RFC3339)
-   fmt.Fprintf(w.conn, "<%d>%s %s %s[%d]: %s%s",
+   return fmt.Fprintf(w.conn, "<%d>%s %s %s[%d]: %s%s",
        p, timestamp, w.hostname,
        w.tag, os.Getpid(), msg, nl)
-   return len(msg), nil
 }
 
 // NewLogger creates a log.Logger whose output is written to
@robpike
Copy link
Contributor

robpike commented May 22, 2013

Comment 1:

Status changed to Started.

@robpike
Copy link
Contributor

robpike commented May 22, 2013

Comment 2:

This issue was closed by revision 4c2df76.

Status changed to Fixed.

@robpike
Copy link
Contributor

robpike commented May 22, 2013

Comment 3:

Although I submitted a "fix", the fix is wrong. The original code is correct because the
write must return the length of the input slice.

Status changed to Invalid.

@robpike
Copy link
Contributor

robpike commented May 22, 2013

Comment 4:

Accepting the bug now, but not the proposed fix.

Labels changed: added priority-soon, removed priority-triage.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented May 22, 2013

Comment 5:

This issue was closed by revision f6c7b33.

Status changed to Fixed.

@minux
Copy link
Member

minux commented May 22, 2013

Comment 6:

revision 66517e57fb48 reverted revision ac7877558dce.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented May 22, 2013

Comment 7:

This issue was closed by revision e17a6d4.

Status changed to Fixed.

@gopherbot
Copy link
Author

Comment 8 by eric.entzel:

This fix doesn't appear to be in the 1.1.1 release - is it expected to go into 1.1.2?

@davecheney
Copy link
Contributor

Comment 9:

1.1.x is only for critical bugs without workaround. This will land in 1.2.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants