-
Notifications
You must be signed in to change notification settings - Fork 183
Re: Introduce Tracing into Chalk #409
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
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.
This all seems pretty straightforward, though I'm not sure what the ?foo
notation is all about in the various macros. One thing that might be a nice addition is to extend the chalk book with a short description of how to use the debug logs -- it would also help in reviewing the PR.
I'd like to see something like:
- How to view the debug logs (document the environment variable options and so forth)
- How to write code that uses
debug
and friends, and the#[instrument]
annotations
Finally, one concern I have with merging this is that it makes tracing a dependency of chalk which would in turn affect rustc -- do you think we can find some way to make it feature gated in a reasonable fashion? (i.e., behind a cargo feature?)
It'd be sort of nice if we could pick between the standard log crate that rustc uses and tracing via cargo feature, so that we can integrate more easily with rustc.
@@ -112,7 +112,7 @@ impl<C: Context> Forest<C> { | |||
mut test: impl FnMut(&C::InferenceNormalizedSubst) -> bool, | |||
) -> bool { | |||
if let Some(answer) = self.tables[table].answer(answer) { | |||
info!("answer cached = {:?}", answer); | |||
info!(?answer, "answer cached"); |
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.
Woah! what is happening here. I guess this is a different for how tracing works?
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.
Yup, in tracing the logging macros generate Event
s which may contain a number of fields. The ?
sigil is a shorthand for creating a new field using the Debug
implementation of answer
.
I'm a new contributor to the Rust project, so I'm not familiar with what the policy around adding new dependencies is. But for what it is worth, |
I think the problem is that it adds a new dependency in |
Well, there are two concerns:
We have a "accept-list" of dependencies it would have to be added to, IIRC, and we'd also want to check the license. As it happens I'd like to experiment with porting rustc over to using tracing, but that's a job in and of itself. |
Ok, @nolanderc think you can rebase this? And maybe add docs in the chalk for how to view logs. @nikomatsakis Now that chalk-ir doesn't depend on chalk-engine (the other way around), then tracing won't be a dependency for Other than that, based on discussion on Zulip, I think this is fine :) |
I don't quite understand that. Can you spell it out a bit more? |
@nikomatsakis So, I realized that the debug macros are in chalk-ir now, so maybe that statement was confusing. But there are no calls that use them in The whitelist in rustc is only for crates that librustc_middle depends on, directly or transitively. librustc_middle only depends on |
What? This sounds like a bug in rustc. The idea of the whitelist is to control what ships in rustc, I don't see why it matters where within rustc's tangled dep graph that dependency arises... |
Closing in favor of #525 Sorry we didn't get this pulled in @nolanderc |
Replaces the old logging system that printed directly to stderr with macros from the
tracing
crate.