You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My request is that tracing::instrument supports using the pretty-print debug specifier (i.e., {:#?}) to print fields instead of the regular debug specifier (i.e.,{:?}).
I use tracing::instrument liberally when hacking on the Rust compiler. Oftentimes, the logs get really hard to read when a function has many parameters and each parameter has many fields and nested structs. I very frequently find myself wanting the ability to pretty-print fields so I can more easily see what's going on.
Proposal
No strong feelings on exactly how it should work. Here's one idea:
Note, though, that you can also do this by skipping all the automatically-generated fields, and adding custom fields using your own wrapper type. For example:
#[tracing::instrument( skip(foo, bar), fields(foo = ?my_wrapper(foo), bar = ?my_wrapper(bar)))]fnmy_function(foo:Foo,bar:Bar){/// ...}
Too much work :P
The text was updated successfully, but these errors were encountered:
Something like this is already supported, but it's extremely non-obvious and it took me around an hour to find. The format using # is called the alternate format, and you can tell tracing_subscriber to use it:
use tracing_subscriber::field::MakeExt;
tracing_subscriber::fmt().map_fmt_fields(|f| f.debug_alt()).init();
Feature Request
My request is that
tracing::instrument
supports using the pretty-print debug specifier (i.e.,{:#?}
) to print fields instead of the regular debug specifier (i.e.,{:?}
).Related to / possibly overlapping with:
#[instrument]
macro offer default format specifier #1312Display
#1311Result
usingerr
viaDebug
instead of onlyDisplay
#1630tracing-attributes
#1089Crates
tracing-attributes
Motivation
I use
tracing::instrument
liberally when hacking on the Rust compiler. Oftentimes, the logs get really hard to read when a function has many parameters and each parameter has many fields and nested structs. I very frequently find myself wanting the ability to pretty-print fields so I can more easily see what's going on.Proposal
No strong feelings on exactly how it should work. Here's one idea:
Two new options,
pretty
andpretty_all
:Perhaps this could be generalized so that users could write their own field formatter and easily inject that into the
instrument
invocation:EDIT: I think this is precisely the idea of #1312
Alternatives
Quoting from #1089 (comment):
Too much work :P
The text was updated successfully, but these errors were encountered: