-
Notifications
You must be signed in to change notification settings - Fork 1.4k
LoggerImpl - Merge WriteToTargetWithFilterChain into Write #6008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughInlines per-target filter handling into LoggerImpl, centralizes call-site capture via a new CaptureCallSiteInfo, changes error handling for capture failures to warn, and removes call-site/stack-trace helper methods from TargetWithFilterChain. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Logger
participant Capture as CaptureCallSiteInfo
participant Filters as PerTargetFilters
participant Target
Logger->>Capture: CaptureCallSiteInfo(loggerType, targetsForLevel, logEvent, logFactory)
alt Call-site optimization succeeds
Capture-->>Logger: set CallerClassName (no stack-trace)
else Need stack-trace
Capture->>Capture: try capture StackTrace (guarded)
alt Capture success
Capture-->>Logger: set CallerClassName
else Capture failed
Capture-->>Logger: InternalLogger.Warn(...)
Note right of Logger: rethrow only if DEBUG or ThrowExceptions
end
end
Logger->>Filters: evaluate filters for each target (in-place)
alt Result == Log or LogFinal
Logger->>Target: Write(logEvent) [async]
alt Result == LogFinal
Note right of Logger: stop processing further targets
end
else Result == Ignore or IgnoreFinal
Logger->>Logger: InternalLogger.Debug("Rejected by filter")
alt Result == IgnoreFinal
Note right of Logger: stop processing further targets
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧬 Code graph analysis (1)src/NLog/LoggerImpl.cs (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
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 |
654a31e to
3ea23c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/NLog/LoggerImpl.cs (1)
89-89: Include filter result in debug for quicker diagnosisLogging the actual FilterResult helps triage why it stopped/continued.
- InternalLogger.Debug("{0} [{1}] Rejecting message because of a filter.", logEvent.LoggerName, logEvent.Level); + InternalLogger.Debug("{0} [{1}] Rejecting message because of filter result: {2}.", logEvent.LoggerName, logEvent.Level, result);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/NLog/LoggerImpl.cs(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/NLog/LoggerImpl.cs (5)
src/NLog/Internal/StackTraceUsageUtils.cs (1)
StackTraceUsage(50-68)src/NLog/Internal/TargetWithFilterChain.cs (11)
StackTraceUsage(98-118)TargetWithFilterChain(47-416)TargetWithFilterChain(51-51)TargetWithFilterChain(61-66)TargetWithFilterChain(120-128)TargetWithFilterChain(204-215)TargetWithFilterChain(295-312)TryCallSiteClassNameOptimization(314-326)TryLookupCallSiteClassName(362-375)MustCaptureStackTrace(328-340)TryRememberCallSiteClassName(342-360)src/NLog/Targets/Target.cs (1)
WriteAsyncLogEvent(308-341)src/NLog/LogEventInfo.cs (14)
LogEventInfo(51-844)LogEventInfo(79-85)LogEventInfo(93-96)LogEventInfo(105-119)LogEventInfo(129-134)LogEventInfo(145-158)LogEventInfo(169-185)LogEventInfo(196-199)LogEventInfo(210-219)LogEventInfo(487-490)LogEventInfo(499-502)LogEventInfo(527-539)LogEventInfo(550-553)SetStackTrace(594-597)src/NLog/Internal/CallSiteInformation.cs (1)
SetStackTrace(106-122)
🔇 Additional comments (2)
src/NLog/LoggerImpl.cs (2)
81-86: Early-termination semantics look correctHandling LogFinal/IgnoreFinal by breaking the loop matches expected behavior and avoids unnecessary target writes.
Also applies to: 89-91
99-133: Confirm log level and rethrow policy for call-site captureCatch now emits
InternalLogger.Warninstead of Error on capture failures and rethrows only whenThrowExceptions/LogManager.ThrowExceptionsare set. Please confirm this change is intended and won’t mask important diagnostics on platforms with partial stack-trace support.Verified removal of
WriteToTargetWithFilterChainand that allCaptureCallSiteInfocalls use the new four-parameter signature.
|



No description provided.