Skip to content

error-stack: implementing conditional fmt::Display behaviour based on ColorMode for an attachment #3932

Discussion options

You must be logged in to vote

I apologize for the late reply; this completely flew under my radar.

Report::install_debug_hook is the thing you're looking for; it is invoked for every attachment type T and provides the color mode as well as charset. You will need to call install_debug_hook at the start of your application (just as you would when you're trying to configure tracing).

In the first iteration of the output, we actually thought about utilizing Display for this exact purpose but came to the conclusion that it wouldn't be of much help and that we needed to create a separate way to do this. This is because we cannot "smuggle" any data into the Formatter without sacrificing quite a bit of general usability. We a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TimDiekmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category/question Further information is requested area/libs > error-stack Affects the `error-stack` crate (library) area/libs Relates to first-party libraries/crates/packages (area) area/dx Improvements or additions to DX or docs
2 participants