mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 21:33:09 +02:00
Add g_log_set_handler_full
This is a bindable version of g_log_set_handler that takes a destroy notify for the user_data. https://bugzilla.gnome.org/show_bug.cgi?id=740516
This commit is contained in:
parent
1102e6f9ca
commit
2471d9cf86
@ -1142,6 +1142,7 @@ g_debug
|
|||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
g_log_set_handler
|
g_log_set_handler
|
||||||
|
g_log_set_handler_full
|
||||||
g_log_remove_handler
|
g_log_remove_handler
|
||||||
g_log_set_always_fatal
|
g_log_set_always_fatal
|
||||||
g_log_set_fatal_mask
|
g_log_set_fatal_mask
|
||||||
|
@ -279,6 +279,7 @@ struct _GLogHandler
|
|||||||
GLogLevelFlags log_level;
|
GLogLevelFlags log_level;
|
||||||
GLogFunc log_func;
|
GLogFunc log_func;
|
||||||
gpointer data;
|
gpointer data;
|
||||||
|
GDestroyNotify destroy;
|
||||||
GLogHandler *next;
|
GLogHandler *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -566,9 +567,37 @@ g_log_set_fatal_mask (const gchar *log_domain,
|
|||||||
*/
|
*/
|
||||||
guint
|
guint
|
||||||
g_log_set_handler (const gchar *log_domain,
|
g_log_set_handler (const gchar *log_domain,
|
||||||
GLogLevelFlags log_levels,
|
GLogLevelFlags log_levels,
|
||||||
GLogFunc log_func,
|
GLogFunc log_func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
return g_log_set_handler_full (log_domain, log_levels, log_func, user_data, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_log_set_handler_full: (rename-to g_log_set_handler)
|
||||||
|
* @log_domain: (allow-none): the log domain, or %NULL for the default ""
|
||||||
|
* application domain
|
||||||
|
* @log_levels: the 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_FATAL and
|
||||||
|
* #G_LOG_FLAG_RECURSION bit flags.
|
||||||
|
* @log_func: the log handler function
|
||||||
|
* @user_data: data passed to the log handler
|
||||||
|
* @destroy: destroy notify for @user_data, or %NULL
|
||||||
|
*
|
||||||
|
* Like g_log_sets_handler(), but takes a destroy notify for the @user_data.
|
||||||
|
*
|
||||||
|
* Returns: the id of the new handler
|
||||||
|
*
|
||||||
|
* Since: 2.44
|
||||||
|
*/
|
||||||
|
guint
|
||||||
|
g_log_set_handler_full (const gchar *log_domain,
|
||||||
|
GLogLevelFlags log_levels,
|
||||||
|
GLogFunc log_func,
|
||||||
|
gpointer user_data,
|
||||||
|
GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
static guint handler_id = 0;
|
static guint handler_id = 0;
|
||||||
GLogDomain *domain;
|
GLogDomain *domain;
|
||||||
@ -592,6 +621,7 @@ g_log_set_handler (const gchar *log_domain,
|
|||||||
handler->log_level = log_levels;
|
handler->log_level = log_levels;
|
||||||
handler->log_func = log_func;
|
handler->log_func = log_func;
|
||||||
handler->data = user_data;
|
handler->data = user_data;
|
||||||
|
handler->destroy = destroy;
|
||||||
handler->next = domain->handlers;
|
handler->next = domain->handlers;
|
||||||
domain->handlers = handler;
|
domain->handlers = handler;
|
||||||
|
|
||||||
@ -699,6 +729,8 @@ g_log_remove_handler (const gchar *log_domain,
|
|||||||
domain->handlers = work->next;
|
domain->handlers = work->next;
|
||||||
g_log_domain_check_free_L (domain);
|
g_log_domain_check_free_L (domain);
|
||||||
g_mutex_unlock (&g_messages_lock);
|
g_mutex_unlock (&g_messages_lock);
|
||||||
|
if (work->destroy)
|
||||||
|
work->destroy (work->data);
|
||||||
g_free (work);
|
g_free (work);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,12 @@ guint g_log_set_handler (const gchar *log_domain,
|
|||||||
GLogLevelFlags log_levels,
|
GLogLevelFlags log_levels,
|
||||||
GLogFunc log_func,
|
GLogFunc log_func,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
GLIB_AVAILABLE_IN_2_44
|
||||||
|
guint g_log_set_handler_full (const gchar *log_domain,
|
||||||
|
GLogLevelFlags log_levels,
|
||||||
|
GLogFunc log_func,
|
||||||
|
gpointer user_data,
|
||||||
|
GDestroyNotify destroy);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
void g_log_remove_handler (const gchar *log_domain,
|
void g_log_remove_handler (const gchar *log_domain,
|
||||||
guint handler_id);
|
guint handler_id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user