From 76d3c39327fa189141dbb8f43beaa30d6a8e6ec5 Mon Sep 17 00:00:00 2001 From: Olivier Poitrey Date: Fri, 19 May 2017 22:25:37 -0700 Subject: [PATCH] Rename Object to Interface --- context.go | 6 +++--- event.go | 6 +++--- field.go | 4 ++-- log_example_test.go | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/context.go b/context.go index d3c2c20..0034066 100644 --- a/context.go +++ b/context.go @@ -128,8 +128,8 @@ func (c Context) Time(key string, t time.Time) Context { return c } -// Object adds the field key with obj marshaled using reflection. -func (c Context) Object(key string, obj interface{}) Context { - c.l.context = appendObject(c.l.context, key, obj) +// Interface adds the field key with obj marshaled using reflection. +func (c Context) Interface(key string, i interface{}) Context { + c.l.context = appendInterface(c.l.context, key, i) return c } diff --git a/event.go b/event.go index 0c66bf7..7155444 100644 --- a/event.go +++ b/event.go @@ -262,11 +262,11 @@ func (e *Event) Time(key string, t time.Time) *Event { return e } -// Object adds the field key with obj marshaled using reflection. -func (e *Event) Object(key string, obj interface{}) *Event { +// Interface adds the field key with i marshaled using reflection. +func (e *Event) Interface(key string, i interface{}) *Event { if !e.enabled { return e } - e.buf = appendObject(e.buf, key, obj) + e.buf = appendInterface(e.buf, key, i) return e } diff --git a/field.go b/field.go index a4706d6..b00458b 100644 --- a/field.go +++ b/field.go @@ -88,8 +88,8 @@ func appendTimestamp(dst []byte) []byte { return appendTime(dst, TimestampFieldName, now()) } -func appendObject(dst []byte, key string, obj interface{}) []byte { - marshaled, err := json.Marshal(obj) +func appendInterface(dst []byte, key string, i interface{}) []byte { + marshaled, err := json.Marshal(i) if err != nil { return appendString(dst, key, fmt.Sprintf("marshaling error: %v", err)) } diff --git a/log_example_test.go b/log_example_test.go index 0ed99d3..500cd98 100644 --- a/log_example_test.go +++ b/log_example_test.go @@ -114,7 +114,7 @@ func ExampleEvent_Dict() { // Output: {"foo":"bar","dict":{"bar":"baz","n":1},"message":"hello world"} } -func ExampleEvent_Object() { +func ExampleEvent_Interface() { log := zerolog.New(os.Stdout) obj := struct { @@ -125,7 +125,7 @@ func ExampleEvent_Object() { log.Log(). Str("foo", "bar"). - Object("obj", obj). + Interface("obj", obj). Msg("hello world") // Output: {"foo":"bar","obj":{"name":"john"},"message":"hello world"} @@ -144,7 +144,7 @@ func ExampleContext_Dict() { // Output: {"foo":"bar","dict":{"bar":"baz","n":1},"message":"hello world"} } -func ExampleContext_Object() { +func ExampleContext_Interface() { obj := struct { Name string `json:"name"` }{ @@ -153,7 +153,7 @@ func ExampleContext_Object() { log := zerolog.New(os.Stdout).With(). Str("foo", "bar"). - Object("obj", obj). + Interface("obj", obj). Logger() log.Log().Msg("hello world")