Skip to content

Commit

Permalink
s/InlineObject/Inline
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantv committed Mar 2, 2021
1 parent fff4bfa commit cdfbaec
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions example_test.go
Expand Up @@ -184,7 +184,7 @@ func (a addr) MarshalLogObject(enc zapcore.ObjectEncoder) error {

func (r request) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddString("url", r.URL)
zap.InlineObject(r.Listen).AddTo(enc)
zap.Inline(r.Listen).AddTo(enc)
return enc.AddObject("remote", r.Remote)
}

Expand All @@ -198,7 +198,7 @@ func ExampleObject() {
Remote: addr{"127.0.0.1", 31200},
}
logger.Info("new request, in nested object", zap.Object("req", req))
logger.Info("new request, inline", zap.InlineObject(req))
logger.Info("new request, inline", zap.Inline(req))
// Output:
// {"level":"info","msg":"new request, in nested object","req":{"url":"/test","ip":"127.0.0.1","port":8080,"remote":{"ip":"127.0.0.1","port":31200}}}
// {"level":"info","msg":"new request, inline","url":"/test","ip":"127.0.0.1","port":8080,"remote":{"ip":"127.0.0.1","port":31200}}
Expand Down
6 changes: 3 additions & 3 deletions field.go
Expand Up @@ -400,11 +400,11 @@ func Object(key string, val zapcore.ObjectMarshaler) Field {
return Field{Key: key, Type: zapcore.ObjectMarshalerType, Interface: val}
}

// InlineObject is similar to Object, but does not nest the object under a field
// Inline is similar to Object, but does not nest the object under a field
// name, but adds the fields to the current namespace inline.
func InlineObject(val zapcore.ObjectMarshaler) Field {
func Inline(val zapcore.ObjectMarshaler) Field {
return zapcore.Field{
Type: zapcore.InlineObjectMarshalerType,
Type: zapcore.InlineMarshalerType,
Interface: val,
}
}
Expand Down
2 changes: 1 addition & 1 deletion field_test.go
Expand Up @@ -123,7 +123,7 @@ func TestFieldConstructors(t *testing.T) {
{"Reflect", Field{Key: "k", Type: zapcore.ReflectType}, Reflect("k", nil)},
{"Stringer", Field{Key: "k", Type: zapcore.StringerType, Interface: addr}, Stringer("k", addr)},
{"Object", Field{Key: "k", Type: zapcore.ObjectMarshalerType, Interface: name}, Object("k", name)},
{"InlineObject", Field{Type: zapcore.InlineObjectMarshalerType, Interface: name}, InlineObject(name)},
{"Inline", Field{Type: zapcore.InlineMarshalerType, Interface: name}, Inline(name)},
{"Any:ObjectMarshaler", Any("k", name), Object("k", name)},
{"Any:ArrayMarshaler", Any("k", bools([]bool{true})), Array("k", bools([]bool{true}))},
{"Any:Stringer", Any("k", addr), Stringer("k", addr)},
Expand Down
6 changes: 3 additions & 3 deletions zapcore/field.go
Expand Up @@ -39,9 +39,9 @@ const (
ArrayMarshalerType
// ObjectMarshalerType indicates that the field carries an ObjectMarshaler.
ObjectMarshalerType
// InlineObjectMarshalerType indicates that the field carries an ObjectMarshaler
// InlineMarshalerType indicates that the field carries an ObjectMarshaler
// that should be inlined.
InlineObjectMarshalerType
InlineMarshalerType
// BinaryType indicates that the field carries an opaque binary blob.
BinaryType
// BoolType indicates that the field carries a bool.
Expand Down Expand Up @@ -118,7 +118,7 @@ func (f Field) AddTo(enc ObjectEncoder) {
err = enc.AddArray(f.Key, f.Interface.(ArrayMarshaler))
case ObjectMarshalerType:
err = enc.AddObject(f.Key, f.Interface.(ObjectMarshaler))
case InlineObjectMarshalerType:
case InlineMarshalerType:
err = f.Interface.(ObjectMarshaler).MarshalLogObject(enc)
case BinaryType:
enc.AddBinary(f.Key, f.Interface.([]byte))
Expand Down
6 changes: 3 additions & 3 deletions zapcore/field_test.go
Expand Up @@ -111,7 +111,7 @@ func TestFieldAddingError(t *testing.T) {
}{
{t: ArrayMarshalerType, iface: users(-1), want: []interface{}{}, err: "too few users"},
{t: ObjectMarshalerType, iface: users(-1), want: map[string]interface{}{}, err: "too few users"},
{t: InlineObjectMarshalerType, iface: users(-1), want: nil, err: "too few users"},
{t: InlineMarshalerType, iface: users(-1), want: nil, err: "too few users"},
{t: StringerType, iface: obj{}, want: empty, err: "PANIC=interface conversion: zapcore_test.obj is not fmt.Stringer: missing method String"},
{t: StringerType, iface: &obj{1}, want: empty, err: "PANIC=panic with string"},
{t: StringerType, iface: &obj{2}, want: empty, err: "PANIC=panic with error"},
Expand Down Expand Up @@ -180,13 +180,13 @@ func TestFields(t *testing.T) {
}
}

func TestInlineObjectMarshaler(t *testing.T) {
func TestInlineMarshaler(t *testing.T) {
enc := NewMapObjectEncoder()

topLevelStr := Field{Key: "k", Type: StringType, String: "s"}
topLevelStr.AddTo(enc)

inlineObj := Field{Key: "ignored", Type: InlineObjectMarshalerType, Interface: users(10)}
inlineObj := Field{Key: "ignored", Type: InlineMarshalerType, Interface: users(10)}
inlineObj.AddTo(enc)

nestedObj := Field{Key: "nested", Type: ObjectMarshalerType, Interface: users(11)}
Expand Down

0 comments on commit cdfbaec

Please sign in to comment.