Skip to content

Support error array in field when using json formatter - #1413

Open
same-id wants to merge 1 commit into
sirupsen:masterfrom
same-id:errors
Open

Support error array in field when using json formatter#1413
same-id wants to merge 1 commit into
sirupsen:masterfrom
same-id:errors

Conversation

@same-id

@same-id same-id commented Dec 29, 2023

Copy link
Copy Markdown

In addition to:
#137

@same-id

same-id commented May 17, 2024

Copy link
Copy Markdown
Author

Bump, I think this can count as a bug fix

Comment thread json_formatter.go
Comment on lines +79 to +80
case []error:
data[k] = errorsArrayToStrings(v)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Slightly thinking out loud here; now that go stdlib provides native support for "multi-errors" through errors.Join, I wonder if this is something that would be better fixed in the code using logrus.

i.e.; instead of WithField("errors", []error{...}), to use WithError(errors.Join(errs....)) (or similar)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The tricky bit is that logrus will (probably) never be able to fully cover all scenarios; if such a []error (or a regular error) would be part of a struct that's set as field; it would probably still produce a non-string output for the error(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants