<refentry id="glib-Message-Logging">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Message-Logging.top_of_page">Message Logging</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Message Logging</refname>
<refpurpose>versatile support for logging messages with different levels of importance</refpurpose>
</refnamediv>

<refsynopsisdiv id="glib-Message-Logging.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;glib.h&gt;

#define             <link linkend="G-LOG-DOMAIN--CAPS">G_LOG_DOMAIN</link>
#define             <link linkend="G-LOG-FATAL-MASK--CAPS">G_LOG_FATAL_MASK</link>
#define             <link linkend="G-LOG-LEVEL-USER-SHIFT--CAPS">G_LOG_LEVEL_USER_SHIFT</link>
<link linkend="void">void</link>                (<link linkend="GLogFunc">*GLogFunc</link>)                         (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *message,
                                                         <link linkend="gpointer">gpointer</link> user_data);
enum                <link linkend="GLogLevelFlags">GLogLevelFlags</link>;

<link linkend="void">void</link>                <link linkend="g-log">g_log</link>                               (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *format,
                                                         ...);
<link linkend="void">void</link>                <link linkend="g-logv">g_logv</link>                              (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *format,
                                                         <link linkend="va-list">va_list</link> args);
#define             <link linkend="g-message">g_message</link>                           (...)
#define             <link linkend="g-warning">g_warning</link>                           (...)
#define             <link linkend="g-critical">g_critical</link>                          (...)
#define             <link linkend="g-error">g_error</link>                             (...)
#define             <link linkend="g-debug">g_debug</link>                             (...)

<link linkend="guint">guint</link>               <link linkend="g-log-set-handler">g_log_set_handler</link>                   (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_levels,
                                                         <link linkend="GLogFunc">GLogFunc</link> log_func,
                                                         <link linkend="gpointer">gpointer</link> user_data);
<link linkend="void">void</link>                <link linkend="g-log-remove-handler">g_log_remove_handler</link>                (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="guint">guint</link> handler_id);
<link linkend="GLogLevelFlags">GLogLevelFlags</link>      <link linkend="g-log-set-always-fatal">g_log_set_always_fatal</link>              (<link linkend="GLogLevelFlags">GLogLevelFlags</link> fatal_mask);
<link linkend="GLogLevelFlags">GLogLevelFlags</link>      <link linkend="g-log-set-fatal-mask">g_log_set_fatal_mask</link>                (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> fatal_mask);
<link linkend="void">void</link>                <link linkend="g-log-default-handler">g_log_default_handler</link>               (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *message,
                                                         <link linkend="gpointer">gpointer</link> unused_data);
<link linkend="GLogFunc">GLogFunc</link>            <link linkend="g-log-set-default-handler">g_log_set_default_handler</link>           (<link linkend="GLogFunc">GLogFunc</link> log_func,
                                                         <link linkend="gpointer">gpointer</link> user_data);
</synopsis>
</refsynopsisdiv>









<refsect1 id="glib-Message-Logging.description" role="desc">
<title role="desc.title">Description</title>
<para>
These functions provide support for logging error messages or messages
used for debugging.
</para>
<para>
There are several built-in levels of messages, defined in <link linkend="GLogLevelFlags"><type>GLogLevelFlags</type></link>.
These can be extended with user-defined levels.
</para>
</refsect1>

