-
Notifications
You must be signed in to change notification settings - Fork 754
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
tracing_subscriber::fmt::init() vs tracing_subscriber::fmt().init() #1329
Comments
The different between (a)
pub fn try_init() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let builder = Collector::builder();
#[cfg(feature = "env-filter")]
let builder = builder.with_env_filter(crate::EnvFilter::from_default_env());
builder.try_init()
} default = ["env-filter", "smallvec", "fmt", "ansi", "chrono", "tracing-log", "json"] This isn't a bug I think. However, we did need better documentation or keep only one |
That very confusing, these name are too close. |
This resolves the disparity between fmt::init() and fmt().init(). Unfortunately, this involves a change to type signature and therefore is a breaking change. Close tokio-rs#1329
Can we please fix the docs to stop claiming that Heck, the extra setup it does should be pulled out into a helper. I would really love to be able to easily add that behavior to my subscriber without losing the ability to customize it further (and without having to care about the presence of |
Previously the documentation for `fmt::init()` was misleading. It stated that it was shorthand for `fmt().init()`. This lead to confusion as users would expect the same behavior from both. However `fmt::init()` would, whether you used the env-filter feature or not, rely on RUST_LOG to set the tracing level. `fmt().init()` does not do this and it must be set with a specific configuration via `with_env_filter`. The documentation has been updated to no longer state that it is 1:1 shorthand for the other. The documentation now specifically points out that you must be using the `env-filter` feature and gives a correct example to mimic the `fmt::init()` behavior using `fmt().init()`. fixes: tokio-rs#2217 tokio-rs#1329
## Motivation Previously the documentation for `fmt::init()` was misleading. It stated that it was shorthand for `fmt().init()`. This lead to confusion as users would expect the same behavior from both. However `fmt::init()` would, whether you used the env-filter feature or not, rely on RUST_LOG to set the tracing level. `fmt().init()` does not do this and it must be set with a specific configuration via `with_env_filter`. ## Solution The documentation has been updated to no longer state that it is 1:1 shorthand for the other. The documentation now specifically points out that you must be using the `env-filter` feature and gives a correct example to mimic the `fmt::init()` behavior using `fmt().init()`. Fixes #2217 Fixes #1329 Co-authored-by: Eliza Weisman <[email protected]>
## Motivation Previously the documentation for `fmt::init()` was misleading. It stated that it was shorthand for `fmt().init()`. This lead to confusion as users would expect the same behavior from both. However `fmt::init()` would, whether you used the env-filter feature or not, rely on RUST_LOG to set the tracing level. `fmt().init()` does not do this and it must be set with a specific configuration via `with_env_filter`. ## Solution The documentation has been updated to no longer state that it is 1:1 shorthand for the other. The documentation now specifically points out that you must be using the `env-filter` feature and gives a correct example to mimic the `fmt::init()` behavior using `fmt().init()`. Fixes tokio-rs#2217 Fixes tokio-rs#1329 Co-authored-by: Eliza Weisman <[email protected]>
Bug Report
Version
tracing: 0.125
tracing-subscriber: 0.2.17
Platform
Crates
tracing-subscriber
Description
The docs for
tracing_subscriber::fmt::init()
state the following:So for a basic example, I used:
This doesn't output anything in the console for me:
However, using the code that this is supposed to be "shorthand" for (
tracing_subscriber::fmt().init()
) works fine:I'm not too sure what's causing this issue on my end, but the docs for tracing-subscriber suggest using the former to initialize everything, which doesn't work in my testing.
The text was updated successfully, but these errors were encountered: