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
I am trying to enable pretty printing (i.e. :#?) in traces. According to this comment, the way to do this is via debug_alt:
use tracing_subscriber::field::MakeExt;
tracing_subscriber::fmt().map_fmt_fields(|f| f.debug_alt()).init();
This works, but I want to be able to just use the pretty() subscriber builder, and just customize this one option. I thought I could do something like:
use tracing_subscriber::field::MakeExt;
tracing_subscriber::fmt().pretty().map_fmt_fields(|f| f.debug_alt()).init();
but this doesn't compile due to the following error:
error[E0599]: the method `debug_alt` exists for struct `Pretty`, but its trait bounds were not satisfied
--> script.rs:21:27
|
21 | .map_fmt_fields(|f| f.debug_alt())
| ^^^^^^^^^ method cannot be called on `Pretty` due to unsatisfied trait bounds
|
::: D:\.tools\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tracing-subscriber-0.3.18\src\fmt\format\pretty.rs:99:1
|
99 | pub struct Pretty {
| ----------------- doesn't satisfy `Pretty: MakeExt<_>`, `Pretty: MakeVisitor<_>` or `_: Sealed<MakeExtMarker<_>>`
|
= note: the following trait bounds were not satisfied:
`Pretty: MakeVisitor<_>`
which is required by `Pretty: MakeExt<_>`
`Pretty: tracing_subscriber::sealed::Sealed<MakeExtMarker<_>>`
which is required by `Pretty: MakeExt<_>`
`&Pretty: MakeVisitor<_>`
which is required by `&Pretty: MakeExt<_>`
`&Pretty: tracing_subscriber::sealed::Sealed<MakeExtMarker<_>>`
which is required by `&Pretty: MakeExt<_>`
`&mut Pretty: MakeVisitor<_>`
which is required by `&mut Pretty: MakeExt<_>`
`&mut Pretty: tracing_subscriber::sealed::Sealed<MakeExtMarker<_>>`
which is required by `&mut Pretty: MakeExt<_>`
It looks like in the 2nd snippet, f is a Pretty which doesn't implement MakeVisitor so the blanket implementdation of MakeExt doesn't apply to it. This means that debug_alt doesnt exist for it. In the first snippet, it compiles because f is DefaultFields which implements MakeVisitor.
Is this just a bug or is there a reason that Pretty doesn't implement MakeVisitor? AFAIU, there is also a PrettyFields struct that does implement MakeVistor, but for some reason, fmt().pretty() returns a Builder that uses Pretty as the generic arg instead of PrettyFields. This diverges from the fmt().json() behavior which returns a JsonFields.
Is there a better way to achieve what I want to do?
The text was updated successfully, but these errors were encountered:
Bug Report
Version
tracing-subscriber v0.3.18
tracing-core v0.1.32
tracing-log v0.2.0
Platform
64Bit Windows 11
Crates
tracing-subscriber
Description
I am trying to enable pretty printing (i.e.
:#?
) in traces. According to this comment, the way to do this is viadebug_alt
:This works, but I want to be able to just use the
pretty()
subscriber builder, and just customize this one option. I thought I could do something like:but this doesn't compile due to the following error:
It looks like in the 2nd snippet,
f
is aPretty
which doesn't implementMakeVisitor
so the blanket implementdation ofMakeExt
doesn't apply to it. This means thatdebug_alt
doesnt exist for it. In the first snippet, it compiles becausef
isDefaultFields
which implementsMakeVisitor
.Is this just a bug or is there a reason that
Pretty
doesn't implementMakeVisitor
? AFAIU, there is also aPrettyFields
struct that does implementMakeVistor
, but for some reason,fmt().pretty()
returns a Builder that usesPretty
as the generic arg instead ofPrettyFields
. This diverges from thefmt().json()
behavior which returns aJsonFields
.Is there a better way to achieve what I want to do?
The text was updated successfully, but these errors were encountered: