Skip to content

Commit

Permalink
fix custom log writer returned bytes written count
Browse files Browse the repository at this point in the history
It was including the prefixed datetime string in the byte count which
made it longer than the passed in byte slice and the io.Multiwriter
considers that an error and stops processing the writers at that point
(skipping the syslog writer).
  • Loading branch information
eikenb committed Oct 27, 2021
1 parent 766b766 commit 9f4a0ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ func (writer logWriter) Write(bytes []byte) (int, error) {
if len(bytes) == 0 {
return 0, nil
}
return fmt.Fprintf(writer.out, "%s %s", now(), bytes)
if _, err := fmt.Fprintf(writer.out, "%s %s", now(), bytes); err != nil {
return 0, err
}
return len(bytes), nil
}

// Config is the configuration for this log setup.
Expand Down

0 comments on commit 9f4a0ed

Please sign in to comment.