⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-message-logging.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Message Logging</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-core.html" title="GLib Core Application Support"><link rel="prev" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions"><link rel="next" href="glib-utilities.html" title="GLib Utilities"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"><link rel="index" href="ix09.html" title="Index of new symbols in 2.14"><link rel="index" href="ix10.html" title="Index of new symbols in 2.16"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-Warnings-and-Assertions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-utilities.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id2957147" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id2957584" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="glib-Message-Logging"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id2957147"></a><span class="refentrytitle">Message Logging</span></h2><p>Message Logging &#8212; versatile support for logging messages with different levels of importance</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include &lt;glib.h&gt;#define             <a class="link" href="glib-Message-Logging.html#G-LOG-DOMAIN:CAPS">G_LOG_DOMAIN</a>#define             <a class="link" href="glib-Message-Logging.html#G-LOG-FATAL-MASK:CAPS">G_LOG_FATAL_MASK</a>#define             <a class="link" href="glib-Message-Logging.html#G-LOG-LEVEL-USER-SHIFT:CAPS">G_LOG_LEVEL_USER_SHIFT</a>void                (<a class="link" href="glib-Message-Logging.html#GLogFunc">*GLogFunc</a>)                         (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> log_level,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *message,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);enum                <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a>;void                <a class="link" href="glib-Message-Logging.html#g-log">g_log</a>                               (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> log_level,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *format,                                                         ...);void                <a class="link" href="glib-Message-Logging.html#g-logv">g_logv</a>                              (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> log_level,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *format,                                                         va_list args);#define             <a class="link" href="glib-Message-Logging.html#g-message">g_message</a>                           (...)#define             <a class="link" href="glib-Message-Logging.html#g-warning">g_warning</a>                           (...)#define             <a class="link" href="glib-Message-Logging.html#g-critical">g_critical</a>                          (...)#define             <a class="link" href="glib-Message-Logging.html#g-error">g_error</a>                             (...)#define             <a class="link" href="glib-Message-Logging.html#g-debug">g_debug</a>                             (...)<a class="link" href="glib-Basic-Types.html#guint">guint</a>               <a class="link" href="glib-Message-Logging.html#g-log-set-handler">g_log_set_handler</a>                   (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> log_levels,                                                         <a class="link" href="glib-Message-Logging.html#GLogFunc">GLogFunc</a> log_func,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);void                <a class="link" href="glib-Message-Logging.html#g-log-remove-handler">g_log_remove_handler</a>                (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> handler_id);<a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a>      <a class="link" href="glib-Message-Logging.html#g-log-set-always-fatal">g_log_set_always_fatal</a>              (<a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> fatal_mask);<a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a>      <a class="link" href="glib-Message-Logging.html#g-log-set-fatal-mask">g_log_set_fatal_mask</a>                (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> fatal_mask);void                <a class="link" href="glib-Message-Logging.html#g-log-default-handler">g_log_default_handler</a>               (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> log_level,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *message,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> unused_data);<a class="link" href="glib-Message-Logging.html#GLogFunc">GLogFunc</a>            <a class="link" href="glib-Message-Logging.html#g-log-set-default-handler">g_log_set_default_handler</a>           (<a class="link" href="glib-Message-Logging.html#GLogFunc">GLogFunc</a> log_func,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre></div><div class="refsect1" lang="en"><a name="id2957584"></a><h2>Description</h2><p>These functions provide support for logging error messages or messages used for debugging. </p><p>There are several built-in levels of messages, defined in <a class="link" href="glib-Message-Logging.html#GLogLevelFlags"><span class="type">GLogLevelFlags</span></a>.These can be extended with user-defined levels.</p></div><div class="refsect1" lang="en"><a name="id2957613"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2957623"></a><h3><a name="G-LOG-DOMAIN:CAPS"></a>G_LOG_DOMAIN</h3><a class="indexterm" name="id2957636"></a><pre class="programlisting">#define G_LOG_DOMAIN    ((gchar*) 0)</pre><p>Defines the log domain.For applications, this is typically left as the default <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> (or "") domain.Libraries should define this so that any messages which they log canbe differentiated from messages from other libraries and application code.But be careful not to define it in any public header files.</p><p>For example, GTK+ uses this in its Makefile.am:</p><div class="informalexample"><pre class="programlisting">INCLUDES = -DG_LOG_DOMAIN=\"Gtk\"</pre></div></div><hr><div class="refsect2" lang="en"><a name="id2957679"></a><h3><a name="G-LOG-FATAL-MASK:CAPS"></a>G_LOG_FATAL_MASK</h3><a class="indexterm" name="id2957692"></a><pre class="programlisting">#define G_LOG_FATAL_MASK        (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)</pre><p>GLib log levels that are considered fatal by default.</p></div><hr><div class="refsect2" lang="en"><a name="id2957709"></a><h3><a name="G-LOG-LEVEL-USER-SHIFT:CAPS"></a>G_LOG_LEVEL_USER_SHIFT</h3><a class="indexterm" name="id2957722"></a><pre class="programlisting">#define G_LOG_LEVEL_USER_SHIFT  (8)</pre><p>Log level shift offset for user defined log levels (0-7 are used by GLib).</p></div><hr><div class="refsect2" lang="en"><a name="id2957739"></a><h3><a name="GLogFunc"></a>GLogFunc ()</h3><a class="indexterm" name="id2957752"></a><pre class="programlisting">void                (*GLogFunc)                         (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *log_domain,                                                         <a class="link" href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> log_level,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *message,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Specifies the prototype of log handler functions.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>log_domain</code></em>&#160;:</span></p></td><td>the log domain of the message.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>log_level</code></em>&#160;:</span></p></td><td>the log level of the message (including the fatal and recursionflags).</td></tr><tr><td><p><span class="term"><em class="parameter"><code>message</code></em>&#160;:</span></p></td><td>the message to process.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td><td>user data, set in <a class="link" href="glib-Message-Logging.html#g-log-set-handler"><code class="function">g_log_set_handler()</code></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2957877"></a><h3><a name="GLogLevelFlags"></a>enum GLogLevelFlags</h3><a class="indexterm" name="id2957890"></a><pre class="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;</pre><p>Flags specifying the level of log messages. It is possible to changehow GLib treats messages of the various levels using <a class="link" href="glib-Message-Logging.html#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"><code class="function">g_log_set_fatal_mask()</code></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="G-LOG-FLAG-RECURSION:CAPS"></a><code class="literal">G_LOG_FLAG_RECURSION</code></span></p></td><td>internal flag</td></tr><tr><td><p><span class="term"><a name="G-LOG-FLAG-FATAL:CAPS"></a><code class="literal">G_LOG_FLAG_FATAL</code></span></p></td><td>internal flag</td></tr><tr><td><p><span class="term"><a name="G-LOG-LEVEL-ERROR:CAPS"></a><code class="literal">G_LOG_LEVEL_ERROR</code></span></p></td><td>log level for errors, see <a class="link" href="glib-Message-Logging.html#g-error"><code class="function">g_error()</code></a>.   This level is also used for messages produced by <a class="link" href="glib-Testing.html#g-assert"><code class="function">g_assert()</code></a>.</td></tr><tr><td><p><span class="term"><a name="G-LOG-LEVEL-CRITICAL:CAPS"></a><code class="literal">G_LOG_LEVEL_CRITICAL</code></span></p></td><td>log level for critical messages, see <a class="link" href="glib-Message-Logging.html#g-critical"><code class="function">g_critical()</code></a>.  This level is also used for messages produced by <a class="link" href="glib-Warnings-and-Assertions.html#g-return-if-fail"><code class="function">g_return_if_fail()</code></a> and   <a class="link" href="glib-Warnings-and-Assertions.html#g-return-val-if-fail"><code class="function">g_return_val_if_fail()</code></a>.</td></tr><tr><td><p><span class="term"><a name="G-LOG-LEVEL-WARNING:CAPS"></a><code class="literal">G_LOG_LEVEL_WARNING</code></span></p></td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -