diff --git a/logr/log_test.go b/logr/log_test.go new file mode 100644 index 0000000..9ffe0a5 --- /dev/null +++ b/logr/log_test.go @@ -0,0 +1,26 @@ +package logr + +import ( + "testing" + + liberr "github.com/jortel/go-utils/error" +) + +func TestList(t *testing.T) { + log := WithName("Test") + type Persion struct { + Name string + Age int + } + p := Persion{ + Name: "Elmer", + Age: 60, + } + + err := liberr.New("Test") + + log.Info("Test") + log.Info("Test", "person", p) + log.Error(err, "Test") + log.Error(err, "Test", "person", p) +} diff --git a/logr/logger.go b/logr/logger.go index e91281e..029c247 100644 --- a/logr/logger.go +++ b/logr/logger.go @@ -148,7 +148,8 @@ func fields(kvpair []any) log.Fields { for i := range kvpair { if i%2 != 0 { key := fmt.Sprintf("%v", kvpair[i-1]) - fields[key] = kvpair[i] + v := fmt.Sprintf("%+v", kvpair[i]) + fields[key] = v } } return fields