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: Add basic key-value pair field support #3

Merged
merged 5 commits into from
Apr 23, 2024
Merged

feat: Add basic key-value pair field support #3

merged 5 commits into from
Apr 23, 2024

Conversation

lpraneis
Copy link
Contributor

Hi @pnehrer , thanks for the useful crate!

I recently used this crate in a project that made heavy use of the slog support for key value pairs and added some basic support to this library for serializing those to a new field, slog.fields and thought I would contribute that change upstream in case it would be useful for others as well.

Feel free to decline this PR if you don't think this kind of addition makes sense here. I gated the new functionality behind a kv feature because it does have some slight allocation overhead per log generated if a key-value pair is in use. I made this feature opt-out but would be happy to swap that to opt-in.

@pnehrer
Copy link
Member

pnehrer commented Apr 17, 2024

Thank you for your submission @lpraneis! I'll have a look and provide feedback shortly.

Copy link
Member

@pnehrer pnehrer left a comment

Choose a reason for hiding this comment

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

Thank you again! I spent some time thinking about how to serialize slog's key/value pairs "natively" but couldn't think of a way as tracking handles these quite differently.

Would you mind calling this addition kv instead of fields? That name is quite overloaded in the context of tracing.

Also, I'd prefer the whole feature to be opt-in, for starters.

Cargo.toml Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@pnehrer pnehrer left a comment

Choose a reason for hiding this comment

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

Wonderful, thank you!

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
lpraneis and others added 2 commits April 23, 2024 08:13
Co-authored-by: Peter Nehrer <pnehrer@eclipticalsoftware.com>
Co-authored-by: Peter Nehrer <pnehrer@eclipticalsoftware.com>
@pnehrer pnehrer merged commit 1a6d37d into ecliptical:main Apr 23, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants