Skip to content

How do I add a memory address of a pointer as a span field? #2778

Answered by hawkw
vi asked this question in Q&A
Discussion options

You must be logged in to vote

You can use format_args!("{:p}", ...) as a normal Debug or Display field. The format_args! macro produces a type which borrows the arguments and implements Debug and Display, rather than allocating and producing a String, like format!.

It might be worthwhile to add helper functions to tracing::field for producing dyn Displays that format something using fmt::Poitner, fmt::UpperHex/fmt::LowerHex, and other formatting traits. But, in the meantime, using format_args! should work.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants