Skip to content

Do you use LevelFilter with < or <=? #1993

Closed
@CAD97

Description

@CAD97

Bug Report

Version

│   └── tracing v0.1.32
│       ├── tracing-attributes v0.1.20 (proc-macro)
│       └── tracing-core v0.1.23
├── tracing v0.1.32 (*)
├── tracing-appender v0.2.1
│   └── tracing-subscriber v0.3.9
│       ├── tracing-core v0.1.23 (*)
│       └── tracing-log v0.1.2
│           └── tracing-core v0.1.23 (*)
└── tracing-subscriber v0.3.9 (*)

Platform

Microsoft Windows Version 21H2 (OS Build 19044.1586)

Crates

tracing-core

Description

When checking if a level is (statically) enabled, is it Level::TRACE < STATIC_MAX_LEVEL or Level::TRACE <= STATIC_MAX_LEVEL?

LevelFilter docs:

If a Level is considered less than a LevelFilter, it should be considered enabled; if greater than or equal to the LevelFilter, that level is disabled. See LevelFilter::current for more details.

LevelFilter::current docs:

If a given span or event has a level higher than the returned LevelFilter, it will not be enabled. However, if the level is less than or equal to this value, the span or event is not guaranteed to be enabled; the subscriber will still filter each callsite individually.

The type docs seem to say that is_enabled = level < filter and is_disabled = level >= filter.

The method docs seem to say that is_disabled = level > filter and is_enabled = level <= filter.

Which one is it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions