Skip to content

Commit

Permalink
fmt: fix EnvFilter rejecting levels equal to the filter level (#75)
Browse files Browse the repository at this point in the history
PR #72 introduced a bug in `EnvFilter` where spans and events whose
level is _equal_ to the filter's max level are rejected, rather than
accepted. This branch fixes the comparisons so that filters once again
work as expected.

Signed-off-by: Eliza Weisman <[email protected]>
  • Loading branch information
hawkw authored Jun 21, 2019
1 parent d74867e commit 2bf7c61
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tokio-trace-fmt/src/filter/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ where

impl<N> Filter<N> for EnvFilter {
fn callsite_enabled(&self, metadata: &Metadata, _: &Context<N>) -> Interest {
if !self.includes_span_directive && self.max_level <= *metadata.level() {
if !self.includes_span_directive && self.max_level < *metadata.level() {
return Interest::never();
}

let mut interest = Interest::never();
for directive in self.directives_for(metadata) {
let accepts_level = directive.level > *metadata.level();
let accepts_level = directive.level >= *metadata.level();
match directive.in_span.as_ref() {
// The directive applies to anything within the span described
// by this metadata. The span must always be enabled.
Expand All @@ -129,7 +129,7 @@ impl<N> Filter<N> for EnvFilter {

fn enabled<'a>(&self, metadata: &Metadata, ctx: &Context<'a, N>) -> bool {
for directive in self.directives_for(metadata) {
let accepts_level = directive.level > *metadata.level();
let accepts_level = directive.level >= *metadata.level();
match directive.in_span.as_ref() {
// The directive applies to anything within the span described
// by this metadata. The span must always be enabled.
Expand Down

0 comments on commit 2bf7c61

Please sign in to comment.