Skip to content

Commit

Permalink
Merge pull request #536 from EriKWDev/master
Browse files Browse the repository at this point in the history
Remove dependency on cfg_if
  • Loading branch information
KodrAus authored Dec 3, 2022
2 parents d670710 + 969281e commit fc9ab1e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 29 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ kv_unstable_std = ["std", "kv_unstable", "value-bag/error"]
kv_unstable_serde = ["kv_unstable_std", "value-bag/serde", "serde"]

[dependencies]
cfg-if = "1.0"
serde = { version = "1.0", optional = true, default-features = false }
sval = { version = "=1.0.0-alpha.5", optional = true, default-features = false }
value-bag = { version = "=1.0.0-alpha.9", optional = true, default-features = false }
Expand Down
79 changes: 51 additions & 28 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@
#[cfg(all(not(feature = "std"), not(test)))]
extern crate core as std;

#[macro_use]
extern crate cfg_if;

use std::cmp;
#[cfg(feature = "std")]
use std::error;
Expand Down Expand Up @@ -1507,31 +1504,57 @@ pub mod __private_api {
/// [`logger`]: fn.logger.html
pub const STATIC_MAX_LEVEL: LevelFilter = MAX_LEVEL_INNER;

cfg_if! {
if #[cfg(all(not(debug_assertions), feature = "release_max_level_off"))] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Off;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_error"))] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Error;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_warn"))] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Warn;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_info"))] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Info;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_debug"))] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Debug;
} else if #[cfg(all(not(debug_assertions), feature = "release_max_level_trace"))] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Trace;
} else if #[cfg(feature = "max_level_off")] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Off;
} else if #[cfg(feature = "max_level_error")] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Error;
} else if #[cfg(feature = "max_level_warn")] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Warn;
} else if #[cfg(feature = "max_level_info")] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Info;
} else if #[cfg(feature = "max_level_debug")] {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Debug;
} else {
const MAX_LEVEL_INNER: LevelFilter = LevelFilter::Trace;
const MAX_LEVEL_INNER: LevelFilter = get_max_level_inner();

const fn get_max_level_inner() -> LevelFilter {
#[allow(unreachable_code)]
{
#[cfg(all(not(debug_assertions), feature = "release_max_level_off"))]
{
return LevelFilter::Off;
}
#[cfg(all(not(debug_assertions), feature = "release_max_level_error"))]
{
return LevelFilter::Error;
}
#[cfg(all(not(debug_assertions), feature = "release_max_level_warn"))]
{
return LevelFilter::Warn;
}
#[cfg(all(not(debug_assertions), feature = "release_max_level_info"))]
{
return LevelFilter::Info;
}
#[cfg(all(not(debug_assertions), feature = "release_max_level_debug"))]
{
return LevelFilter::Debug;
}
#[cfg(all(not(debug_assertions), feature = "release_max_level_trace"))]
{
return LevelFilter::Trace;
}
#[cfg(feature = "max_level_off")]
{
return LevelFilter::Off;
}
#[cfg(feature = "max_level_error")]
{
return LevelFilter::Error;
}
#[cfg(feature = "max_level_warn")]
{
return LevelFilter::Warn;
}
#[cfg(feature = "max_level_info")]
{
return LevelFilter::Info;
}
#[cfg(feature = "max_level_debug")]
{
return LevelFilter::Debug;
}

LevelFilter::Trace
}
}

Expand Down

0 comments on commit fc9ab1e

Please sign in to comment.