Add Msgf test

This commit is contained in:
Olivier Poitrey 2017-05-20 20:59:39 -07:00
parent 6b56a13287
commit e0e86f933f
1 changed files with 8 additions and 0 deletions

View File

@ -150,6 +150,14 @@ func TestFieldsDisabled(t *testing.T) {
}
}
func TestMsgf(t *testing.T) {
out := &bytes.Buffer{}
New(out).Log().Msgf("one %s %.1f %d %v", "two", 3.4, 5, errors.New("six"))
if got, want := out.String(), `{"message":"one two 3.4 5 six"}`+"\n"; got != want {
t.Errorf("invalid log output: got %q, want %q", got, want)
}
}
func TestWithAndFieldsCombined(t *testing.T) {
out := &bytes.Buffer{}
log := New(out).With().Str("f1", "val").Str("f2", "val").Logger()