From e20a6d8c9864e69f7754a36ef1135c28ee39da5d Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 20 Jan 2022 00:33:48 +0300 Subject: [PATCH] logger: add logger Fields test Signed-off-by: Vasiliy Tolstov --- logrus_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/logrus_test.go b/logrus_test.go index fdfd105..4e5283b 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -11,6 +11,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)) -- 2.45.2