-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
zapslog.Handler: Test with slogtest, fix all failures #1334
Comments
Adds a test for zapslog that verifies its behavior with slogtest's TestHandler function. This verifies compliance with the slog logging contract. Resolves uber-go#1334
Adds a test for zapslog that verifies its behavior with slogtest's TestHandler function. This verifies compliance with the slog logging contract. Resolves uber-go#1334
Adds a test for zapslog that verifies its behavior with slogtest's TestHandler function. This verifies compliance with the slog logging contract. Resolves uber-go#1334
Per the slog.Handler contract, handlers should not log attributes that are equal to the zero value. This is equivalent to Zap's `zap.Skip()`. Discovered by uber-go#1335 Refs uber-go#1334
Can I help with this or is it done? @abhinav |
Hey, @SoulPancake. Thanks for your interest! Thanks! |
Hey @abhinav, as far as "Handler should ignore a zero Record.Time" - isn't this up to each individual |
@justinhwang Yeah, that's a fair point. I think it makes sense that the official encoders that come with Zap support that behavior, and we should possibly consider documenting that encoder implementations are highly encouraged to skip writing the time for a log entry if it's a zero value. |
Adds a test for zapslog that verifies its behavior with slogtest's TestHandler function. This verifies compliance with the slog logging contract. Resolves uber-go#1334
Per the comment on `Encoder.EncodeEntry`, any fields that are empty including fields on the `Entry` type should be omitted. Omit the `Time` field when we have empty time. This also aligns with slog.Handler contract. Refs #1334 Discovered by #1335 --------- Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
Adds a test for zapslog that verifies its behavior with slogtest's TestHandler function. This verifies compliance with the slog logging contract. Resolves uber-go#1334
|
Signed-off-by: junya koyama <arukiidou@yahoo.co.jp>
…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 <arukiidou@yahoo.co.jp> Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
zapslog.Handler is not yet tested with slogtest on master.
We should add a test for that and address any problems that occur.
#1335 attempts to add such a test. Pending failures:
The text was updated successfully, but these errors were encountered: