-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Logging macro `if_log_enabled` checks both `log` and `always-log` crate features to select which macro version to use. Unfortunately, `log` feature cannot be set by crate consumers in either existing form or if added to `Cargo.toml`, probably because of a name clash with `log` crate: ```diff $ git diff Cargo.toml diff --git a/tracing/Cargo.toml b/tracing/Cargo.toml index 37bb61f..e030d27 100644 --- a/tracing/Cargo.toml +++ b/tracing/Cargo.toml @@ -63,7 +63,7 @@ release_max_level_trace = [] async-await = [] std = ["tracing-core/std"] +log = ["log"] log-always = ["log"] attributes = ["tracing-attributes"] ``` ``` Caused by: optional dependency `log` is not included in any feature Make sure that `dep:log` is included in one of features in the [features] table. ``` I'm renaming `log` feature to `logging` to work around that. With the following code: ```rust let now = std::time::Instant::now(); eprintln!("before span created us = {}", now.elapsed().as_micros()); let span = tracing::span!(tracing::Level::TRACE, "setup"); eprintln!("after span created us = {}", now.elapsed().as_micros()); let entered = span.enter(); eprintln!("after enter us = {}", now.elapsed().as_micros()); drop(entered); eprintln!("after entered drop us = {}", now.elapsed().as_micros()); drop(span); eprintln!("after span drop us = {}", now.elapsed().as_micros()); ``` Typical timings with logging feature enabled (but not logging anything): ``` before span created us = 0 after span created us = 8 after enter us = 9 after entered drop us = 13 after span drop us = 14 ``` Typical timings with logging disabled (this PR): ``` before span created us = 0 after span created us = 1 after enter us = 3 after entered drop us = 5 after span drop us = 6 ```
- Loading branch information
Showing
4 changed files
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters