-
Notifications
You must be signed in to change notification settings - Fork 259
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
kv macro support #353
kv macro support #353
Conversation
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.
Thanks so much for working on this @yoshuawuyts!
I've just left a comment about how we're capturing values as strings.
Ah, we should also be careful not to regress the It does also present a bit of a syntactic oddity, where values interpolated into the message would use the info!("hello {value}", value = "cats", {
cat_1: "chashu",
cat_2: "nori",
}); I don't think this is necessarily a problem though, but thought it was worth pointing out. |
fe1b13e
to
6cd5063
Compare
@KodrAus in general it seems we don't have a lot of tests right now -- I was wondering how we might want to go about it? |
Yeh, we don't really for the macro syntax, do we. Maybe we could add an integration test file that can do something like this: struct AssertRecord;
impl Log for AssertRecord {
fn record(&self, record: &Record) {
ASSERT.with(|a| a(record));
}
}
#[test]
fn level_info() {
// Sets the assert function in thread-local storage
// then calls the log statement
test_log!(
info!("Hello, {value}!", value = "world"),
|record| {
assert_eq!("Hello, world!", record.args().to_string();
assert_eq!(Level::Info, record.level());
}
);
} So that we can build up a suite for the current syntax. But I'm happy to sketch that out independently if you like? For now I think if we can try find a way to keep |
@KodrAus ohhh, yeah looks like you were onto something there -- I found a bug in my impl which I've fixed, but more importantly the Though I'm not entirely sure how to fix it, so I'm all ears if you have suggestions! |
Hi @yoshuawuyts! I'm just circling back to this, I'll spend some time playing with the macros too and see where I end up. We might end up having to tweak the syntax a little (which we could do to consider working more nicely with other extensions like #357). |
@KodrAus Hi! -- I've been meaning to post an update, but kept putting it off because of reasons, but yea I've spent some time working on this though haven't been able to solve it. So what seems to be happening is that the macro currently correctly desugars into: format_args!("hello {cat}", cat = "nori"); But the output isn't working. Why? Well, it turns out that Now what I suspect is happening here is that I've tried processing it as a Hope this was helpful! |
199: remove custom log code in favor of macro crate r=stjepang a=yoshuawuyts This removes our custom log macro code in favor of using [`kv-log-macro`](https://github.com/yoshuawuyts/kv-log-macro). This is a temporary crate that exists only until rust-lang/log#353 lands which enables progress on rust-lang/log#328. Thanks! Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
199: remove custom log code in favor of macro crate r=yoshuawuyts a=yoshuawuyts This removes our custom log macro code in favor of using [`kv-log-macro`](https://github.com/yoshuawuyts/kv-log-macro). This is a temporary crate that exists only until rust-lang/log#353 lands which enables progress on rust-lang/log#328. Thanks! Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Hi @yoshuawuyts! 👋 Sorry I’ve been really scattered over the last few months so haven’t been able to make a lot of progress here. However I’m feeling less concerned about regressing this specific edge-case, and I also think implicit inline format args makes the difference between our binding syntax for format args vs kv pairs much less significant. So all that’s to say I’d be on board with pushing forward with this! |
@KodrAus yay, that's excellent news! I'm very excited for this! I just pushed a patch to remove the failing tests, meaning this patch should now be ready to be merged! It seems CI is currently not setup, so it can't verify this patch. But hopefully this is good! |
Oh dear... Lemme just fix that real quick. |
@yoshuawuyts would you like to squash and rebase your commits on the current |
44ab6c5
to
6ad3610
Compare
@KodrAus rebased and force-pushed. Hoping this works! 🤞 |
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Heh, for odd reasons CI is no longer reporting on this branch. My guess is because the repo was migrated it caused some bug in GitHub's UI. CI link is here: https://github.com/yoshuawuyts/log/runs/295531981 -- it seems |
Ah it looks like |
Not behind a computer right now but we should try running CI again. Looks like #362 got merged two weeks ago. |
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.
Yes! Let's merge this in. CI should be good now but if there's any issues I'll get them sorted.
Thanks so much for your patience and effort on this one @yoshuawuyts!
@KodrAus Wooot! So happy this got merged! Thank you! Do you have any idea when this could make it to a release on crates.io? I'm super stoked to start trying it out! ✨ |
@yoshuawuyts Yeh this is an exciting step forward! I'll put together a release PR today and cc you on it. I might get a few other peeps from Libs to take a look at the diff too just to make sure we haven't missed anything. |
Adds key-value support to the log macros. Supersedes #346. Refs #343 #328. Thanks!
Syntax
Tasks