Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Further error-logging improvements #333

Merged
merged 3 commits into from
Feb 23, 2017
Merged

Further error-logging improvements #333

merged 3 commits into from
Feb 23, 2017

Conversation

akshayjshah
Copy link
Contributor

First, add support for customizing error fields' keys; now that we support rich errors, we can't simply rely on string fields.

Second, use that support in Any and Errors. This should complete our support for github.com/pkg/errors.

Fully resolves #303.

@mention-bot
Copy link

@akshayjshah, thanks for your PR! By analyzing the history of the files in this pull request, we identified @prashantv, @pravj and @creiht to be potential reviewers.

array.go Outdated
// Re-use the error field's logic, which supports non-standard error types.
Error(e.error).AddTo(enc)
return nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra newline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{
"errors",
Errors("", []error{nil, errors.New("foo"), nil, errors.New("bar")}),
[]interface{}{map[string]interface{}{"error": "foo"}, map[string]interface{}{"error": "bar"}},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a test which also adds errorVerbose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can. Those code paths are already covered, but doesn't hurt to do it again.

error
}

func (e *errArrayElem) MarshalLogObject(enc zapcore.ObjectEncoder) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does mean our output for []error ends up being a list of objects which have a key error. I don't have strong opinions on this, but it does seem a little strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's definitely a little odd. I'm honestly not sure what else to do - it seems worse to have arrays that mix strings and objects. Would you prefer that? Or separate arrays of the errors and verbose errors?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support pkg/errors Stacktracer interface
6 participants