Function
GLiblog_set_handler
Declaration [src]
guint
g_log_set_handler(
constgchar*log_domain,
GLogLevelFlagslog_levels,
GLogFunclog_func,
gpointeruser_data
)
Description [src]
Sets the log handler for a domain and a set of log levels.
To handle fatal and recursive messages the log_levels parameter
must be combined with the G_LOG_FLAG_FATAL and G_LOG_FLAG_RECURSION
bit flags.
Note that since the G_LOG_LEVEL_ERROR log level is always fatal, if
you want to set a handler for this log level you must combine it with
G_LOG_FLAG_FATAL.
This has no effect if structured logging is enabled; see Using Structured Logging.
The log_domain parameter can be set to NULL or an empty string to use the default
application domain.
Here is an example for adding a log handler for all warning messages in the default domain:
g_log_set_handler(NULL,G_LOG_LEVEL_WARNING|G_LOG_FLAG_FATAL
|G_LOG_FLAG_RECURSION,my_log_handler,NULL);
This example adds a log handler for all critical messages from GTK:
g_log_set_handler("Gtk",G_LOG_LEVEL_CRITICAL|G_LOG_FLAG_FATAL
|G_LOG_FLAG_RECURSION,my_log_handler,NULL);
This example adds a log handler for all messages from GLib:
g_log_set_handler("GLib",G_LOG_LEVEL_MASK|G_LOG_FLAG_FATAL
|G_LOG_FLAG_RECURSION,my_log_handler,NULL);
This function is not directly available to language bindings.
The implementation of this function is provided by g_log_set_handler_full() in language bindings.
Parameters
log_domain-
Type:
const gchar*The log domain application domain.
The argument can beNULL.The data is owned by the caller of the function.The value is a NUL terminated UTF-8 string. log_levels-
Type:
GLogLevelFlagsThe log levels to apply the log handler for. To handle fatal and recursive messages as well, combine the log levels with the
G_LOG_FLAG_FATALandG_LOG_FLAG_RECURSIONbit flags. log_func-
Type:
GLogFuncThe log handler function.
user_data-
Type:
gpointerData passed to the log handler.
The argument can beNULL.The data is owned by the caller of the function.
Return value
Type: guint
The id of the new handler.