-
Notifications
You must be signed in to change notification settings - Fork 700
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
trace: support string interpolation #83
Comments
I suspect it should be possible to add syntax for interpolating fields into a textual message in |
👋 Dropping a line here in reference to a convo in the #tracing channel in Discord. Currently we use info!(logger, "msg: {}", 1, formatted_field="a"; "additional_field" => 4) The fields before the ; are used for the format string, and the result of that is used as I'm not actually a huge fan of this, mostly cause it leads to duplication of fields, and the syntax differs between then in a weird wait. Something that might be nice could be if the syntax was basically just like |
Since Rust RFC 2795 will be stabilized in 1.58, the ergonomic semantics outlined by @samschlegel above should soon be achievable. All we'll need to do is modify |
Is there anything currently blocking this feature from happening? |
No, it's fairly straightforwardly doable now, just nobody's had time to get to it. |
Log readability is significantly improved by interleaving information with text, rather than supplying a static string followed by a set of key-value pairs. tokio-trace's macros should support constructing such interpolated strings while preserving the interpolated data as structured fields.
Additionally, any out-of-the-box subscribers targeting direct human consumption (such as by printing to stdout) should not duplicate interpolated values in its output. This could be accomplished without compromising support for users that prefer not to use interpolation by using a distinct field name for message strings that include interpolated data, and establishing that human-oriented subscribers should only display unrecognized key-value pairs if an interpolated message field is not present.
The text was updated successfully, but these errors were encountered: