-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: configurable threshold and colorful output #6
base: main
Are you sure you want to change the base?
Conversation
Please run the |
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.
Thanks for your contribution! May run cargo fmt
and cargo clippy
to pass the checks.
.idea/workspace.xml
Outdated
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.
Would you please remove this file?
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.
Yeah. I would do this, sorry for irrelevant file.
@@ -29,13 +30,23 @@ use crate::Span; | |||
#[builder(default)] | |||
pub struct Config { | |||
/// Whether to include the **verbose** span in the await-tree. | |||
verbose: bool, | |||
pub verbose: bool, |
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.
We may keep these fields private (or pub(crate)
) and use ConfigBuilder
to construct a Config
.
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.
We may keep these fields private (or
pub(crate)
) and useConfigBuilder
to construct aConfig
.
Current config is simple, only three fields, but the disign pattern is up to you. Maybe the current version is enough.
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.
We already have ConfigBuilder
now (by deriving Builder
) so there's no extra effort required. :)
|
||
/// Whether to coloring the terminal | ||
colored: bool, | ||
|
||
/// if the time of execution is beyond it, warn it | ||
warn_threshold: time::Duration, |
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 about directly storing a Config
here?
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 about directly storing a
Config
here?
If put Config
here, the field verbose
is not used by context.
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.
Yeah, you're right. So I'm considering whether colored
and warn_threshold
should be properties of tree formatting, instead of the tree or the registry. 🤔 For example, we have...
struct FormatConfig {
colored: bool,
warn_threshold: time::Duration,
}
pub struct FormatTree<'a> {
tree: &'a Tree,
config: FormatConfig
}
impl Display for FormatTree<'_> { .. }
impl Tree {
pub fn display(&self, config: FormatConfig) -> FormatTree<'_> { .. }
}
impl Display for Tree { /* delegate to `self.display(FormatConfig::default()).fmt(f)` */ }
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.
Yes, It could be done this way.
Co-authored-by: Bugen Zhao <[email protected]>
Co-authored-by: Bugen Zhao <[email protected]>
Made it~ |
Hey, what is the current progress of this MR? Is there something need to do from my side? |
@@ -19,6 +19,7 @@ parking_lot = "0.12" | |||
pin-project = "1" | |||
tokio = { version = "1", features = ["rt"] } | |||
tracing = "0.1" | |||
colored = "2" |
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 we should hide this under a feature?
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.
Both LGTM :)
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.
Yeah, both LGTM. They are about the balance between performance and convenience.
@@ -19,6 +19,7 @@ parking_lot = "0.12" | |||
pin-project = "1" | |||
tokio = { version = "1", features = ["rt"] } | |||
tracing = "0.1" | |||
colored = "2" |
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.
Both LGTM :)
The time of warn threshlod may be configurable and colorable.