Function

GLibtest_log_set_fatal_handler

since: 2.22

Declaration

void
g_test_log_set_fatal_handler (
  GTestLogFatalFunc log_func,
  gpointer user_data
)

Description

Installs a non-error fatal log handler which can be used to decide whether log messages which are counted as fatal abort the program.

The use case here is that you are running a test case that depends on particular libraries or circumstances and cannot prevent certain known critical or warning messages. So you install a handler that compares the domain and message to precisely not abort in such a case.

Note that the handler is reset at the beginning of any test case, so you have to set it inside each test function which needs the special behavior.

This handler has no effect on g_error messages.

This handler also has no effect on structured log messages (using g_log_structured() or g_log_structured_array()). To change the fatal behaviour for specific log messages, programs must install a custom log writer function using g_log_set_writer_func().See Using Structured Logging.

Available since: 2.22

This function is not directly available to language bindings.

Parameters

log_func

Type: GTestLogFatalFunc

The log handler function.

user_data

Type: gpointer

Data passed to the log handler.

The argument can be NULL.
The data is owned by the caller of the function.