fix(logging): run FatalHandler on all kFatal paths - #872
Open
kamcheungting-db wants to merge 1 commit into
Open
Conversation
The FatalHandler only ran for fixed ICEBERG_LOG_FATAL; reaching kFatal via the runtime-level ICEBERG_LOG(kFatal, ...) or ICEBERG_LOG_TO(sink, kFatal, ...) aborted without invoking it (and only formatted when ShouldLog passed). Extract the fatal sequence into a shared DispatchFatal (format once -> emit-if-enabled -> flush -> run handler -> abort) and route LogFatal, LogToCurrentRuntime, and LogToExplicitRuntime through it. Adds death tests for the two runtime paths. Co-authored-by: Isaac
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.
Follow-up to #725 (merged): the registered
FatalHandlerruns only for the fixed-severityICEBERG_LOG_FATAL. ReachingkFatalthrough the runtime-level forms aborts without invoking it:ICEBERG_LOG(LogLevel::kFatal, ...)→LogToCurrentRuntimeflushes and aborts, no handler.ICEBERG_LOG_TO(sink, LogLevel::kFatal, ...)→LogToExplicitRuntime, same.Those paths also format the message only when
ShouldLog(kFatal)passes, so a handler (once wired) would miss the text for a filtered record. This was raised in review on #726; the fix didn't make it into the #725 merge, so it is submitted separately here.Change: extract the fatal sequence into a shared
internal::DispatchFatal— format the message once, emit it if the logger is enabled, flush that same logger, run any registeredFatalHandler, thenstd::abort()— and route all three fatal paths (LogFatal,LogToCurrentRuntime,LogToExplicitRuntime) through it. A handler that itself throws cannot prevent the abort.Tests: two death tests asserting the handler fires for the generic runtime-level
kFataland forICEBERG_LOG_TO(..., kFatal).Behavior for non-fatal levels and for
ICEBERG_LOG_FATALis unchanged.This pull request and its description were written by Isaac.