Include number of bytes written as debugging output.

This commit is contained in:
Alex Payne 2014-09-13 13:03:40 -07:00
parent 29c4caff54
commit 91f92800d7
1 changed files with 2 additions and 0 deletions

View File

@ -34,6 +34,7 @@ func (hook *PapertrailHook) Fire(entry *logrus.Entry) error {
payload := fmt.Sprintf("<22> %s %s: [%s] %s", date, hook.AppName, entry.Data["level"], entry.Message) payload := fmt.Sprintf("<22> %s %s: [%s] %s", date, hook.AppName, entry.Data["level"], entry.Message)
line, err := entry.String() line, err := entry.String()
bytesWritten, err := hook.UDPConn.Write([]byte(payload))
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err) fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err)
return err return err
@ -44,6 +45,7 @@ func (hook *PapertrailHook) Fire(entry *logrus.Entry) error {
_, err = hook.UDPConn.Write([]byte(payload)) _, err = hook.UDPConn.Write([]byte(payload))
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Unable to send log line to Papertrail via UDP, %v", err) fmt.Fprintf(os.Stderr, "Unable to send log line to Papertrail via UDP, %v", err)
fmt.Fprintf(os.Stderr, "Unable to send log line to Papertrail via UDP. Wrote %d bytes before error: %v", bytesWritten, err)
return err return err
} }