It would be nice to have the option to enrich events with a template field, which would be the log line before it is interpolated. The suggestion is to have the following
let a = 10;
let b = 20;
tracing::info!(me = "im a me", ?a, "info {}, {}", b, (a + b));
output this:
// current implementation
2023-11-23T08:59:02.722507Z INFO main: info 20, 30 me="im a me" a=10
// suggested feature
2023-11-23T08:59:02.722923Z INFO main: info 20, 30 template="info {}, {}" me="im a me" a=10
This would allow log statements to be grouped by the reason and not the specifics. File+Line number can only guarantee this within the same release.
Proposal
A feature would be sufficient such that it is an opt-in option. I have tried to extend info! using a wrapper macro, but have been unable to maintain the same syntax.
Feature Request
Crates
Motivation
It would be nice to have the option to enrich events with a template field, which would be the log line before it is interpolated. The suggestion is to have the following
output this:
This would allow log statements to be grouped by the reason and not the specifics. File+Line number can only guarantee this within the same release.
Proposal
A feature would be sufficient such that it is an opt-in option. I have tried to extend
info!
using a wrapper macro, but have been unable to maintain the same syntax.This would be triggered using
info!(me="im a me", ?a, : "info {}, {}", b, (a+b));
With my limited skills in macroing, the above has a few drawbacks:
:
has to be prefixed to the template stringa+b
does not compile without)Alternative solution
It might be (probably is) a better option to update the underlying info or event macro instead of wrapping them.