-
Notifications
You must be signed in to change notification settings - Fork 1.5k
zapslog: Handler should inline the Attrs of a group with an empty key #1402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
4 tasks
I think that might fix with the following approach Lines 90 to 91 in 70f61bb
to case slog.KindGroup:
if attr.Key == "" {
return zap.Inline(groupObject(attr.Value.Group()))
}
return zap.Object(attr.Key, groupObject(attr.Value.Group())) |
arukiidou
added a commit
to arukiidou/zap
that referenced
this issue
Feb 2, 2024
Signed-off-by: junya koyama <[email protected]>
abhinav
added a commit
that referenced
this issue
Feb 5, 2024
…oup. (#1408) This change adds a test based on testing/slogtest that verifies compliance with the slog handler contract (a draft of this was available in #1335), and fixes all resulting issues. The two remaining issues were: - `Group("", attrs)` should inline the new fields instead of creating a group with an empty name. This was fixed with the use of `zap.Inline`. - Groups without any attributes should not be created. That is, `logger.WithGroup("foo").Info("bar")` should not create an empty "foo" namespace (`"foo": {}`). This was fixed by keeping track of unapplied groups and applying them the first time a field is serialized. Following this change, slogtest passes as expected. Refs #1333 Resolves #1334, #1401, #1402 Supersedes #1263, #1335 ### TESTS - passed. arukiidou#1 - This also works in Go 1.22 --------- Signed-off-by: junya koyama <[email protected]> Co-authored-by: Abhinav Gupta <[email protected]>
Resolved by #1408 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
slogtest
cause errors:actual logs:
To Reproduce
run
testing/slogtest
Expected behavior
so that:
Additional context
none.
The text was updated successfully, but these errors were encountered: