trace: Simplify dynamic tracing level application #380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I've been looking to refactor the trace layer (really kind of rewrite it, but I wanted to read most of the existing code and ideally transform it piece by piece instead of starting from scratch, which would likely lead to lots of going back and forth as I discover new things that the old code supported that aren't that easy).
As part of that, I found the
log_pattern_match
macros and thought that there had to be a better way. And I think I found a better way :)Solution
event!
invocations for differentformat_args!
strings, instead create a custom type that implementsDisplay
and create it on-the-fly to then log itevent!
invocations for when a field is supposed to be captured vs. not, instead make the field value anOption
which has the same effect (not 100% the same I think, theFieldSet
for the event will always contain the field now, but theValueSet
will still behave the same which should be the only practically relevant thing)event!
s with a non-const
level