mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-02 07:36:17 +01:00
New function to install an alternate default log handler. (#66387, Darin
Sun Sep 5 01:46:11 2004 Matthias Clasen <maclas@gmx.de> * glib/glib.def: * glib/gmessages.h: * glib/gmessages.c (g_log_set_default_handler): New function to install an alternate default log handler. (#66387, Darin Adler)
This commit is contained in:
parent
1df50a9841
commit
4dcb22c14a
@ -1,3 +1,11 @@
|
||||
Sun Sep 5 01:46:11 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib.def:
|
||||
* glib/gmessages.h:
|
||||
* glib/gmessages.c (g_log_set_default_handler): New
|
||||
function to install an alternate default log
|
||||
handler. (#66387, Darin Adler)
|
||||
|
||||
2004-09-03 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/glib.def: Update.
|
||||
|
@ -1,3 +1,11 @@
|
||||
Sun Sep 5 01:46:11 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib.def:
|
||||
* glib/gmessages.h:
|
||||
* glib/gmessages.c (g_log_set_default_handler): New
|
||||
function to install an alternate default log
|
||||
handler. (#66387, Darin Adler)
|
||||
|
||||
2004-09-03 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/glib.def: Update.
|
||||
|
@ -1,3 +1,11 @@
|
||||
Sun Sep 5 01:46:11 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib.def:
|
||||
* glib/gmessages.h:
|
||||
* glib/gmessages.c (g_log_set_default_handler): New
|
||||
function to install an alternate default log
|
||||
handler. (#66387, Darin Adler)
|
||||
|
||||
2004-09-03 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/glib.def: Update.
|
||||
|
@ -1,3 +1,11 @@
|
||||
Sun Sep 5 01:46:11 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib.def:
|
||||
* glib/gmessages.h:
|
||||
* glib/gmessages.c (g_log_set_default_handler): New
|
||||
function to install an alternate default log
|
||||
handler. (#66387, Darin Adler)
|
||||
|
||||
2004-09-03 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/glib.def: Update.
|
||||
|
@ -1,3 +1,11 @@
|
||||
Sun Sep 5 01:46:11 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib.def:
|
||||
* glib/gmessages.h:
|
||||
* glib/gmessages.c (g_log_set_default_handler): New
|
||||
function to install an alternate default log
|
||||
handler. (#66387, Darin Adler)
|
||||
|
||||
2004-09-03 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* glib/glib.def: Update.
|
||||
|
@ -1,3 +1,8 @@
|
||||
Sun Sep 5 01:44:23 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib-sections.txt:
|
||||
* glib/tmpl/messages.sgml: Document g_log_set_default_handler().
|
||||
|
||||
Wed Sep 1 20:27:59 2004 Matthias Clasen <maclas@gmx.de>
|
||||
|
||||
* glib/glib-sections.txt: Add g_date_get_iso8601_week_of_year.
|
||||
|
@ -853,6 +853,7 @@ g_log_remove_handler
|
||||
g_log_set_always_fatal
|
||||
g_log_set_fatal_mask
|
||||
g_log_default_handler
|
||||
g_log_set_default_handler
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -6,7 +6,8 @@ versatile support for logging messages with different levels of importance.
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
These functions provide support for logging error messages or messages used for debugging.
|
||||
These functions provide support for logging error messages or messages
|
||||
used for debugging.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -159,15 +160,18 @@ A convenience function/macro to log a debug message.
|
||||
<para>
|
||||
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.
|
||||
must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
|
||||
bit flags.
|
||||
</para>
|
||||
<para>
|
||||
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.
|
||||
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.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Adding a log handler for all warning messages in the default (application) domain</title>
|
||||
<title>Adding a log handler for all warning messages in the default
|
||||
(application) domain</title>
|
||||
<programlisting>
|
||||
g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
|
||||
| G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
||||
@ -183,7 +187,8 @@ to set a handler for this log level you must combine it with #G_LOG_FLAG_FATAL.
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Adding a log handler for <emphasis>all</emphasis> messages from GLib</title>
|
||||
<title>Adding a log handler for <emphasis>all</emphasis> messages from
|
||||
GLib</title>
|
||||
<programlisting>
|
||||
g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
|
||||
| G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
||||
@ -234,7 +239,8 @@ Sets the log levels which are fatal in the given domain.
|
||||
|
||||
<!-- ##### FUNCTION g_log_default_handler ##### -->
|
||||
<para>
|
||||
The default log handler.
|
||||
The default log handler set up by GLib; g_log_set_default_handler()
|
||||
allows to install an alternate default log handler.
|
||||
This is used if no log handler has been set for the particular log domain
|
||||
and log level combination. It outputs the message to stderr or stdout
|
||||
and if the log level is fatal it calls <function>abort()</function>.
|
||||
@ -243,10 +249,22 @@ and if the log level is fatal it calls <function>abort()</function>.
|
||||
stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL, and
|
||||
%G_LOG_LEVEL_WARNING. stdout is used for the rest.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
@log_domain: the log domain of the message.
|
||||
@log_level: the level of the message.
|
||||
@message: the message.
|
||||
@unused_data: data passed from g_log() which is unused.
|
||||
|
||||
<!-- ##### FUNCTION g_log_set_default_handler ##### -->
|
||||
<para>
|
||||
Installs a default log handler which is used is used if no
|
||||
log handler has been set for the particular log domain
|
||||
and log level combination. By default, GLib uses
|
||||
g_log_default_handler() as default log handler.
|
||||
</para>
|
||||
|
||||
@log_func: the log handler function.
|
||||
@user_data: data passed to the log handler.
|
||||
@Returns: the previous default log handler
|
||||
@Since: 2.6
|
||||
|
@ -317,6 +317,7 @@ EXPORTS
|
||||
g_log_default_handler
|
||||
g_log_remove_handler
|
||||
g_log_set_always_fatal
|
||||
g_log_set_default_handler
|
||||
g_log_set_fatal_mask
|
||||
g_log_set_handler
|
||||
g_logv
|
||||
|
@ -81,7 +81,8 @@ static GPrintFunc glib_print_func = NULL;
|
||||
static GPrintFunc glib_printerr_func = NULL;
|
||||
static GPrivate *g_log_depth = NULL;
|
||||
static GLogLevelFlags g_log_msg_prefix = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_DEBUG;
|
||||
|
||||
static GLogFunc default_log_func = g_log_default_handler;
|
||||
static gpointer default_log_data = NULL;
|
||||
|
||||
/* --- functions --- */
|
||||
#ifdef G_OS_WIN32
|
||||
@ -284,7 +285,9 @@ g_log_domain_get_handler_L (GLogDomain *domain,
|
||||
handler = handler->next;
|
||||
}
|
||||
}
|
||||
return g_log_default_handler;
|
||||
|
||||
*data = default_log_data;
|
||||
return default_log_func;
|
||||
}
|
||||
|
||||
GLogLevelFlags
|
||||
@ -375,6 +378,21 @@ g_log_set_handler (const gchar *log_domain,
|
||||
return handler_id;
|
||||
}
|
||||
|
||||
GLogFunc
|
||||
g_log_set_default_handler (GLogFunc log_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GLogFunc old_log_func;
|
||||
|
||||
g_mutex_lock (g_messages_lock);
|
||||
old_log_func = default_log_func;
|
||||
default_log_func = log_func;
|
||||
default_log_data = user_data;
|
||||
g_mutex_unlock (g_messages_lock);
|
||||
|
||||
return old_log_func;
|
||||
}
|
||||
|
||||
void
|
||||
g_log_remove_handler (const gchar *log_domain,
|
||||
guint handler_id)
|
||||
|
@ -88,6 +88,8 @@ void g_log_default_handler (const gchar *log_domain,
|
||||
GLogLevelFlags log_level,
|
||||
const gchar *message,
|
||||
gpointer unused_data);
|
||||
GLogFunc g_log_set_default_handler (GLogFunc log_func,
|
||||
gpointer user_data);
|
||||
void g_log (const gchar *log_domain,
|
||||
GLogLevelFlags log_level,
|
||||
const gchar *format,
|
||||
|
Loading…
Reference in New Issue
Block a user