logger: update logger interface

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-01-10 18:56:39 +03:00
parent 270ad1b889
commit 7b3a7a9448
5 changed files with 111 additions and 84 deletions

View File

@@ -1,16 +1,18 @@
package logger
import (
"context"
"testing"
)
func TestLogger(t *testing.T) {
ctx := context.TODO()
l := NewLogger(WithLevel(TraceLevel))
if err := l.Init(); err != nil {
t.Fatal(err)
}
l.Trace("trace_msg1")
l.Warn("warn_msg1")
l.Fields(map[string]interface{}{"error": "test"}).Info("error message")
l.Warn("first", " ", "second")
l.Trace(ctx, "trace_msg1")
l.Warn(ctx, "warn_msg1")
l.Fields(map[string]interface{}{"error": "test"}).Info(ctx, "error message")
l.Warn(ctx, "first", " ", "second")
}