-
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
zapcore: Ignore nil Entry.Time in encoders #1369
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1369 +/- ##
==========================================
+ Coverage 98.28% 98.42% +0.14%
==========================================
Files 53 53
Lines 3493 3493
==========================================
+ Hits 3433 3438 +5
+ Misses 50 46 -4
+ Partials 10 9 -1
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
The PR largely LGTM. Just two changes, please:
- Delete the skipped test. We'd prefer to track that pending work in a GH issue.
- Add a similar check to console_encoder_test as the JSON case.
exp/zapslog/handler_test.go
Outdated
@@ -189,3 +193,42 @@ func TestAttrKinds(t *testing.T) { | |||
}, | |||
entry.ContextMap()) | |||
} | |||
|
|||
func TestSlogtest(t *testing.T) { | |||
t.Skip() // TODO: skip for now until test failures are fixed (#1334) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep this test off master until we actually have it passing.
t.Skip
s don't really get follow ups that often—I'd prefer we track the pending work in issues as we're already doing that.
Would you mind deleting this change from this PR?
{ | ||
desc: "zero_time_omitted", | ||
expected: `{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Would you mind adding a similar check to the console_encoder_test.go as well?
This work is being tracked in #1334.
Verifies that the console encoder also skips the time if it's a zero value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that the console encoder didn't have an existing test for something like this. I added one and a test for this.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @justinhwang and @abhinav!
* bump go.mod dependencies * jsonpatch evanphx/json-patch#160 * zap uber-go/zap#1369 * lint
Per the comment on
Encoder.EncodeEntry
, any fields that are empty including fields on theEntry
type should be omitted. Omit theTime
field when we have empty time.This also aligns with slog.Handler contract.
Refs #1334
Discovered by #1335