+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.
+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.
+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.
+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.
+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.
+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.
g_log_set_always_fatal
g_log_set_fatal_mask
g_log_default_handler
+g_log_set_default_handler
</SECTION>
<SECTION>
<!-- ##### 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>
<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);
</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);
<!-- ##### 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>.
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
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
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
handler = handler->next;
}
}
- return g_log_default_handler;
+
+ *data = default_log_data;
+ return default_log_func;
}
GLogLevelFlags
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)
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,