Codebase list golang-github-go-kit-kit / 14b9e54
Do not pass data strings to the format argument of Printf or Fprintf, use Print and Fprint instead. Chris Hines 8 years ago
2 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
66 "strings"
77 )
88
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
1010 // designed to be passed to a gokit logger as the writer, for cases where it's
1111 // desirable to pipe all log output to the same, canonical destination.
1212 type StdlibWriter struct{}
1313
1414 // Write implements io.Writer.
1515 func (w StdlibWriter) Write(p []byte) (int, error) {
16 log.Printf(strings.TrimSpace(string(p)))
16 log.Print(strings.TrimSpace(string(p)))
1717 return len(p), nil
1818 }
1919
6363 "/a/b/c/d.go:23: hello": "file=/a/b/c/d.go:23 msg=hello\n",
6464 } {
6565 buf.Reset()
66 fmt.Fprintf(writer, input)
66 fmt.Fprint(writer, input)
6767 if have := buf.String(); want != have {
6868 t.Errorf("%q: want %#v, have %#v", input, want, have)
6969 }