fix: apply log_level directive to env filter for tracing subscriber#247
fix: apply log_level directive to env filter for tracing subscriber#247gaius-qi wants to merge 1 commit into
Conversation
The tracing subscriber previously used `EnvFilter::from_default_env()` together with `with_max_level(log_level)`. When `RUST_LOG` was unset, `EnvFilter` defaulted to `ERROR` and overrode the configured `log_level`, making it ineffective. Signed-off-by: Gaius <gaius.qi@gmail.com>
WalkthroughThe tracing subscriber configuration in the main entry point was refactored to use a single Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@modelexpress_server/src/main.rs`:
- Around line 51-53: The current logging setup unconditionally adds a directive
via EnvFilter::from_default_env().add_directive(log_level.into()) which
overrides RUST_LOG; change to use EnvFilter::from_env_lossy() combined with
setting the fallback via with_default_directive(log_level.into()) so the
configured log_level is only applied when RUST_LOG is unset/invalid. Locate the
EnvFilter usage (EnvFilter::from_default_env and add_directive) and replace the
construction with EnvFilter::from_env_lossy(...) / or use
EnvFilter::from_env_lossy() and pass it into
FmtSubscriber::builder().with_env_filter(...), or use the builder helper
with_default_directive(log_level.into()) before calling from_env_lossy to ensure
the configured level is a default rather than an override.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c682f952-3cc0-4479-85e0-36262b2aa136
📒 Files selected for processing (1)
modelexpress_server/src/main.rs
The tracing subscriber previously used
EnvFilter::from_default_env()together withwith_max_level(log_level). WhenRUST_LOGwas unset,EnvFilterdefaulted toERRORand overrode the configuredlog_level, making it ineffective.Summary by CodeRabbit