-
Notifications
You must be signed in to change notification settings - Fork 128
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 support for Key-Value data in log records. #137
Conversation
Any news on this? Could we at least merge it behind a feature flag or something? Does this need any changes besides a rebase? |
I would also love to start using it. One good addition to the pull-request would probably be a usage example. |
I tried these changes and they work well. As far as usage examples go, I think that is done in the Users of env_log would just need to use the One thing I noticed is maybe the target should be written after the kv pairs. Currently we get:
But IMO the following looks cleaner, since target stays aligned with lines that do not have kv pairs:
Also wanted to mentioned that it might be worth it to consider putting the structured data in different lines, to improve readability. At least for development, IMO the following looks better:
This is what Though in production we'd probably want everything on the same line. |
Thanks for pointing to the examples in the log crate. That makes sense. As to your other points: I'd second both of them. |
I was just about to open an issue when I found this PR... It would be awesome if this could be merged so I can keep using |
Thanks for the rebase @tmccombs! After using this a little I'm thinking that it would (maybe) be good to make it configurable where the K/V's are written? As I'm used that they are written behind the actual log message instead of in front of it. When reading a lot of log files that all log a different number of K/V's, you really have to scan al lot to find where the actual message is. If the K/V's are added at the end, all the messages are (more or less) directly above each other 🤷🏻♂️ |
I added a commit that moves the Key values behind the rest of the option, and made it configurable whether it is on a single line or on separate lines, as @simao suggested. |
Looks really good!! Thanks for your efforts, I'll be using your branch until this gets (hopefully) merged 👍🏻 |
Any reason on what this is blocked on? Would be great to get this merged, even until an experimental flag. |
@epage could you enable CI runs on this? |
549fcda
to
b5f0ea0
Compare
@tmccombs at this point my thoughts are
|
I could use a little more direction on what you are looking for here. I'm guessing you mean have something like the Should I keep an implementation that uses newlines between each field? It looks liek tracing-subscriber always just includes all the fields on the same line as the main message. Full and Compact use basically the same syntax for displaying fields, but Pretty is sligtly different (it i uses ": " instead of "=", is that a distinction worth having?)? |
Hadn't looked into that before. Thanks for listing those considerations. As this is unstable, let's focus on an MVP and just use the formatting they do by default and not provide any configuration. We can then explore in an Issue what our formatting configuration options are, both those from the two PRs and from tracing-subscriber. |
|
I've resolved conflicts and squashed the commits. |
src/fmt/mod.rs
Outdated
/// The values can be suppressed, included in a trailer at the end of the line, or | ||
/// included as multiple lines after the message. | ||
#[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||
pub enum KVStyle { |
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.
Is this a zombie from resolving the merge conflicts?
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.
ah, yes it is
#[cfg(feature = "unstable-kv")] | ||
pub use self::kv::*; |
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.
If you are already going back to make a change, can you you check this on RUSTDOCFLAGS=--cfg=docsrs cargo +nightly doc --all-features
(I'm hoping that is correct).
Each API item behind a cfg
should have a note in the documentation, like clap::command
requiring cargo
.
Most likely, you'll need to either duplicate this cfg
on the items or move the cfg
into the kv
mod.
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.
b40e990
to
29e378d
Compare
Hey all! 👋 Firstly, thank you for picking up and carrying this project forwards 🙏 We're (finally) about to stabilize the key-value support in |
Make the key italic by default.
I've updated to use the stable version of the log kv feature. Fixed merge conflicts, and fixed the compilation error when the color option is not enabled. |
Which means updating to 0.4.21
See rust-lang/log#328