fix: logging.level 与 launch.separate_window 配置不生效 - #10
Merged
Conversation
- logging: 用 LevelFilter 替换 EnvFilter, 通过 with_filter 应用到每个 fmt layer (EnvFilter 作为 Vec layer 成员无法过滤兄弟 fmt layer, 导致 level 配置无效) - launch: separate_window 合并 config.launch.separate_window 与 CLI 参数 - main: 配置加载后输出 debug 日志便于诊断 - test: 新增 logging_and_launch_fields_parsed 覆盖两个字段解析
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
用户报告: 修改
config/config.toml中的logging.level和launch.separate_window不生效。根因
logging.level不生效:init_logging使用EnvFilter::new()并push到Vec<Box<dyn Layer>>中。EnvFilter 作为 Vec 中的兄弟 layer 无法过滤其他 fmt layer —— 每个 fmt layer 按自己的默认LevelFilter(INFO)输出,导致配置的trace/debug级别无效。launch.separate_window不生效:execute_once只读取cli.launch.separate_window(CLI 参数),完全忽略config.launch.separate_window。配置文件里设为true不生效。修复
src/logging/init.rsEnvFilter→LevelFilter::from_str(&resolve_level(...)),通过.with_filter(level_filter)应用到每个 fmt layer(console + file)src/launch/execute.rsseparate_window: cli.launch.separate_window || config.launch.separate_window,CLI 与 config 合并(CLI 优先);增加 spawn debug 日志src/main.rssrc/config/loader.rslogging_and_launch_fields_parsed覆盖两个字段的 TOML 解析验证
cargo build通过cargo test: 95 passed(含新增测试)cargo fmt --all -- --check干净cargo clippy --all-targets --all-features: 零警告隐私
提交前扫描: 仅 4 个
src/源码文件,config/与logs/均未被 git 跟踪,无私人文件混入。