-
Notifications
You must be signed in to change notification settings - Fork 726
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
tracing: Replace macro-rules with procedural macros #133
Comments
I believe @Ralith is working on this. My understanding is that it is currently blocked on dtolnay/syn#661. |
This is accurate. If that issue can be fixed, I am otherwise very close to a working prototype of
These macros will necessarily rely on proc-macro-hack, which means that they can't be used by downstream code directly from the crate they're implemented in; an intermediate re-exporting crate is always necessary. My understanding is that |
Looks like it might not be a syn issue: dtolnay/proc-macro-hack#34 |
Now isolated to a compiler issue: rust-lang/rust#62325 |
Thanks for keeping us updated, @Ralith --- great to hear that progress is being made on unblocking this! |
Looks like the compiler bug has been fixed in rust-lang/rust#62393, so hopefully we can move forwards with this once the fix is on stable. |
## Motivation Currently, the `tracing` macros require curly braces as delimiters when a `format_args` macro is used in addition to structured fields, like: ```rust info!({ field1 = value1, field2 = value2 }, "unstructured message"); ``` This is confusing, since the delimiters are not used in other cases; it makes the syntax more complex; and, most importantly, I think it looks kind of ugly. I've been planning to get rid of this when we transition to procedural macros, but the transition is currently blocked on a compiler bug, rust-lang/rust#62325. (see #133 (comment)) I've been getting tired of waiting for this. ## Solution: This branch updates the `tracing` crate's macros to support a format_args message after the structured key-value fields without curly braces. For example, ```rust let yay = "WITHOUT DELIMITERS!!!"; info!(field1 = value1, field2 = value2, "message: {}", yay); ``` I've updated the tests & examples in the `tracing` crate so that they show this usage rather than the old usage. The old form with curly braces is still supported, since removing it would be a breaking change, but we'll transition it out in examples & tutorials. (can you put a `deprecated` attribute on a specific macro arm???). Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Feature Request
Crates
tracing
Motivation
Now that we are not supporting Rust 1.26.0 as our minimum compatible version, we can ship procedural macros in
tracing
. Replacing the existingmacro_rules
macros should improve user-facing error messages, make the macros more maintainable, and make it easier to add new features to them in the future (such as #83).Proposal
The macros should be in a separate crate, but they should be re-exported by
tracing
. We should re-implement the existing macro syntax prior to adding any new features, and do that separately as a follow-up.I think the new macros could live in the existing
tracing-proc-macros
ortracing-macros
crates. Perhaps we should usetracing-macros
and move everything currently intracing-proc-macros
there (and rewrite or remove the macros currently intracing-macros
, which are very experimental).The text was updated successfully, but these errors were encountered: