Skip to content

Commit

Permalink
Merge branch 'master' into v0.1.x-time-update
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw authored Apr 13, 2023
2 parents d1e5adf + 5722b45 commit 91cf34b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
1 change: 0 additions & 1 deletion tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ rust-version = "1.56.0"
tracing-core = { path = "../tracing-core", version = "0.2", default-features = false }
log = { version = "0.4.17", optional = true }
tracing-attributes = { path = "../tracing-attributes", version = "0.2", optional = true }
cfg-if = "1.0.0"
pin-project-lite = "0.2.9"

[dev-dependencies]
Expand Down
54 changes: 29 additions & 25 deletions tracing/src/level_filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,36 @@ pub use tracing_core::{metadata::ParseLevelFilterError, LevelFilter};
/// determine if those spans or events are enabled.
///
/// [module-level documentation]: self#compile-time-filters
pub const STATIC_MAX_LEVEL: LevelFilter = MAX_LEVEL;
pub const STATIC_MAX_LEVEL: LevelFilter = get_max_level_inner();

cfg_if::cfg_if! {
if #[cfg(all(not(debug_assertions), feature = "release_max_level_off"))] {
const MAX_LEVEL: LevelFilter = LevelFilter::OFF;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_error"))] {
const MAX_LEVEL: LevelFilter = LevelFilter::ERROR;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_warn"))] {
const MAX_LEVEL: LevelFilter = LevelFilter::WARN;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_info"))] {
const MAX_LEVEL: LevelFilter = LevelFilter::INFO;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_debug"))] {
const MAX_LEVEL: LevelFilter = LevelFilter::DEBUG;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_trace"))] {
const MAX_LEVEL: LevelFilter = LevelFilter::TRACE;
} else if #[cfg(feature = "max_level_off")] {
const MAX_LEVEL: LevelFilter = LevelFilter::OFF;
} else if #[cfg(feature = "max_level_error")] {
const MAX_LEVEL: LevelFilter = LevelFilter::ERROR;
} else if #[cfg(feature = "max_level_warn")] {
const MAX_LEVEL: LevelFilter = LevelFilter::WARN;
} else if #[cfg(feature = "max_level_info")] {
const MAX_LEVEL: LevelFilter = LevelFilter::INFO;
} else if #[cfg(feature = "max_level_debug")] {
const MAX_LEVEL: LevelFilter = LevelFilter::DEBUG;
const fn get_max_level_inner() -> LevelFilter {
if cfg!(not(debug_assertions)) {
if cfg!(feature = "release_max_level_off") {
LevelFilter::OFF
} else if cfg!(feature = "release_max_level_error") {
LevelFilter::ERROR
} else if cfg!(feature = "release_max_level_warn") {
LevelFilter::WARN
} else if cfg!(feature = "release_max_level_info") {
LevelFilter::INFO
} else if cfg!(feature = "release_max_level_debug") {
LevelFilter::DEBUG
} else {
// Same as branch cfg!(feature = "release_max_level_trace")
LevelFilter::TRACE
}
} else if cfg!(feature = "max_level_off") {
LevelFilter::OFF
} else if cfg!(feature = "max_level_error") {
LevelFilter::ERROR
} else if cfg!(feature = "max_level_warn") {
LevelFilter::WARN
} else if cfg!(feature = "max_level_info") {
LevelFilter::INFO
} else if cfg!(feature = "max_level_debug") {
LevelFilter::DEBUG
} else {
const MAX_LEVEL: LevelFilter = LevelFilter::TRACE;
// Same as branch cfg!(feature = "max_level_trace")
LevelFilter::TRACE
}
}

0 comments on commit 91cf34b

Please sign in to comment.