<refsect1 id="glib-Message-Logging.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="G-LOG-DOMAIN--CAPS" role="macro">
<title>G_LOG_DOMAIN</title>
<indexterm zone="G-LOG-DOMAIN--CAPS"><primary sortas="LOG_DOMAIN">G_LOG_DOMAIN</primary></indexterm><programlisting>#define G_LOG_DOMAIN    ((gchar*) 0)
</programlisting>
<para>
Defines the log domain.
For applications, this is typically left as the default <link linkend="NULL--CAPS"><literal>NULL</literal></link> (or "") domain.
Libraries should define this so that any messages which they log can
be differentiated from messages from other libraries and application code.
But be careful not to define it in any public header files.
</para>
<para>
For example, GTK+ uses this in its Makefile.am:
</para>
<informalexample><programlisting>
INCLUDES = -DG_LOG_DOMAIN=\"Gtk\"
</programlisting></informalexample></refsect2>
<refsect2 id="G-LOG-FATAL-MASK--CAPS" role="macro">
<title>G_LOG_FATAL_MASK</title>
<indexterm zone="G-LOG-FATAL-MASK--CAPS"><primary sortas="LOG_FATAL_MASK">G_LOG_FATAL_MASK</primary></indexterm><programlisting>#define G_LOG_FATAL_MASK        (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
</programlisting>
<para>
GLib log levels that are considered fatal by default.
</para></refsect2>
<refsect2 id="G-LOG-LEVEL-USER-SHIFT--CAPS" role="macro">
<title>G_LOG_LEVEL_USER_SHIFT</title>
<indexterm zone="G-LOG-LEVEL-USER-SHIFT--CAPS"><primary sortas="LOG_LEVEL_USER_SHIFT">G_LOG_LEVEL_USER_SHIFT</primary></indexterm><programlisting>#define G_LOG_LEVEL_USER_SHIFT  (8)
</programlisting>
<para>
Log level shift offset for user defined log levels (0-7 are used by GLib).
</para></refsect2>
<refsect2 id="GLogFunc" role="function">
<title>GLogFunc ()</title>
<indexterm zone="GLogFunc"><primary sortas="LogFunc">GLogFunc</primary></indexterm><programlisting><link linkend="void">void</link>                (*GLogFunc)                         (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *message,
                                                         <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>
Specifies the prototype of log handler functions.
</para><variablelist role="params">
<varlistentry><term><parameter>log_domain</parameter>&#160;:</term>
<listitem><simpara>the log domain of the message.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>log_level</parameter>&#160;:</term>
<listitem><simpara>the log level of the message (including the fatal and recursion
flags).
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>message</parameter>&#160;:</term>
<listitem><simpara>the message to process.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>user data, set in <link linkend="g-log-set-handler"><function>g_log_set_handler()</function></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="GLogLevelFlags" role="enum">
<title>enum GLogLevelFlags</title>
<indexterm zone="GLogLevelFlags"><primary sortas="LogLevelFlags">GLogLevelFlags</primary></indexterm><programlisting>typedef enum
{
  /* log flags */
  G_LOG_FLAG_RECURSION          = 1 &lt;&lt; 0,
  G_LOG_FLAG_FATAL              = 1 &lt;&lt; 1,

  /* GLib log levels */
  G_LOG_LEVEL_ERROR             = 1 &lt;&lt; 2,       /* always fatal */
  G_LOG_LEVEL_CRITICAL          = 1 &lt;&lt; 3,
  G_LOG_LEVEL_WARNING           = 1 &lt;&lt; 4,
  G_LOG_LEVEL_MESSAGE           = 1 &lt;&lt; 5,
  G_LOG_LEVEL_INFO              = 1 &lt;&lt; 6,
  G_LOG_LEVEL_DEBUG             = 1 &lt;&lt; 7,

  G_LOG_LEVEL_MASK              = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
} GLogLevelFlags;
</programlisting>
<para>
Flags specifying the level of log messages. It is possible to change
how GLib treats messages of the various levels using <link linkend="g-log-set-handler"><function>g_log_set_handler()</function></link>
and <link linkend="g-log-set-fatal-mask"><function>g_log_set_fatal_mask()</function></link>.
</para><variablelist role="enum">
<varlistentry id="G-LOG-FLAG-RECURSION--CAPS" role="constant">
<term><literal>G_LOG_FLAG_RECURSION</literal></term>
<listitem><simpara>internal flag
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-FLAG-FATAL--CAPS" role="constant">
<term><literal>G_LOG_FLAG_FATAL</literal></term>
<listitem><simpara>internal flag
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-LEVEL-ERROR--CAPS" role="constant">
<term><literal>G_LOG_LEVEL_ERROR</literal></term>
<listitem><simpara>log level for errors, see <link linkend="g-error"><function>g_error()</function></link>. 
  This level is also used for messages produced by <link linkend="g-assert"><function>g_assert()</function></link>.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-LEVEL-CRITICAL--CAPS" role="constant">
<term><literal>G_LOG_LEVEL_CRITICAL</literal></term>
<listitem><simpara>log level for critical messages, see <link linkend="g-critical"><function>g_critical()</function></link>.
  This level is also used for messages produced by <link linkend="g-return-if-fail"><function>g_return_if_fail()</function></link> and
  <link linkend="g-return-val-if-fail"><function>g_return_val_if_fail()</function></link>.
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-LEVEL-WARNING--CAPS" role="constant">
<term><literal>G_LOG_LEVEL_WARNING</literal></term>
<listitem><simpara>log level for warnings, see <link linkend="g-warning"><function>g_warning()</function></link>
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-LEVEL-MESSAGE--CAPS" role="constant">
<term><literal>G_LOG_LEVEL_MESSAGE</literal></term>
<listitem><simpara>log level for messages, see <link linkend="g-message"><function>g_message()</function></link>
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-LEVEL-INFO--CAPS" role="constant">
<term><literal>G_LOG_LEVEL_INFO</literal></term>
<listitem><simpara>log level for informational messages
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-LEVEL-DEBUG--CAPS" role="constant">
<term><literal>G_LOG_LEVEL_DEBUG</literal></term>
<listitem><simpara>log level for debug messages, see <link linkend="g-debug"><function>g_debug()</function></link>
</simpara></listitem>
</varlistentry>
<varlistentry id="G-LOG-LEVEL-MASK--CAPS" role="constant">
<term><literal>G_LOG_LEVEL_MASK</literal></term>
<listitem><simpara>a mask including all log levels.
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="g-log" role="function">
<title>g_log ()</title>
<indexterm zone="g-log"><primary sortas="log">g_log</primary></indexterm><programlisting><link linkend="void">void</link>                g_log                               (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *format,
                                                         ...);</programlisting>
<para>
Logs an error or debugging message.
If the log level has been set as fatal, the <link linkend="abort"><function>abort()</function></link>
function is called to terminate the program.
</para><variablelist role="params">
<varlistentry><term><parameter>log_domain</parameter>&#160;:</term>
<listitem><simpara>the log domain, usually <link linkend="G-LOG-DOMAIN--CAPS"><type>G_LOG_DOMAIN</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>log_level</parameter>&#160;:</term>
<listitem><simpara>the log level, either from <link linkend="GLogLevelFlags"><type>GLogLevelFlags</type></link> or a user-defined level.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>format</parameter>&#160;:</term>
<listitem><simpara>the message format. See the <link linkend="printf"><function>printf()</function></link>
documentation.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>the parameters to insert into the format string.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-logv" role="function">
<title>g_logv ()</title>
<indexterm zone="g-logv"><primary sortas="logv">g_logv</primary></indexterm><programlisting><link linkend="void">void</link>                g_logv                              (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *format,
                                                         <link linkend="va-list">va_list</link> args);</programlisting>
<para>
Logs an error or debugging message.
If the log level has been set as fatal, the <link linkend="abort"><function>abort()</function></link>
function is called to terminate the program.
</para><variablelist role="params">
<varlistentry><term><parameter>log_domain</parameter>&#160;:</term>
<listitem><simpara>the log domain.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>log_level</parameter>&#160;:</term>
<listitem><simpara>the log level.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>format</parameter>&#160;:</term>
<listitem><simpara>the message format. See the <link linkend="printf"><function>printf()</function></link>
documentation.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>args</parameter>&#160;:</term>
<listitem><simpara>the parameters to insert into the format string.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-message" role="macro">
<title>g_message()</title>
<indexterm zone="g-message"><primary sortas="message">g_message</primary></indexterm><programlisting>#define             g_message(...)</programlisting>
<para>
A convenience function/macro to log a normal message.
</para><variablelist role="params">
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>format string, followed by parameters to insert into the format string (as with <link linkend="printf"><function>printf()</function></link>)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-warning" role="macro">
<title>g_warning()</title>
<indexterm zone="g-warning"><primary sortas="warning">g_warning</primary></indexterm><programlisting>#define             g_warning(...)</programlisting>
<para>
A convenience function/macro to log a warning message.
</para>
<para>
You can make warnings fatal at runtime by setting the <link linkend="G-DEBUG--CAPS"><literal>G_DEBUG</literal></link> environment
variable (see <ulink url="glib-running.html">Running GLib Applications</ulink>).
</para><variablelist role="params">
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>format string, followed by parameters to insert into the format string (as with <link linkend="printf"><function>printf()</function></link>)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-critical" role="macro">
<title>g_critical()</title>
<indexterm zone="g-critical"><primary sortas="critical">g_critical</primary></indexterm><programlisting>#define             g_critical(...)</programlisting>
<para>
Logs a "critical warning" (<link linkend="G-LOG-LEVEL-CRITICAL--CAPS"><type>G_LOG_LEVEL_CRITICAL</type></link>). It's more or less
application-defined what constitutes a critical vs. a regular
warning. You could call <link linkend="g-log-set-always-fatal"><function>g_log_set_always_fatal()</function></link> to make critical
warnings exit the program, then use <link linkend="g-critical"><function>g_critical()</function></link> for fatal errors, for
example.
</para>
<para>
You can also make critical warnings fatal at runtime by setting
the <link linkend="G-DEBUG--CAPS"><literal>G_DEBUG</literal></link> environment variable (see
<ulink url="glib-running.html">Running GLib Applications</ulink>).
</para><variablelist role="params">
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>format string, followed by parameters to insert into the format string (as with <link linkend="printf"><function>printf()</function></link>)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-error" role="macro">
<title>g_error()</title>
<indexterm zone="g-error"><primary sortas="error">g_error</primary></indexterm><programlisting>#define             g_error(...)</programlisting>
<para>
A convenience function/macro to log an error message.
Error messages are always fatal, resulting in a call to
<link linkend="abort"><function>abort()</function></link> to terminate the application.
This function will result in a core dump; don't use it for errors you
expect. Using this function indicates a bug in your program, i.e. an
assertion failure.
</para><variablelist role="params">
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>format string, followed by parameters to insert into the format string (as with <link linkend="printf"><function>printf()</function></link>)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-debug" role="macro" condition="since:2.6">
<title>g_debug()</title>
<indexterm zone="g-debug" role="2.6"><primary sortas="debug">g_debug</primary></indexterm><programlisting>#define             g_debug(...)</programlisting>
<para>
A convenience function/macro to log a debug message.
</para><variablelist role="params">
<varlistentry><term><parameter>...</parameter>&#160;:</term>
<listitem><simpara>format string, followed by parameters to insert into the format string (as with <link linkend="printf"><function>printf()</function></link>)
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>
<refsect2 id="g-log-set-handler" role="function">
<title>g_log_set_handler ()</title>
<indexterm zone="g-log-set-handler"><primary sortas="log_set_handler">g_log_set_handler</primary></indexterm><programlisting><link linkend="guint">guint</link>               g_log_set_handler                   (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_levels,
                                                         <link linkend="GLogFunc">GLogFunc</link> log_func,
                                                         <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>
Sets the log handler for a domain and a set of log levels.
To handle fatal and recursive messages the <parameter>log_levels</parameter> parameter
must be combined with the <link linkend="G-LOG-FLAG-FATAL--CAPS"><type>G_LOG_FLAG_FATAL</type></link> and <link linkend="G-LOG-FLAG-RECURSION--CAPS"><type>G_LOG_FLAG_RECURSION</type></link>
bit flags.
</para>
<para>
Note that since the <link linkend="G-LOG-LEVEL-ERROR--CAPS"><type>G_LOG_LEVEL_ERROR</type></link> log level is always fatal, if
you want to set a handler for this log level you must combine it with
<link linkend="G-LOG-FLAG-FATAL--CAPS"><type>G_LOG_FLAG_FATAL</type></link>.
</para>
<example>
<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);
</programlisting>
</example>
<example>
<title>Adding a log handler for all critical messages from GTK+</title>
<programlisting>
  g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
                     | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
</programlisting>
</example>
<example>
<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);
</programlisting>
</example><variablelist role="params">
<varlistentry><term><parameter>log_domain</parameter>&#160;:</term>
<listitem><simpara>the log domain, or <link linkend="NULL--CAPS"><literal>NULL</literal></link> for the default "" application domain.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>log_levels</parameter>&#160;:</term>
<listitem><simpara>the log levels to apply the log handler for. To handle fatal
and recursive messages as well, combine the log levels with the
<link linkend="G-LOG-FLAG-FATAL--CAPS"><type>G_LOG_FLAG_FATAL</type></link> and <link linkend="G-LOG-FLAG-RECURSION--CAPS"><type>G_LOG_FLAG_RECURSION</type></link> bit flags.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>log_func</parameter>&#160;:</term>
<listitem><simpara>the log handler function.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>data passed to the log handler.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>the id of the new handler.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-log-remove-handler" role="function">
<title>g_log_remove_handler ()</title>
<indexterm zone="g-log-remove-handler"><primary sortas="log_remove_handler">g_log_remove_handler</primary></indexterm><programlisting><link linkend="void">void</link>                g_log_remove_handler                (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="guint">guint</link> handler_id);</programlisting>
<para>
Removes the log handler.
</para><variablelist role="params">
<varlistentry><term><parameter>log_domain</parameter>&#160;:</term>
<listitem><simpara>the log domain.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>handler_id</parameter>&#160;:</term>
<listitem><simpara>the id of the handler, which was returned in <link linkend="g-log-set-handler"><function>g_log_set_handler()</function></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-log-set-always-fatal" role="function">
<title>g_log_set_always_fatal ()</title>
<indexterm zone="g-log-set-always-fatal"><primary sortas="log_set_always_fatal">g_log_set_always_fatal</primary></indexterm><programlisting><link linkend="GLogLevelFlags">GLogLevelFlags</link>      g_log_set_always_fatal              (<link linkend="GLogLevelFlags">GLogLevelFlags</link> fatal_mask);</programlisting>
<para>
Sets the message levels which are always fatal, in any log domain.
When a message with any of these levels is logged the program terminates.
You can only set the levels defined by GLib to be fatal.
<link linkend="G-LOG-LEVEL-ERROR--CAPS"><literal>G_LOG_LEVEL_ERROR</literal></link> is always fatal.
</para>
<para>
You can also make some message levels
fatal at runtime by setting the <link linkend="G-DEBUG--CAPS"><literal>G_DEBUG</literal></link> environment variable (see
<ulink url="glib-running.html">Running GLib Applications</ulink>).
</para><variablelist role="params">
<varlistentry><term><parameter>fatal_mask</parameter>&#160;:</term>
<listitem><simpara>the mask containing bits set for each level of error which is
to be fatal.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>the old fatal mask.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-log-set-fatal-mask" role="function">
<title>g_log_set_fatal_mask ()</title>
<indexterm zone="g-log-set-fatal-mask"><primary sortas="log_set_fatal_mask">g_log_set_fatal_mask</primary></indexterm><programlisting><link linkend="GLogLevelFlags">GLogLevelFlags</link>      g_log_set_fatal_mask                (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> fatal_mask);</programlisting>
<para>
Sets the log levels which are fatal in the given domain.
<link linkend="G-LOG-LEVEL-ERROR--CAPS"><literal>G_LOG_LEVEL_ERROR</literal></link> is always fatal.
</para><variablelist role="params">
<varlistentry><term><parameter>log_domain</parameter>&#160;:</term>
<listitem><simpara>the log domain.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fatal_mask</parameter>&#160;:</term>
<listitem><simpara>the new fatal mask.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>the old fatal mask for the log domain.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-log-default-handler" role="function">
<title>g_log_default_handler ()</title>
<indexterm zone="g-log-default-handler"><primary sortas="log_default_handler">g_log_default_handler</primary></indexterm><programlisting><link linkend="void">void</link>                g_log_default_handler               (const <link linkend="gchar">gchar</link> *log_domain,
                                                         <link linkend="GLogLevelFlags">GLogLevelFlags</link> log_level,
                                                         const <link linkend="gchar">gchar</link> *message,
                                                         <link linkend="gpointer">gpointer</link> unused_data);</programlisting>
