From f2c331f14c6085fed363890ff9552a7ca9d8b18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjell=20Hedstr=C3=B6m?= Date: Thu, 24 May 2018 17:10:53 -0600 Subject: [PATCH] Added description for FATAL hook function --- API.markdown | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/API.markdown b/API.markdown index ecee9f3..d387947 100644 --- a/API.markdown +++ b/API.markdown @@ -19,7 +19,7 @@ Most of the API that you need for using g3log is described in this readme. For m * Fatal handling * [Linux/*nix](#fatal_handling_linux) * [Custom fatal handling](#fatal_custom_handling) - * [TOWRITE: Pre fatal hook](#fatal_pre_hook) + * [Pre fatal hook](#fatal_pre_hook) * [TOWRITE: Override of signal handling](#fatal_signalhandler_override) * [Disable fatal handling](#fatal_handling_disabled) * [PID1 Fatal Signal Recommendations](#PID1) @@ -299,7 +299,7 @@ The default behaviour for G3log is to catch several fatal events before they for ``` - ### TOWRITE: Custom fatal handling + ### Custom fatal handling By default the fatal signals are defined in [src/g3log.cpp](src/g3log.cpp) as ``` SIGABRT @@ -317,7 +317,13 @@ The default behaviour for G3log is to catch several fatal events before they for {SIGSEGV, "SIGSEGV"}}); ``` - ### TOWRITE: Pre fatal hook + ### Pre fatal hook + You can define a custom call back function that will be called before the fatal signal handling re-emits the `fatal` signal. See [src/g3log/g3log.hpp](src/g3log/g3log.hpp) for details. + ``` + // Example of how to enforce important shutdown cleanup even in the event of a fatal crash: + g3::setFatalPreLoggingHook([]{ cleanup(); }); + ``` + ### TOWRITE: Override of signal handling ### Disable fatal handling Fatal signal handling can be disabled with a CMake option: `ENABLE_FATAL_SIGNALHANDLING`. See [Options.cmake](https://github.com/KjellKod/g3log/blob/master/Options.cmake) for more details