[glib/wip/gcleanup: 2/10] gmessages: Add g_info macro for G_LOG_LEVEL_INFO
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/gcleanup: 2/10] gmessages: Add g_info macro for G_LOG_LEVEL_INFO
- Date: Thu, 31 Oct 2013 09:17:24 +0000 (UTC)
commit eb888062b5611d737bb0b7e28c07487ffc835521
Author: Stef Walter <stefw gnome org>
Date: Tue Oct 29 21:30:06 2013 +0100
gmessages: Add g_info macro for G_LOG_LEVEL_INFO
For completeness. Although less used than others, projects want
to use this, and end up having to define it awkwardly themselves.
https://bugzilla.gnome.org/show_bug.cgi?id=711103
docs/reference/glib/glib-sections.txt | 1 +
glib/gmessages.c | 22 +++++++++++++++++++++-
glib/gmessages.h | 15 +++++++++++++++
glib/tests/protocol.c | 5 +----
4 files changed, 38 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 9613a5f..c44219f 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1072,6 +1072,7 @@ g_message
g_warning
g_critical
g_error
+g_info
g_debug
<SUBSECTION>
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 26018cd..2965d28 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -146,7 +146,7 @@
* and g_return_val_if_fail().
* @G_LOG_LEVEL_WARNING: log level for warnings, see g_warning()
* @G_LOG_LEVEL_MESSAGE: log level for messages, see g_message()
- * @G_LOG_LEVEL_INFO: log level for informational messages
+ * @G_LOG_LEVEL_INFO: log level for informational messages, see g_info()
* @G_LOG_LEVEL_DEBUG: log level for debug messages, see g_debug()
* @G_LOG_LEVEL_MASK: a mask including all log levels
*
@@ -225,6 +225,23 @@
*/
/**
+ * g_info:
+ * @...: format string, followed by parameters to insert
+ * into the format string (as with printf())
+ *
+ * A convenience function/macro to log an informational message. Seldom used.
+ *
+ * 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.
+ *
+ * Since: 2.40
+ */
+
+/**
* g_debug:
* @...: format string, followed by parameters to insert
* into the format string (as with printf())
@@ -235,6 +252,9 @@
* 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.
+ *
* Since: 2.6
*/
diff --git a/glib/gmessages.h b/glib/gmessages.h
index 77958ad..6c6ba7f 100644
--- a/glib/gmessages.h
+++ b/glib/gmessages.h
@@ -164,6 +164,9 @@ void g_assert_warning (const char *log_domain,
#define g_warning(...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
__VA_ARGS__)
+#define g_info(...) g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_INFO, \
+ __VA_ARGS__)
#define g_debug(...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_DEBUG, \
__VA_ARGS__)
@@ -184,6 +187,9 @@ void g_assert_warning (const char *log_domain,
#define g_warning(format...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_WARNING, \
format)
+#define g_info(format...) g_log (G_LOG_DOMAIN, \
+ G_LOG_LEVEL_INFO, \
+ format)
#define g_debug(format...) g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_DEBUG, \
format)
@@ -230,6 +236,15 @@ g_warning (const gchar *format,
va_end (args);
}
static void
+g_info (const gchar *format,
+ ...)
+{
+ va_list args;
+ va_start (args, format);
+ g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format, args);
+ va_end (args);
+}
+static void
g_debug (const gchar *format,
...)
{
diff --git a/glib/tests/protocol.c b/glib/tests/protocol.c
index e80b610..fe67c41 100644
--- a/glib/tests/protocol.c
+++ b/glib/tests/protocol.c
@@ -42,11 +42,8 @@ debug (void)
static void
info (void)
{
-#ifdef g_info
-#error "rewrite this to use g_info()"
-#endif
if (g_test_subprocess ())
- g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "this is a regular g_log(..., G_LOG_LEVEL_INFO, ...) from the
test suite");
+ g_info ("this is a regular g_info from the test suite");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]