<para>
The default log handler set up by GLib; <link linkend="g-log-set-default-handler"><function>g_log_set_default_handler()</function></link>
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 <link linkend="abort"><function>abort()</function></link>.
</para>
<para>
stderr is used for levels <link linkend="G-LOG-LEVEL-ERROR--CAPS"><literal>G_LOG_LEVEL_ERROR</literal></link>, <link linkend="G-LOG-LEVEL-CRITICAL--CAPS"><literal>G_LOG_LEVEL_CRITICAL</literal></link>,
<link linkend="G-LOG-LEVEL-WARNING--CAPS"><literal>G_LOG_LEVEL_WARNING</literal></link> and <link linkend="G-LOG-LEVEL-MESSAGE--CAPS"><literal>G_LOG_LEVEL_MESSAGE</literal></link>. stdout is used for the rest.
</para><variablelist role="params">
<varlistentry><term><parameter>log_domain</parameter>&#160;:</term>
<listitem><simpara>the log domain of the message.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>log_level</parameter>&#160;:</term>
<listitem><simpara>the level of the message.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>message</parameter>&#160;:</term>
<listitem><simpara>the message.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>unused_data</parameter>&#160;:</term>
<listitem><simpara>data passed from <link linkend="g-log"><function>g_log()</function></link> which is unused.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-log-set-default-handler" role="function" condition="since:2.6">
<title>g_log_set_default_handler ()</title>
<indexterm zone="g-log-set-default-handler" role="2.6"><primary sortas="log_set_default_handler">g_log_set_default_handler</primary></indexterm><programlisting><link linkend="GLogFunc">GLogFunc</link>            g_log_set_default_handler           (<link linkend="GLogFunc">GLogFunc</link> log_func,
                                                         <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>
Installs a default log handler which is used if no
log handler has been set for the particular log domain
and log level combination. By default, GLib uses
<link linkend="g-log-default-handler"><function>g_log_default_handler()</function></link> as default log handler.
</para><variablelist role="params">
<varlistentry><term><parameter>log_func</parameter>&#160;:</term>
<listitem><simpara>the log handler function.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>data passed to the log handler.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>the previous default log handler
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.6</para></refsect2>

</refsect1>




</refentry>
