tracing
tracing copied to clipboard
Use macros for module declarations on fmt module
Motivation
ref: https://github.com/tokio-rs/tracing/pull/1009
This is code refactoring. Currently, there is a lot of code that declares modules as follows:
#[cfg(feature = "registry")]
#[cfg_attr(docsrs, doc(cfg(feature = "registry")))]
pub use registry::Registry;
#[cfg(feature = "registry")]
#[cfg_attr(docsrs, doc(cfg(feature = "registry")))]
pub fn registry() -> Registry {
Registry::default()
}
It is verbose to write a module declaration multiple times using the feature attribute. Also, if the definition for the same feature spans multiple places, it will be a little harder to read the code.
Solution
You can combine features attributes in one place by writing as follows. It also eliminates the need to write the same code over and over again.
cfg_feature!("feature" ,{
pub use registry::Registry;
pub fn registry() -> Registry {
Registry::default()
}
});
Thanks! Can you format this PR to pass CI?
Do you know why ci displays an error?
Looks like some merge conflicts need to be resolved?
We could probably still re-base and get this merged fyi @k-nasa