mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
zlog: Count module filters toward the enabled log level (#66985)
## Summary Log filters keyed by a module path, such as `"project::lsp_store": "debug"`, are stored separately from scope filters. `refresh_from_settings` computed the most verbose enabled level from the scope filters only. Records more verbose than that level are rejected before any filter is consulted, so a module filter could not enable `debug` or `trace` records unless a scope filter or `ZED_LOG` already allowed that level. The level now includes module filters. ## Testing `cargo test -p zlog` passes. `test_refresh_from_settings_with_module_filter` is new and fails without the fix. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Fixed `log` settings keyed by module path (such as `project::lsp_store`) not enabling `debug` or `trace` logs
This commit is contained in:
@@ -99,6 +99,9 @@ pub fn refresh_from_settings(settings: &HashMap<String, String>) {
|
||||
level_enabled_max = level_enabled_max.max(level as u8);
|
||||
}
|
||||
}
|
||||
for (_, level) in &map_new.modules {
|
||||
level_enabled_max = level_enabled_max.max(*level as u8);
|
||||
}
|
||||
LEVEL_ENABLED_MAX_CONFIG.store(level_enabled_max, Ordering::Release);
|
||||
|
||||
{
|
||||
@@ -542,6 +545,17 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_refresh_from_settings_with_module_filter() {
|
||||
let settings = [("a::b".to_string(), "trace".to_string())]
|
||||
.into_iter()
|
||||
.collect();
|
||||
refresh_from_settings(&settings);
|
||||
let is_enabled = is_scope_enabled(&scope_new(&[""]), Some("a::b"), log::Level::Trace);
|
||||
refresh_from_settings(&HashMap::default());
|
||||
assert!(is_enabled);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_enabled_module() {
|
||||
let mut map = scope_map_from_keys(&[("a", "trace")]);
|
||||
|
||||
Reference in New Issue
Block a user