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

Add NumbersAsStrings to EncoderConfig #1

Merged
merged 1 commit into from
Dec 3, 2020

Conversation

fishy
Copy link
Member

@fishy fishy commented Dec 3, 2020

This partially fixes uber-go#884.

This implementation is limited to top level fields, like:

Int64("int64", 123)
Float64("float64", 456)

Or sugared:

With("int64", 123, "float64", float64(456), "slice", []int{1, 2, 3})

It does NOT work with reflected fields like:

Reflect("slice", []int{1, 2, 3})
With("struct", struct{ Int64 int64 }{Int64: 123})

As for reflected fields we use go's stdlib json encoder directly, which
doesn't provide such feature.

This partially fixes uber-go#884.

This implementation is limited to top level fields, like:

    Int64("int64", 123)
    Float64("float64", 456)

Or sugared:

    With("int64", 123, "float64", float64(456), "slice", []int{1, 2, 3})

It does NOT work with reflected fields like:

    Reflect("slice", []int{1, 2, 3})
    With("struct", struct{ Int64 int64 }{Int64: 123})

As for reflected fields we use go's stdlib json encoder directly, which
doesn't provide such feature.
@fishy fishy merged commit 0d6cec9 into reddit:master Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Add an "always encode numbers as strings" option to zapcore.EncoderConfig
3 participants