LoggingRule - Update FinalMinLevel to match NLog.config#6118
LoggingRule - Update FinalMinLevel to match NLog.config#6118
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
b6622a9 to
e778708
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/NLog.UnitTests/Config/ConfigApiTests.cs (1)
343-352: Test correctly validates new FinalMinLevel behavior.The test appropriately mirrors
LogRuleMinLevel_enablesand validates that settingFinalMinLevelon a fresh rule in the Off state enables the expected levels and updatesMinLevel.Consider adding a complementary test verifying that
FinalMinLeveldoes not updateMinLevelwhen the rule already has levels enabled (i.e., when_logLevelFilteris notOff). This would ensure the conditional logic in the setter is fully exercised.💡 Optional: Additional test for non-Off state
[Fact] public void LogRuleFinalMinLevel_DoesNotChangeExistingMinLevel() { var rule = new LoggingRule(); rule.MinLevel = LogLevel.Debug; // Rule is no longer in Off state rule.FinalMinLevel = LogLevel.Warn; // MinLevel should remain Debug, not change to Warn Assert.Equal(LogLevel.Debug, rule.MinLevel); Assert.Equal(new[] { LogLevel.Debug, LogLevel.Info, LogLevel.Warn, LogLevel.Error, LogLevel.Fatal }, rule.Levels); },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/NLog.UnitTests/Config/ConfigApiTests.cs` around lines 343 - 352, Add a complementary unit test to exercise the conditional in the LoggingRule.FinalMinLevel setter: create a test (e.g., LogRuleFinalMinLevel_DoesNotChangeExistingMinLevel) that constructs a LoggingRule, sets rule.MinLevel = LogLevel.Debug (so _logLevelFilter is not Off), then sets rule.FinalMinLevel = LogLevel.Warn and asserts that rule.MinLevel remains LogLevel.Debug and rule.Levels contains the debug-through-fatal levels; this verifies FinalMinLevel does not override an existing MinLevel.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/NLog.UnitTests/Config/ConfigApiTests.cs`:
- Around line 343-352: Add a complementary unit test to exercise the conditional
in the LoggingRule.FinalMinLevel setter: create a test (e.g.,
LogRuleFinalMinLevel_DoesNotChangeExistingMinLevel) that constructs a
LoggingRule, sets rule.MinLevel = LogLevel.Debug (so _logLevelFilter is not
Off), then sets rule.FinalMinLevel = LogLevel.Warn and asserts that
rule.MinLevel remains LogLevel.Debug and rule.Levels contains the
debug-through-fatal levels; this verifies FinalMinLevel does not override an
existing MinLevel.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8c18ed1c-7815-440b-968d-d4640121c2a6
📒 Files selected for processing (2)
src/NLog/Config/LoggingRule.cstests/NLog.UnitTests/Config/ConfigApiTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/NLog/Config/LoggingRule.cs
e778708 to
df3d2f2
Compare
|
|



When specifying FinalMinLevel in Nlog.config, then it also implicitly assigns MinLevel (unless explicitly assigned).