Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func NamedError(key string, err error) Field {

type errArray []error

// MarshalLogArray implements zapcore.ArrayMarshaler.
func (errs errArray) MarshalLogArray(arr zapcore.ArrayEncoder) error {
for i := range errs {
if errs[i] == nil {
Expand All @@ -73,6 +74,7 @@ type errArrayElem struct {
error
}

// MarshalLogObject implements zapcore.ObjectMarshaler.
func (e *errArrayElem) MarshalLogObject(enc zapcore.ObjectEncoder) error {
// Re-use the error field's logic, which supports non-standard error types.
Error(e.error).AddTo(enc)
Expand Down
2 changes: 2 additions & 0 deletions sugar.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ type invalidPair struct {
key, value interface{}
}

// MarshalLogObject implements zapcore.ObjectMarshaler.
func (p invalidPair) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddInt64("position", int64(p.position))
Any("key", p.key).AddTo(enc)
Expand All @@ -295,6 +296,7 @@ func (p invalidPair) MarshalLogObject(enc zapcore.ObjectEncoder) error {

type invalidPairs []invalidPair

// MarshalLogArray implements zapcore.ArrayMarshaler.
func (ps invalidPairs) MarshalLogArray(enc zapcore.ArrayEncoder) error {
var err error
for i := range ps {
Expand Down
Loading