-
Notifications
You must be signed in to change notification settings - Fork 256
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
Get structured logging API ready for stabilization #613
Conversation
We currently have |
I think I would understand possible confusing between the two traits, so maybe we need to rename one of the two? What about renaming |
That's a fair point. Perhaps we could keep the names verb-y and use |
Sounds good 👍 |
Ok, I think the last remaining thing here is macro syntax. We could adopt exactly
where
where
We could use a simple lowering scheme so Another potential position could be on the key name:
That would more easily let us expected Any thoughts? |
I like this, feels similar to
Small thing is versioning, in case serde/sval ever publish a v2, how do we want to handle that? We can go
Because we'll be copying the standard formatting found in the std lib, I don't think will become an issue.
How would be limiting ourselves using the above |
That seems like a good scheme to me 👍 I spelled this out explicitly in
We'd just need to wrap full expressions in parenthesis or braces, because the |
This is quite a big change but I think it's ready for a review now. Some things to call out:
|
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 like it.
The only concern I have is that people find the modified on the key odd/unexpected, when coming from the std::fmt
implementation. That might be worth calling out in the documentation.
src/__private_api.rs
Outdated
|
||
pub type Value<'a> = kv::Value<'a>; | ||
|
||
pub fn capture_to_value<'a, V: kv::value::ToValue + ?Sized>(v: &'a &'a V) -> Value<'a> { |
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.
Why the double reference?
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 left a comment in the source on why we do this. It's just so we can capture T: ?Sized
while still erasing it behind a dyn Trait. Passing in the double reference in just helps the lifetimes work out.
The
way of capturing an error using the |
I think the last thing remaining here is what to do about the |
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 think the last thing remaining here is what to do about the
_unstable
suffix on our features. I was thinking making them just shims for the unsuffixed versions, but continuing to accept them so that we don't break every current user of the feature. What do you think @Thomasdezeeuw?
We can, but we a also have other breakages, e.g. the removal of the as_{display,debug, etc.}
macros. Some of the API on Value
has changes, which is also breaking.
So I'm wondering if we should keep some of the old API, if possible, if kv_unstable
is used? Marking it all as deprecated show it at least generates warnings (I don't know if that is possible for features). Then e.g. 6 months after the stable release we can remove the _unstable
feature and all it's related API? This would give people some time to migrate their code.
@@ -44,10 +44,10 @@ jobs: | |||
- run: cargo test --verbose --all-features | |||
- run: cargo test --verbose --features serde | |||
- run: cargo test --verbose --features std | |||
- run: cargo test --verbose --features kv_unstable |
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.
We could start using cargo-hack for this at some point (for another pr).
Cargo.toml
Outdated
kv_unstable = ["kv"] | ||
kv_unstable_sval = ["kv_sval"] | ||
kv_unstable_std = ["kv_std"] | ||
kv_unstable_serde = ["kv_serde"] |
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.
To bad there is only compile_error!
, not compile_warn!
otherwise it would be nice to add that.
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.
Actually on second though... we're going to break a lot of (unstable) code already by removing the as_serde
macros, do we just rip the bandaid in one go and break everything? Or should we add those macros back if [kv_unstable
] is used (and mark them as #[deprecated]
)?
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 think this is a reasonable thing to do 👍
Unfortunately you can’t mark them as deprecated but we can also re-export the renamed visitor traits under their old names when the old _unstable
features are enabled.
How does this sound as a plan for stabilization:
The idea being new code and any maintained in that time period should move from the unstable to the stable API without much fuss, but there will be a point where the bandaid comes off completely. The only unfortunate part is we can’t deprecate old trait names so we don’t have a good way of making users of them aware things have changed. |
Sounds good to me 👍 |
In this latest round of changes I've restored the old APIs under their respective |
Ok, I think this is ready for its last review now. Thank you so much for all the time you've invested in helping push this forwards so far @Thomasdezeeuw 🙏 We'd never have reached this point without you. |
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! Let's merge.
I'm gonna go over the API with https://github.com/Enselic/cargo-public-api/ see what, if any, difference there are
Co-authored-by: Thomas de Zeeuw <thomasdezeeuw@gmail.com>
Co-authored-by: Thomas de Zeeuw <thomasdezeeuw@gmail.com>
Closes #149
Closes #328
Closes #357
Closes #436
Closes #584
Based on the review in #584
The plan is to:
Value::capture_*
andValue::downcast_*
methods. All deprecated APIs are gated under the oldkv_unstable
features and will be removed once we remove those old unstable features.ToValue
(key:? = value
).value-bag
as a dependency if eitherserde
orsval
is also needed. In cases where you just want basic structured logging, we should do it in a dependency-free way. This will just mean adding a simpleValueInner
enum.I'll cc once this is ready for review, to save a bit of notification noise.
Once this PR is complete, we should be able to stabilize structured logging support in the
log
crate.