Do not pass data strings to the format argument of Printf or Fprintf, use Print and Fprint instead.
Chris Hines
8 years ago
6 | 6 | "strings" |
7 | 7 | ) |
8 | 8 | |
9 | // StdlibWriter implements io.Writer by invoking the stdlib log.Printf. It's | |
9 | // StdlibWriter implements io.Writer by invoking the stdlib log.Print. It's | |
10 | 10 | // designed to be passed to a gokit logger as the writer, for cases where it's |
11 | 11 | // desirable to pipe all log output to the same, canonical destination. |
12 | 12 | type StdlibWriter struct{} |
13 | 13 | |
14 | 14 | // Write implements io.Writer. |
15 | 15 | func (w StdlibWriter) Write(p []byte) (int, error) { |
16 | log.Printf(strings.TrimSpace(string(p))) | |
16 | log.Print(strings.TrimSpace(string(p))) | |
17 | 17 | return len(p), nil |
18 | 18 | } |
19 | 19 |