Move CaptureUnhandledExceptions into config builder#14
Merged
Conversation
Tie exception capture lifecycle to LogConfig so handlers are automatically unsubscribed on Reconfigure() and Shutdown(), eliminating the need for manual StopCapturing calls. Breaking change: remove LogManager.CaptureUnhandledExceptions() and LogManager.StopCapturingUnhandledExceptions() public methods. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f555364 to
fe29a61
Compare
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.
Summary
Reason for Change
CaptureUnhandledExceptionswas a standalone static method onLogManagerwith a lifetime decoupled from the logging configuration. Developers had to manually callStopCapturingUnhandledExceptions(), and forgetting to do so leaked event subscriptions. Moving it into the config builder ties its lifecycle toReconfigure()andShutdown().Impact
LogConfigBuildergainsCaptureUnhandledExceptions(bool observeTaskExceptions = false)methodLogConfigstores capture flags; handlers are automatically subscribed/unsubscribed during config swaps_config?.ErrorHandler(theInternalErrorHandler) instead of a separate static delegateSetMinimumLevel/SetCategoryOverridesinternal methods carry exception capture flags to new configsMigration Steps
Replace:
With:
Performance Considerations
No performance impact — same
Interlockedguard pattern, same event handler logic.Security Considerations
None.
Breaking Changes
LogManager.CaptureUnhandledExceptions()andLogManager.StopCapturingUnhandledExceptions()public methods removed. Exception handler parameter removed — routes toInternalErrorHandlerinstead._exceptionHandlerstatic field removed fromLogManager.