-
#[tracing::instrument(ret, level = "debug")]
pub fn myfn(context: String) -> String {
warn!("careful!");
todo!()
}i would like the return value to be logged on the "DEBUG" level only, to cut back on the logging noise. However, I want the warn!(...) log here to have the instrumented context attached to it. Right now, the context is only attached when the level is debug. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
This isn't currently possible, but it would be a good feature request! We could add something like #[tracing::instrument(ret(level = "debug"), level = "warn")]
fn whatever() -> ... {
...
}to allow changing the level for the We would probably want to do it by adding a I think this should be a fairly straightforward change, at least for someone who's familiar with procedural macros, if you're interested in implementing it? |
Beta Was this translation helpful? Give feedback.
-
|
For future generations: yes, it is possible since 0.1.24 tracing/tracing-attributes/CHANGELOG.md Lines 92 to 103 in c297a37 |
Beta Was this translation helpful? Give feedback.
This isn't currently possible, but it would be a good feature request! We could add something like
to allow changing the level for the
retevent.We would probably want to do it by adding a
ret(level = "<level>")rather than justret = "<level>"to future-proof the macro interface, so that we can add additional configuration arguments beyond setting the return event's level.I think this should be a fairly straightforward change, at least for someone who's familiar with procedural macros, if you're interested in implementing it?