zed-industries/zed · error

Cannot set multiple max levels

Error message

Cannot set multiple max levels

What it means

Raised in zlog filter parsing: the filter string specified more than one bare (name-less) max level, e.g. 'info,warn'. Only one global max level is allowed; additional directives must be 'name=level' pairs.

Source

Thrown at crates/zlog/src/env_config.rs:28

    let mut max_level = None;
    let mut directive_names = Vec::new();
    let mut directive_levels = Vec::new();

    for directive in filter.split(',') {
        match directive.split_once('=') {
            Some((name, level)) => {
                anyhow::ensure!(!level.contains('='), "Invalid directive: {directive}");
                let level = parse_level(level.trim())?;
                directive_names.push(name.trim().trim_end_matches(".rs").to_string());
                directive_levels.push(level);
            }
            None => {
                let Ok(level) = parse_level(directive.trim()) else {
                    directive_names.push(directive.trim().trim_end_matches(".rs").to_string());
                    directive_levels.push(log::LevelFilter::max() /* Enable all levels */);
                    continue;
                };
                anyhow::ensure!(max_level.is_none(), "Cannot set multiple max levels");
                max_level.replace(level);
            }
        };
    }

    Ok(EnvFilter {
        level_global: max_level,
        directive_names,
        directive_levels,
    })
}

fn parse_level(level: &str) -> Result<log::LevelFilter> {
    if level.eq_ignore_ascii_case("TRACE") {
        return Ok(log::LevelFilter::Trace);
    }
    if level.eq_ignore_ascii_case("DEBUG") {
        return Ok(log::LevelFilter::Debug);

View on GitHub (pinned to f4178619ac)

Solutions

  1. Remove duplicate bare level directives and keep a single global level
  2. Use per-module directives instead of multiple global levels
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zlog/src/env_config.rs:28 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/11b54000e0e58134. Report an issue: GitHub.