-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing: don't require delimiters for format_args (#288)
## 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>
- Loading branch information
Showing
7 changed files
with
231 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.