Skip to content

Commit

Permalink
logger: add logger Fields test (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: Vasiliy Tolstov <[email protected]>
  • Loading branch information
vtolstov authored Jan 19, 2022
1 parent ed8de3b commit d6571eb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions zap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ import (
"go.unistack.org/micro/v3/logger"
)

func TestFields(t *testing.T) {
ctx := context.TODO()
buf := bytes.NewBuffer(nil)
l := NewLogger(logger.WithLevel(logger.TraceLevel), logger.WithOutput(buf))
if err := l.Init(); err != nil {
t.Fatal(err)
}
l.Fields("key", "val").Info(ctx, "message")
if !bytes.Contains(buf.Bytes(), []byte(`"key":"val"`)) {
t.Fatalf("logger fields not works, buf contains: %s", buf.Bytes())
}
}

func TestOutput(t *testing.T) {
buf := bytes.NewBuffer(nil)
l := NewLogger(logger.WithOutput(buf))
Expand Down

0 comments on commit d6571eb

Please sign in to comment.