Skip to content

Commit

Permalink
chore(config): change level to max_level
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBarriere committed Aug 20, 2020
1 parent 7cb160a commit 64fedbd
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod test {
report_logs_in_timings: true,
report_logs_in_console: true,
use_console_color: true,
level: tracing::Level::TRACE,
max_level: tracing::Level::TRACE,
}
)
}
Expand Down Expand Up @@ -94,17 +94,17 @@ mod test {

let config = builder.build();

assert_eq!(config.level, tracing::Level::TRACE);
assert_eq!(config.max_level, tracing::Level::TRACE);
}

#[test]
fn test_set_config_log_level_warn() {
let mut builder = WASMLayerConfigBuilder::new();
builder.set_level(tracing::Level::WARN);
builder.set_max_level(tracing::Level::WARN);

let config = builder.build();

assert_eq!(config.level, tracing::Level::WARN);
assert_eq!(config.max_level, tracing::Level::WARN);
}
}

Expand All @@ -122,7 +122,7 @@ pub struct WASMLayerConfigBuilder {
/// Only relevant if report_logs_in_console is true, this will use color style strings in the console.
use_console_color: bool,
/// Log events will be reported from this level -- Default is ALL (TRACE)
level: tracing::Level
max_level: tracing::Level
}

impl WASMLayerConfigBuilder {
Expand All @@ -139,12 +139,12 @@ impl WASMLayerConfigBuilder {
self
}

/// Set the minimal level on which events should be displayed
pub fn set_level(
/// Set the maximal level on which events should be displayed
pub fn set_max_level(
&mut self,
level: tracing::Level,
max_level: tracing::Level,
) -> &mut WASMLayerConfigBuilder {
self.level = level;
self.max_level = max_level;
self
}

Expand Down Expand Up @@ -177,7 +177,7 @@ impl WASMLayerConfigBuilder {
report_logs_in_timings: self.report_logs_in_timings,
report_logs_in_console: self.report_logs_in_console,
use_console_color: self.use_console_color,
level: self.level.clone(),
max_level: self.max_level.clone(),
}
}
}
Expand All @@ -188,7 +188,7 @@ impl Default for WASMLayerConfigBuilder {
report_logs_in_timings: true,
report_logs_in_console: true,
use_console_color: true,
level: tracing::Level::TRACE,
max_level: tracing::Level::TRACE,
}
}
}
Expand All @@ -198,7 +198,7 @@ pub struct WASMLayerConfig {
report_logs_in_timings: bool,
report_logs_in_console: bool,
use_console_color: bool,
level: tracing::Level
max_level: tracing::Level
}

impl core::default::Default for WASMLayerConfig {
Expand All @@ -207,7 +207,7 @@ impl core::default::Default for WASMLayerConfig {
report_logs_in_timings: true,
report_logs_in_console: true,
use_console_color: true,
level: tracing::Level::TRACE
max_level: tracing::Level::TRACE
}
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ fn mark_name(id: &tracing::Id) -> String {
impl<S: Subscriber + for<'a> LookupSpan<'a>> Layer<S> for WASMLayer {
fn enabled(&self, metadata: &tracing::Metadata<'_>, _: Context<'_, S>) -> bool {
let level = metadata.level();
level <= &self.config.level
level <= &self.config.max_level
}

fn new_span(
Expand Down

0 comments on commit 64fedbd

Please sign in to comment.