Skip to content

fix(logging): run FatalHandler on all kFatal paths - #872

Open
kamcheungting-db wants to merge 1 commit into
apache:mainfrom
kamcheungting-db:logging-fatal-handler-all-paths
Open

fix(logging): run FatalHandler on all kFatal paths#872
kamcheungting-db wants to merge 1 commit into
apache:mainfrom
kamcheungting-db:logging-fatal-handler-all-paths

Conversation

@kamcheungting-db

Copy link
Copy Markdown
Contributor

Follow-up to #725 (merged): the registered FatalHandler runs only for the fixed-severity ICEBERG_LOG_FATAL. Reaching kFatal through the runtime-level forms aborts without invoking it:

  • ICEBERG_LOG(LogLevel::kFatal, ...)LogToCurrentRuntime flushes 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 registered FatalHandler, then std::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 kFatal and for ICEBERG_LOG_TO(..., kFatal).

Behavior for non-fatal levels and for ICEBERG_LOG_FATAL is unchanged.

This pull request and its description were written by Isaac.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant