Warning and debug in Gnome technology


</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())


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值