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