您的位置:首页 > 其它

Warning and debug in Gnome technology

2015-03-25 19:17 295 查看
</pre><h3 style="">g_warning()</h3><pre class="programlisting" style="">#define             g_warning(...)


A convenience function/macro to log a warning message.

You can make warnings fatal at runtime by setting the 
G_DEBUG
 environment variable (see Running
GLib Applications).

If 
g_log_default_handler()
 is
used as the log handler function, a newline character will automatically be appended to @..., and need not be entered manually.

Parameters

...
format string, followed by parameters to insert into the format string (as with 
printf()
)
We get a negative errno-style error code named "r". And then we can write the code like this.

g_warning ("Error doing something blah: %s", g_strerror (-r));


Debug and critical are almost the same as the warning.

Here are the API of g_debug and g_critical.

g_debug()

#define             g_debug(...)


A convenience function/macro to log a debug message.

If 
g_log_default_handler()
 is
used as the log handler function, a new-line character will automatically be appended to @..., and need not be entered manually.

Such messages are suppressed by the 
g_log_default_handler()
 unless
the G_MESSAGES_DEBUG environment variable is set appropriately.

Parameters

...
format string, followed by parameters to insert into the format string (as with 
printf()
)

g_critical()

#define             g_critical(...)


Logs a "critical warning" (G_LOG_LEVEL_CRITICAL). It's more or less application-defined
what constitutes a critical vs. a regular warning. You could call 
g_log_set_always_fatal()
 to
make critical warnings exit the program, then use 
g_critical()
 for
fatal errors, for example.

You can also make critical warnings fatal at runtime by setting the 
G_DEBUG
 environment variable (see Running
GLib Applications).

If 
g_log_default_handler()
 is
used as the log handler function, a new-line character will automatically be appended to @..., and need not be entered manually.

Parameters

...
format string, followed by parameters to insert into the format string (as with 
printf()
)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