forked from uber-go/zap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zapslog: fix all with slogtest, support inline group, ignore empty gr…
…oup. (uber-go#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 uber-go#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 uber-go#1333 Resolves uber-go#1334, uber-go#1401, uber-go#1402 Supersedes uber-go#1263, uber-go#1335 ### TESTS - passed. #1 - This also works in Go 1.22 --------- Signed-off-by: junya koyama <arukiidou@yahoo.co.jp> Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
- Loading branch information
Showing
2 changed files
with
281 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters