-
Notifications
You must be signed in to change notification settings - Fork 850
Open
Description
Feature Request:
Crates
tracing_attributes
Motivation
Currently, instrument macro uses debug format for all arguments on the function annotated.
However, sometimes the display version of the arguments is preferred as it's often more human friendly. The only current way to do so is to manually add each one to the fields argument with the display format specified. This is verbose, and error prone when modifying the function arguments.
e.g.
#[instrument(fields(a = %a, b = %b, c = %c, d = %d, ...)]
fn foo(a: Box<dyn Display>, b: Box<dyn Display>, ...) { ... }
Proposal
Add a new argument to instrument macro that allows specifies the format of the function arguments.
Example
#[instrument(fmt = tracing::value::display)
fn foo(a: Box<dyn Display>, b: Box<dyn Display>, ...) { ... }
We can change this line. https://docs.rs/tracing-attributes/0.1.15/src/tracing_attributes/lib.rs.html#652
to not hard-code debug format.
Open to implementing this change if there's no objections to this feature.
Alternatives
- Leave as is. => :(
- introduce a separate macro like
display_instrument
let4be, BGR360, NAlexPear, dfaust and elichai
Metadata
Metadata
Assignees
Labels
No labels