-
Notifications
You must be signed in to change notification settings - Fork 15
refactor: marker is mdc #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
} | ||
|
||
impl Diagnostic { | ||
pub fn name(&self) -> &'static str { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this method for? Since it's supposed to by dyn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously I use it to filter all the context provided from FastraceDiagnostic in some case.
That is, a key-value in MDC can be considered as (context_name, key_name, value) and implementor of append/layout can filter kvs by either name. But it may not be used now and perhaps over design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be over designed.. The application, who configurates logforth, has the control over which diagnostic goes through which append. So I don't think it's necessary to let the append filter on diagnostic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in a new PR.
"thread-local" | ||
} | ||
|
||
pub fn insert<K, V>(&self, key: K, value: V) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove &self?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as rustc can eliminate the overhead, I'd prefer to keep the helper struct to align concepts - https://x.com/tison1096/status/1877365316621115855
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could the user, who want's to set the kv, get the MDC to call the methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the same so it's easy to get a copy by let diag = ThreadLocalDiagnostic::default()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But perhaps ThreadLocalDiagnostic::insert(k, v)
would be OK.
}); | ||
} | ||
|
||
pub fn remove(&self, key: &str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Ref - rust-lang/log#655