Skip to content
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

feat(field): add zap.Dict to Field constructor list #1297

merged 6 commits into from Aug 14, 2023

feat(field): add zap.Dict to Field constructor list #1297

merged 6 commits into from Aug 14, 2023


Copy link

@hhk7734 hhk7734 commented Jul 3, 2023

When I want to log a sub dictionary, it's hard to find that I can just log zap.Object("k", ObjectMarshalerFunc(func(inner ObjectEncoder) error { ... })), and it seems unintuitive.

So I added zap.Dict.


	zap.String("1-1", "b"),
	zap.Bool("1-2", true),
		zap.String("1-3-1", "d"),
{"1": {"1-1": "b", "1-2": true, "1-3": {"1-3-1": "d"}}}
  "1": {
    "1-1": "b",
    "1-2": true,
    "1-3": {
      "1-3-1": "d"

Copy link

CLAassistant commented Jul 3, 2023

CLA assistant check
All committers have signed the CLA.

Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Merging #1297 (c19628d) into master (5da8736) will increase coverage by 0.15%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1297      +/-   ##
+ Coverage   97.61%   97.77%   +0.15%     
  Files          52       52              
  Lines        3355     3366      +11     
+ Hits         3275     3291      +16     
+ Misses         69       65       -4     
+ Partials       11       10       -1     
Files Changed Coverage Δ
field.go 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link

@abhinav abhinav left a comment

Choose a reason for hiding this comment

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

Thanks, @hhk7734. This is a great idea!
I've made some changes to the implementation. Namely, instead of adding a new field type, I've implemented this functionality outside in terms of a new private ObjectMarshaler implementation. That way, the zapcore package doesn't see any changes (except new tests).

The change LGTM, but I'd like to get another maintainer to also look over it.
CC @mway @sywhang @prashantv

Copy link

mway commented Aug 14, 2023

LGTM - thanks @hhk7734 and @abhinav!

@mway mway merged commit fcfd368 into uber-go:master Aug 14, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants