Tizen 2.1 base
[platform/upstream/glib2.0.git] / docs / reference / glib / html / glib-Message-Logging.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Message Logging</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-core.html" title="GLib Core Application Support">
9 <link rel="prev" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions">
10 <link rel="next" href="glib-utilities.html" title="GLib Utilities">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
16 <tr valign="middle">
17 <td><a accesskey="p" href="glib-Warnings-and-Assertions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GLib Reference Manual</th>
21 <td><a accesskey="n" href="glib-utilities.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 </tr>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#glib-Message-Logging.synopsis" class="shortcut">Top</a>
25                    | 
26                   <a href="#glib-Message-Logging.description" class="shortcut">Description</a>
27 </td></tr>
28 </table>
29 <div class="refentry">
30 <a name="glib-Message-Logging"></a><div class="titlepage"></div>
31 <div class="refnamediv"><table width="100%"><tr>
32 <td valign="top">
33 <h2><span class="refentrytitle"><a name="glib-Message-Logging.top_of_page"></a>Message Logging</span></h2>
34 <p>Message Logging — versatile support for logging messages
35     with different levels of importance</p>
36 </td>
37 <td valign="top" align="right"></td>
38 </tr></table></div>
39 <div class="refsynopsisdiv">
40 <a name="glib-Message-Logging.synopsis"></a><h2>Synopsis</h2>
41 <pre class="synopsis">
42 #include &lt;glib.h&gt;
43
44 #define             <a class="link" href="glib-Message-Logging.html#G-LOG-DOMAIN:CAPS" title="G_LOG_DOMAIN">G_LOG_DOMAIN</a>
45 #define             <a class="link" href="glib-Message-Logging.html#G-LOG-FATAL-MASK:CAPS" title="G_LOG_FATAL_MASK">G_LOG_FATAL_MASK</a>
46 #define             <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-USER-SHIFT:CAPS" title="G_LOG_LEVEL_USER_SHIFT">G_LOG_LEVEL_USER_SHIFT</a>
47 <span class="returnvalue">void</span>                (<a class="link" href="glib-Message-Logging.html#GLogFunc" title="GLogFunc ()">*GLogFunc</a>)                         (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
48                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
49                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *message</code></em>,
50                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
51 enum                <a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags">GLogLevelFlags</a>;
52
53 <span class="returnvalue">void</span>                <a class="link" href="glib-Message-Logging.html#g-log" title="g_log ()">g_log</a>                               (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
54                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
55                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *format</code></em>,
56                                                          <em class="parameter"><code>...</code></em>);
57 <span class="returnvalue">void</span>                <a class="link" href="glib-Message-Logging.html#g-logv" title="g_logv ()">g_logv</a>                              (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
58                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
59                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *format</code></em>,
60                                                          <em class="parameter"><code><span class="type">va_list</span> args</code></em>);
61 #define             <a class="link" href="glib-Message-Logging.html#g-message" title="g_message()">g_message</a>                           (...)
62 #define             <a class="link" href="glib-Message-Logging.html#g-warning" title="g_warning()">g_warning</a>                           (...)
63 #define             <a class="link" href="glib-Message-Logging.html#g-critical" title="g_critical()">g_critical</a>                          (...)
64 #define             <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()">g_error</a>                             (...)
65 #define             <a class="link" href="glib-Message-Logging.html#g-debug" title="g_debug()">g_debug</a>                             (...)
66
67 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-Message-Logging.html#g-log-set-handler" title="g_log_set_handler ()">g_log_set_handler</a>                   (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
68                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_levels</code></em>,
69                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogFunc" title="GLogFunc ()"><span class="type">GLogFunc</span></a> log_func</code></em>,
70                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
71 <span class="returnvalue">void</span>                <a class="link" href="glib-Message-Logging.html#g-log-remove-handler" title="g_log_remove_handler ()">g_log_remove_handler</a>                (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
72                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> handler_id</code></em>);
73 <a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="returnvalue">GLogLevelFlags</span></a>      <a class="link" href="glib-Message-Logging.html#g-log-set-always-fatal" title="g_log_set_always_fatal ()">g_log_set_always_fatal</a>              (<em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> fatal_mask</code></em>);
74 <a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="returnvalue">GLogLevelFlags</span></a>      <a class="link" href="glib-Message-Logging.html#g-log-set-fatal-mask" title="g_log_set_fatal_mask ()">g_log_set_fatal_mask</a>                (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
75                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> fatal_mask</code></em>);
76 <span class="returnvalue">void</span>                <a class="link" href="glib-Message-Logging.html#g-log-default-handler" title="g_log_default_handler ()">g_log_default_handler</a>               (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
77                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
78                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *message</code></em>,
79                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> unused_data</code></em>);
80 <a class="link" href="glib-Message-Logging.html#GLogFunc" title="GLogFunc ()"><span class="returnvalue">GLogFunc</span></a>            <a class="link" href="glib-Message-Logging.html#g-log-set-default-handler" title="g_log_set_default_handler ()">g_log_set_default_handler</a>           (<em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogFunc" title="GLogFunc ()"><span class="type">GLogFunc</span></a> log_func</code></em>,
81                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
82 </pre>
83 </div>
84 <div class="refsect1">
85 <a name="glib-Message-Logging.description"></a><h2>Description</h2>
86 <p>
87 These functions provide support for logging error messages
88 or messages used for debugging.
89 </p>
90 <p>
91 There are several built-in levels of messages, defined in
92 <a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a>. These can be extended with user-defined levels.
93 </p>
94 </div>
95 <div class="refsect1">
96 <a name="glib-Message-Logging.details"></a><h2>Details</h2>
97 <div class="refsect2">
98 <a name="G-LOG-DOMAIN:CAPS"></a><h3>G_LOG_DOMAIN</h3>
99 <pre class="programlisting">#define G_LOG_DOMAIN    ((gchar*) 0)
100 </pre>
101 <p>
102 Defines the log domain.
103 </p>
104 <p>
105 For applications, this is typically left as the default <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>
106 (or "") domain. Libraries should define this so that any messages
107 which they log can be differentiated from messages from other
108 libraries and application code. But be careful not to define
109 it in any public header files.
110 </p>
111 <p>
112 For example, GTK+ uses this in its Makefile.am:
113 </p>
114 <div class="informalexample">
115   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
116     <tbody>
117       <tr>
118         <td class="listing_lines" align="right"><pre>1</pre></td>
119         <td class="listing_code"><pre class="programlisting"><span class="normal">INCLUDES </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">-</span><span class="normal">DG_LOG_DOMAIN</span><span class="symbol">=\</span><span class="string">"Gtk</span><span class="specialchar">\"</span></pre></td>
120       </tr>
121     </tbody>
122   </table>
123 </div>
124
125 <p>
126 </p>
127 </div>
128 <hr>
129 <div class="refsect2">
130 <a name="G-LOG-FATAL-MASK:CAPS"></a><h3>G_LOG_FATAL_MASK</h3>
131 <pre class="programlisting">#define G_LOG_FATAL_MASK        (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
132 </pre>
133 <p>
134 GLib log levels that are considered fatal by default.
135 </p>
136 </div>
137 <hr>
138 <div class="refsect2">
139 <a name="G-LOG-LEVEL-USER-SHIFT:CAPS"></a><h3>G_LOG_LEVEL_USER_SHIFT</h3>
140 <pre class="programlisting">#define G_LOG_LEVEL_USER_SHIFT  (8)
141 </pre>
142 </div>
143 <hr>
144 <div class="refsect2">
145 <a name="GLogFunc"></a><h3>GLogFunc ()</h3>
146 <pre class="programlisting"><span class="returnvalue">void</span>                (*GLogFunc)                         (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
147                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
148                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *message</code></em>,
149                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
150 <p>
151 Specifies the prototype of log handler functions.
152 </p>
153 <div class="variablelist"><table border="0">
154 <col align="left" valign="top">
155 <tbody>
156 <tr>
157 <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
158 <td>the log domain of the message</td>
159 </tr>
160 <tr>
161 <td><p><span class="term"><em class="parameter"><code>log_level</code></em> :</span></p></td>
162 <td>the log level of the message (including the
163 fatal and recursion flags)</td>
164 </tr>
165 <tr>
166 <td><p><span class="term"><em class="parameter"><code>message</code></em> :</span></p></td>
167 <td>the message to process</td>
168 </tr>
169 <tr>
170 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
171 <td>user data, set in <a class="link" href="glib-Message-Logging.html#g-log-set-handler" title="g_log_set_handler ()"><code class="function">g_log_set_handler()</code></a>
172 </td>
173 </tr>
174 </tbody>
175 </table></div>
176 </div>
177 <hr>
178 <div class="refsect2">
179 <a name="GLogLevelFlags"></a><h3>enum GLogLevelFlags</h3>
180 <pre class="programlisting">typedef enum {
181   /* log flags */
182   G_LOG_FLAG_RECURSION          = 1 &lt;&lt; 0,
183   G_LOG_FLAG_FATAL              = 1 &lt;&lt; 1,
184
185   /* GLib log levels */
186   G_LOG_LEVEL_ERROR             = 1 &lt;&lt; 2,       /* always fatal */
187   G_LOG_LEVEL_CRITICAL          = 1 &lt;&lt; 3,
188   G_LOG_LEVEL_WARNING           = 1 &lt;&lt; 4,
189   G_LOG_LEVEL_MESSAGE           = 1 &lt;&lt; 5,
190   G_LOG_LEVEL_INFO              = 1 &lt;&lt; 6,
191   G_LOG_LEVEL_DEBUG             = 1 &lt;&lt; 7,
192
193   G_LOG_LEVEL_MASK              = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
194 } GLogLevelFlags;
195 </pre>
196 <p>
197 Flags specifying the level of log messages.
198 </p>
199 <p>
200 It is possible to change how GLib treats messages of the various
201 levels using <a class="link" href="glib-Message-Logging.html#g-log-set-handler" title="g_log_set_handler ()"><code class="function">g_log_set_handler()</code></a> and <a class="link" href="glib-Message-Logging.html#g-log-set-fatal-mask" title="g_log_set_fatal_mask ()"><code class="function">g_log_set_fatal_mask()</code></a>.
202 </p>
203 <div class="variablelist"><table border="0">
204 <col align="left" valign="top">
205 <tbody>
206 <tr>
207 <td><p><a name="G-LOG-FLAG-RECURSION:CAPS"></a><span class="term"><code class="literal">G_LOG_FLAG_RECURSION</code></span></p></td>
208 <td>internal flag
209 </td>
210 </tr>
211 <tr>
212 <td><p><a name="G-LOG-FLAG-FATAL:CAPS"></a><span class="term"><code class="literal">G_LOG_FLAG_FATAL</code></span></p></td>
213 <td>internal flag
214 </td>
215 </tr>
216 <tr>
217 <td><p><a name="G-LOG-LEVEL-ERROR:CAPS"></a><span class="term"><code class="literal">G_LOG_LEVEL_ERROR</code></span></p></td>
218 <td>log level for errors, see <a class="link" href="glib-Message-Logging.html#g-error" title="g_error()"><code class="function">g_error()</code></a>.
219     This level is also used for messages produced by <a class="link" href="glib-Testing.html#g-assert" title="g_assert()"><code class="function">g_assert()</code></a>.
220 </td>
221 </tr>
222 <tr>
223 <td><p><a name="G-LOG-LEVEL-CRITICAL:CAPS"></a><span class="term"><code class="literal">G_LOG_LEVEL_CRITICAL</code></span></p></td>
224 <td>log level for critical messages, see <a class="link" href="glib-Message-Logging.html#g-critical" title="g_critical()"><code class="function">g_critical()</code></a>.
225     This level is also used for messages produced by <a class="link" href="glib-Warnings-and-Assertions.html#g-return-if-fail" title="g_return_if_fail()"><code class="function">g_return_if_fail()</code></a>
226     and <a class="link" href="glib-Warnings-and-Assertions.html#g-return-val-if-fail" title="g_return_val_if_fail()"><code class="function">g_return_val_if_fail()</code></a>.
227 </td>
228 </tr>
229 <tr>
230 <td><p><a name="G-LOG-LEVEL-WARNING:CAPS"></a><span class="term"><code class="literal">G_LOG_LEVEL_WARNING</code></span></p></td>
231 <td>log level for warnings, see <a class="link" href="glib-Message-Logging.html#g-warning" title="g_warning()"><code class="function">g_warning()</code></a>
232 </td>
233 </tr>
234 <tr>
235 <td><p><a name="G-LOG-LEVEL-MESSAGE:CAPS"></a><span class="term"><code class="literal">G_LOG_LEVEL_MESSAGE</code></span></p></td>
236 <td>log level for messages, see <a class="link" href="glib-Message-Logging.html#g-message" title="g_message()"><code class="function">g_message()</code></a>
237 </td>
238 </tr>
239 <tr>
240 <td><p><a name="G-LOG-LEVEL-INFO:CAPS"></a><span class="term"><code class="literal">G_LOG_LEVEL_INFO</code></span></p></td>
241 <td>log level for informational messages
242 </td>
243 </tr>
244 <tr>
245 <td><p><a name="G-LOG-LEVEL-DEBUG:CAPS"></a><span class="term"><code class="literal">G_LOG_LEVEL_DEBUG</code></span></p></td>
246 <td>log level for debug messages, see <a class="link" href="glib-Message-Logging.html#g-debug" title="g_debug()"><code class="function">g_debug()</code></a>
247 </td>
248 </tr>
249 <tr>
250 <td><p><a name="G-LOG-LEVEL-MASK:CAPS"></a><span class="term"><code class="literal">G_LOG_LEVEL_MASK</code></span></p></td>
251 <td>a mask including all log levels
252 </td>
253 </tr>
254 </tbody>
255 </table></div>
256 </div>
257 <hr>
258 <div class="refsect2">
259 <a name="g-log"></a><h3>g_log ()</h3>
260 <pre class="programlisting"><span class="returnvalue">void</span>                g_log                               (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
261                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
262                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *format</code></em>,
263                                                          <em class="parameter"><code>...</code></em>);</pre>
264 <p>
265 Logs an error or debugging message.
266 </p>
267 <p>
268 If the log level has been set as fatal, the <code class="function">abort()</code>
269 function is called to terminate the program.
270 </p>
271 <div class="variablelist"><table border="0">
272 <col align="left" valign="top">
273 <tbody>
274 <tr>
275 <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
276 <td>the log domain, usually <a class="link" href="glib-Message-Logging.html#G-LOG-DOMAIN:CAPS" title="G_LOG_DOMAIN"><span class="type">G_LOG_DOMAIN</span></a>
277 </td>
278 </tr>
279 <tr>
280 <td><p><span class="term"><em class="parameter"><code>log_level</code></em> :</span></p></td>
281 <td>the log level, either from <a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a>
282 or a user-defined level</td>
283 </tr>
284 <tr>
285 <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
286 <td>the message format. See the <code class="function">printf()</code> documentation</td>
287 </tr>
288 <tr>
289 <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
290 <td>the parameters to insert into the format string</td>
291 </tr>
292 </tbody>
293 </table></div>
294 </div>
295 <hr>
296 <div class="refsect2">
297 <a name="g-logv"></a><h3>g_logv ()</h3>
298 <pre class="programlisting"><span class="returnvalue">void</span>                g_logv                              (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
299                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
300                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *format</code></em>,
301                                                          <em class="parameter"><code><span class="type">va_list</span> args</code></em>);</pre>
302 <p>
303 Logs an error or debugging message.
304 </p>
305 <p>
306 If the log level has been set as fatal, the <code class="function">abort()</code>
307 function is called to terminate the program.
308 </p>
309 <div class="variablelist"><table border="0">
310 <col align="left" valign="top">
311 <tbody>
312 <tr>
313 <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
314 <td>the log domain</td>
315 </tr>
316 <tr>
317 <td><p><span class="term"><em class="parameter"><code>log_level</code></em> :</span></p></td>
318 <td>the log level</td>
319 </tr>
320 <tr>
321 <td><p><span class="term"><em class="parameter"><code>format</code></em> :</span></p></td>
322 <td>the message format. See the <code class="function">printf()</code> documentation</td>
323 </tr>
324 <tr>
325 <td><p><span class="term"><em class="parameter"><code>args</code></em> :</span></p></td>
326 <td>the parameters to insert into the format string</td>
327 </tr>
328 </tbody>
329 </table></div>
330 </div>
331 <hr>
332 <div class="refsect2">
333 <a name="g-message"></a><h3>g_message()</h3>
334 <pre class="programlisting">#define             g_message(...)</pre>
335 <p>
336 A convenience function/macro to log a normal message.
337 </p>
338 <div class="variablelist"><table border="0">
339 <col align="left" valign="top">
340 <tbody><tr>
341 <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
342 <td>format string, followed by parameters to insert
343 into the format string (as with <code class="function">printf()</code>)</td>
344 </tr></tbody>
345 </table></div>
346 </div>
347 <hr>
348 <div class="refsect2">
349 <a name="g-warning"></a><h3>g_warning()</h3>
350 <pre class="programlisting">#define             g_warning(...)</pre>
351 <p>
352 A convenience function/macro to log a warning message.
353 </p>
354 <p>
355 You can make warnings fatal at runtime by setting the
356 <code class="envar">G_DEBUG</code> environment variable (see
357 <a class="ulink" href="glib-running.html" target="_top">Running GLib Applications</a>).
358 </p>
359 <div class="variablelist"><table border="0">
360 <col align="left" valign="top">
361 <tbody><tr>
362 <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
363 <td>format string, followed by parameters to insert
364 into the format string (as with <code class="function">printf()</code>)</td>
365 </tr></tbody>
366 </table></div>
367 </div>
368 <hr>
369 <div class="refsect2">
370 <a name="g-critical"></a><h3>g_critical()</h3>
371 <pre class="programlisting">#define             g_critical(...)</pre>
372 <p>
373 Logs a "critical warning" (<a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-CRITICAL:CAPS"><span class="type">G_LOG_LEVEL_CRITICAL</span></a>).
374 It's more or less application-defined what constitutes
375 a critical vs. a regular warning. You could call
376 <a class="link" href="glib-Message-Logging.html#g-log-set-always-fatal" title="g_log_set_always_fatal ()"><code class="function">g_log_set_always_fatal()</code></a> to make critical warnings exit
377 the program, then use <a class="link" href="glib-Message-Logging.html#g-critical" title="g_critical()"><code class="function">g_critical()</code></a> for fatal errors, for
378 example.
379 </p>
380 <p>
381 You can also make critical warnings fatal at runtime by
382 setting the <code class="envar">G_DEBUG</code> environment variable (see
383 <a class="ulink" href="glib-running.html" target="_top">Running GLib Applications</a>).
384 </p>
385 <div class="variablelist"><table border="0">
386 <col align="left" valign="top">
387 <tbody><tr>
388 <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
389 <td>format string, followed by parameters to insert
390 into the format string (as with <code class="function">printf()</code>)</td>
391 </tr></tbody>
392 </table></div>
393 </div>
394 <hr>
395 <div class="refsect2">
396 <a name="g-error"></a><h3>g_error()</h3>
397 <pre class="programlisting">#define             g_error(...)</pre>
398 <p>
399 A convenience function/macro to log an error message.
400 </p>
401 <p>
402 Error messages are always fatal, resulting in a call to
403 <code class="function">abort()</code> to terminate the application. This function will
404 result in a core dump; don't use it for errors you expect.
405 Using this function indicates a bug in your program, i.e.
406 an assertion failure.
407 </p>
408 <div class="variablelist"><table border="0">
409 <col align="left" valign="top">
410 <tbody><tr>
411 <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
412 <td>format string, followed by parameters to insert
413 into the format string (as with <code class="function">printf()</code>)</td>
414 </tr></tbody>
415 </table></div>
416 </div>
417 <hr>
418 <div class="refsect2">
419 <a name="g-debug"></a><h3>g_debug()</h3>
420 <pre class="programlisting">#define             g_debug(...)</pre>
421 <p>
422 A convenience function/macro to log a debug message.
423 </p>
424 <div class="variablelist"><table border="0">
425 <col align="left" valign="top">
426 <tbody><tr>
427 <td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
428 <td>format string, followed by parameters to insert
429 into the format string (as with <code class="function">printf()</code>)</td>
430 </tr></tbody>
431 </table></div>
432 <p class="since">Since 2.6</p>
433 </div>
434 <hr>
435 <div class="refsect2">
436 <a name="g-log-set-handler"></a><h3>g_log_set_handler ()</h3>
437 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_log_set_handler                   (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
438                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_levels</code></em>,
439                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogFunc" title="GLogFunc ()"><span class="type">GLogFunc</span></a> log_func</code></em>,
440                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
441 <p>
442 Sets the log handler for a domain and a set of log levels.
443 To handle fatal and recursive messages the <em class="parameter"><code>log_levels</code></em> parameter
444 must be combined with the <a class="link" href="glib-Message-Logging.html#G-LOG-FLAG-FATAL:CAPS"><span class="type">G_LOG_FLAG_FATAL</span></a> and <a class="link" href="glib-Message-Logging.html#G-LOG-FLAG-RECURSION:CAPS"><span class="type">G_LOG_FLAG_RECURSION</span></a>
445 bit flags.
446 </p>
447 <p>
448 Note that since the <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-ERROR:CAPS"><span class="type">G_LOG_LEVEL_ERROR</span></a> log level is always fatal, if
449 you want to set a handler for this log level you must combine it with
450 <a class="link" href="glib-Message-Logging.html#G-LOG-FLAG-FATAL:CAPS"><span class="type">G_LOG_FLAG_FATAL</span></a>.
451 </p>
452 <p>
453 </p>
454 <div class="example">
455 <a name="id582753"></a><p class="title"><b>Example 10. Adding a log handler for all warning messages in the default
456 (application) domain</b></p>
457 <div class="example-contents">
458   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
459     <tbody>
460       <tr>
461         <td class="listing_lines" align="right"><pre>1
462 2</pre></td>
463         <td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Message-Logging.html#g-log-set-handler">g_log_set_handler</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-LEVEL-WARNING:CAPS">G_LOG_LEVEL_WARNING</a> </span><span class="symbol">|</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-FLAG-FATAL:CAPS">G_LOG_FLAG_FATAL</a></span>
464 <span class="normal">                   </span><span class="symbol">|</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-FLAG-RECURSION:CAPS">G_LOG_FLAG_RECURSION</a></span><span class="symbol">,</span><span class="normal"> my_log_handler</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
465       </tr>
466     </tbody>
467   </table>
468 </div>
469
470 </div>
471 <p><br class="example-break">
472 </p>
473 <p>
474 </p>
475 <div class="example">
476 <a name="id582771"></a><p class="title"><b>Example 11. Adding a log handler for all critical messages from GTK+</b></p>
477 <div class="example-contents">
478   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
479     <tbody>
480       <tr>
481         <td class="listing_lines" align="right"><pre>1
482 2</pre></td>
483         <td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Message-Logging.html#g-log-set-handler">g_log_set_handler</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"Gtk"</span><span class="symbol">,</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-LEVEL-CRITICAL:CAPS">G_LOG_LEVEL_CRITICAL</a> </span><span class="symbol">|</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-FLAG-FATAL:CAPS">G_LOG_FLAG_FATAL</a></span>
484 <span class="normal">                   </span><span class="symbol">|</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-FLAG-RECURSION:CAPS">G_LOG_FLAG_RECURSION</a></span><span class="symbol">,</span><span class="normal"> my_log_handler</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
485       </tr>
486     </tbody>
487   </table>
488 </div>
489
490 </div>
491 <p><br class="example-break">
492 </p>
493 <p>
494 </p>
495 <div class="example">
496 <a name="id582790"></a><p class="title"><b>Example 12. Adding a log handler for <span class="emphasis"><em>all</em></span> messages from
497 GLib</b></p>
498 <div class="example-contents">
499   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
500     <tbody>
501       <tr>
502         <td class="listing_lines" align="right"><pre>1
503 2</pre></td>
504         <td class="listing_code"><pre class="programlisting"><span class="function"><a href="glib-Message-Logging.html#g-log-set-handler">g_log_set_handler</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"GLib"</span><span class="symbol">,</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-LEVEL-MASK:CAPS">G_LOG_LEVEL_MASK</a> </span><span class="symbol">|</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-FLAG-FATAL:CAPS">G_LOG_FLAG_FATAL</a></span>
505 <span class="normal">                   </span><span class="symbol">|</span><span class="normal"> <a href="glib-Message-Logging.html#G-LOG-FLAG-RECURSION:CAPS">G_LOG_FLAG_RECURSION</a></span><span class="symbol">,</span><span class="normal"> my_log_handler</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
506       </tr>
507     </tbody>
508   </table>
509 </div>
510
511 </div>
512 <p><br class="example-break">
513 </p>
514 <div class="variablelist"><table border="0">
515 <col align="left" valign="top">
516 <tbody>
517 <tr>
518 <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
519 <td>the log domain, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> for the default ""
520 application domain. <span class="annotation">[<acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span>
521 </td>
522 </tr>
523 <tr>
524 <td><p><span class="term"><em class="parameter"><code>log_levels</code></em> :</span></p></td>
525 <td>the log levels to apply the log handler for.
526 To handle fatal and recursive messages as well, combine
527 the log levels with the <a class="link" href="glib-Message-Logging.html#G-LOG-FLAG-FATAL:CAPS"><span class="type">G_LOG_FLAG_FATAL</span></a> and
528 <a class="link" href="glib-Message-Logging.html#G-LOG-FLAG-RECURSION:CAPS"><span class="type">G_LOG_FLAG_RECURSION</span></a> bit flags.</td>
529 </tr>
530 <tr>
531 <td><p><span class="term"><em class="parameter"><code>log_func</code></em> :</span></p></td>
532 <td>the log handler function</td>
533 </tr>
534 <tr>
535 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
536 <td>data passed to the log handler</td>
537 </tr>
538 <tr>
539 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
540 <td>the id of the new handler</td>
541 </tr>
542 </tbody>
543 </table></div>
544 </div>
545 <hr>
546 <div class="refsect2">
547 <a name="g-log-remove-handler"></a><h3>g_log_remove_handler ()</h3>
548 <pre class="programlisting"><span class="returnvalue">void</span>                g_log_remove_handler                (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
549                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> handler_id</code></em>);</pre>
550 <p>
551 Removes the log handler.
552 </p>
553 <div class="variablelist"><table border="0">
554 <col align="left" valign="top">
555 <tbody>
556 <tr>
557 <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
558 <td>the log domain</td>
559 </tr>
560 <tr>
561 <td><p><span class="term"><em class="parameter"><code>handler_id</code></em> :</span></p></td>
562 <td>the id of the handler, which was returned
563 in <a class="link" href="glib-Message-Logging.html#g-log-set-handler" title="g_log_set_handler ()"><code class="function">g_log_set_handler()</code></a>
564 </td>
565 </tr>
566 </tbody>
567 </table></div>
568 </div>
569 <hr>
570 <div class="refsect2">
571 <a name="g-log-set-always-fatal"></a><h3>g_log_set_always_fatal ()</h3>
572 <pre class="programlisting"><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="returnvalue">GLogLevelFlags</span></a>      g_log_set_always_fatal              (<em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> fatal_mask</code></em>);</pre>
573 <p>
574 Sets the message levels which are always fatal, in any log domain.
575 When a message with any of these levels is logged the program terminates.
576 You can only set the levels defined by GLib to be fatal.
577 <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-ERROR:CAPS"><code class="literal">G_LOG_LEVEL_ERROR</code></a> is always fatal.
578 </p>
579 <p>
580 You can also make some message levels fatal at runtime by setting
581 the <code class="envar">G_DEBUG</code> environment variable (see
582 <a class="ulink" href="glib-running.html" target="_top">Running GLib Applications</a>).
583 </p>
584 <div class="variablelist"><table border="0">
585 <col align="left" valign="top">
586 <tbody>
587 <tr>
588 <td><p><span class="term"><em class="parameter"><code>fatal_mask</code></em> :</span></p></td>
589 <td>the mask containing bits set for each level
590 of error which is to be fatal</td>
591 </tr>
592 <tr>
593 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
594 <td>the old fatal mask</td>
595 </tr>
596 </tbody>
597 </table></div>
598 </div>
599 <hr>
600 <div class="refsect2">
601 <a name="g-log-set-fatal-mask"></a><h3>g_log_set_fatal_mask ()</h3>
602 <pre class="programlisting"><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="returnvalue">GLogLevelFlags</span></a>      g_log_set_fatal_mask                (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
603                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> fatal_mask</code></em>);</pre>
604 <p>
605 Sets the log levels which are fatal in the given domain.
606 <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-ERROR:CAPS"><code class="literal">G_LOG_LEVEL_ERROR</code></a> is always fatal.
607 </p>
608 <div class="variablelist"><table border="0">
609 <col align="left" valign="top">
610 <tbody>
611 <tr>
612 <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
613 <td>the log domain</td>
614 </tr>
615 <tr>
616 <td><p><span class="term"><em class="parameter"><code>fatal_mask</code></em> :</span></p></td>
617 <td>the new fatal mask</td>
618 </tr>
619 <tr>
620 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
621 <td>the old fatal mask for the log domain</td>
622 </tr>
623 </tbody>
624 </table></div>
625 </div>
626 <hr>
627 <div class="refsect2">
628 <a name="g-log-default-handler"></a><h3>g_log_default_handler ()</h3>
629 <pre class="programlisting"><span class="returnvalue">void</span>                g_log_default_handler               (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *log_domain</code></em>,
630                                                          <em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogLevelFlags" title="enum GLogLevelFlags"><span class="type">GLogLevelFlags</span></a> log_level</code></em>,
631                                                          <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *message</code></em>,
632                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> unused_data</code></em>);</pre>
633 <p>
634 The default log handler set up by GLib; <a class="link" href="glib-Message-Logging.html#g-log-set-default-handler" title="g_log_set_default_handler ()"><code class="function">g_log_set_default_handler()</code></a>
635 allows to install an alternate default log handler.
636 This is used if no log handler has been set for the particular log
637 domain and log level combination. It outputs the message to stderr
638 or stdout and if the log level is fatal it calls <code class="function">abort()</code>.
639 </p>
640 <p>
641 The behavior of this log handler can be influenced by a number of
642 environment variables:
643 </p>
644 <div class="variablelist"><table border="0">
645 <col align="left" valign="top">
646 <tbody>
647 <tr>
648 <td><p><span class="term"><code class="envar">G_MESSAGES_PREFIXED</code></span></p></td>
649 <td>
650       A :-separated list of log levels for which messages should
651       be prefixed by the program name and PID of the aplication.
652     </td>
653 </tr>
654 <tr>
655 <td><p><span class="term"><code class="envar">G_MESSAGES_DEBUG</code></span></p></td>
656 <td>
657       A space-separated list of log domains for which debug and
658       informational messages are printed. By default these
659       messages are not printed.
660     </td>
661 </tr>
662 </tbody>
663 </table></div>
664 <p>
665 </p>
666 <p>
667 stderr is used for levels <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-ERROR:CAPS"><code class="literal">G_LOG_LEVEL_ERROR</code></a>, <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-CRITICAL:CAPS"><code class="literal">G_LOG_LEVEL_CRITICAL</code></a>,
668 <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-WARNING:CAPS"><code class="literal">G_LOG_LEVEL_WARNING</code></a> and <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-MESSAGE:CAPS"><code class="literal">G_LOG_LEVEL_MESSAGE</code></a>. stdout is used for
669 the rest.
670 </p>
671 <div class="variablelist"><table border="0">
672 <col align="left" valign="top">
673 <tbody>
674 <tr>
675 <td><p><span class="term"><em class="parameter"><code>log_domain</code></em> :</span></p></td>
676 <td>the log domain of the message</td>
677 </tr>
678 <tr>
679 <td><p><span class="term"><em class="parameter"><code>log_level</code></em> :</span></p></td>
680 <td>the level of the message</td>
681 </tr>
682 <tr>
683 <td><p><span class="term"><em class="parameter"><code>message</code></em> :</span></p></td>
684 <td>the message</td>
685 </tr>
686 <tr>
687 <td><p><span class="term"><em class="parameter"><code>unused_data</code></em> :</span></p></td>
688 <td>data passed from <a class="link" href="glib-Message-Logging.html#g-log" title="g_log ()"><code class="function">g_log()</code></a> which is unused</td>
689 </tr>
690 </tbody>
691 </table></div>
692 </div>
693 <hr>
694 <div class="refsect2">
695 <a name="g-log-set-default-handler"></a><h3>g_log_set_default_handler ()</h3>
696 <pre class="programlisting"><a class="link" href="glib-Message-Logging.html#GLogFunc" title="GLogFunc ()"><span class="returnvalue">GLogFunc</span></a>            g_log_set_default_handler           (<em class="parameter"><code><a class="link" href="glib-Message-Logging.html#GLogFunc" title="GLogFunc ()"><span class="type">GLogFunc</span></a> log_func</code></em>,
697                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
698 <p>
699 Installs a default log handler which is used if no
700 log handler has been set for the particular log domain
701 and log level combination. By default, GLib uses
702 <a class="link" href="glib-Message-Logging.html#g-log-default-handler" title="g_log_default_handler ()"><code class="function">g_log_default_handler()</code></a> as default log handler.
703 </p>
704 <div class="variablelist"><table border="0">
705 <col align="left" valign="top">
706 <tbody>
707 <tr>
708 <td><p><span class="term"><em class="parameter"><code>log_func</code></em> :</span></p></td>
709 <td>the log handler function</td>
710 </tr>
711 <tr>
712 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
713 <td>data passed to the log handler</td>
714 </tr>
715 <tr>
716 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
717 <td>the previous default log handler</td>
718 </tr>
719 </tbody>
720 </table></div>
721 <p class="since">Since 2.6</p>
722 </div>
723 </div>
724 </div>
725 <div class="footer">
726 <hr>
727           Generated by GTK-Doc V1.18</div>
728 </body>
729 </html>