[libglnx/wip/smcv/g-info] backports: Backport g_info()




commit c5e1b295bc0f60b4562cd3db0379c0822ed758f1
Author: Simon McVittie <smcv collabora com>
Date:   Wed Jul 27 16:36:27 2022 +0100

    backports: Backport g_info()
    
    The rest of the g_log() wrappers have been there since time immemorial,
    but g_info() was initially omitted. It's useful for projects like Flatpak
    that want to have two levels of off-by-default logging, which map nicely
    to info and debug.
    
    Signed-off-by: Simon McVittie <smcv collabora com>

 glnx-backports.h            | 4 ++++
 tests/test-libglnx-macros.c | 8 ++++++++
 2 files changed, 12 insertions(+)
---
diff --git a/glnx-backports.h b/glnx-backports.h
index 0c5fabe..bdc4bbe 100644
--- a/glnx-backports.h
+++ b/glnx-backports.h
@@ -48,6 +48,10 @@ G_BEGIN_DECLS
   } G_STMT_END
 #endif
 
+#if !GLIB_CHECK_VERSION(2, 40, 0)
+#define g_info(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__)
+#endif
+
 #if !GLIB_CHECK_VERSION(2, 44, 0)
 
 #define g_strv_contains glnx_strv_contains
diff --git a/tests/test-libglnx-macros.c b/tests/test-libglnx-macros.c
index 5f41e5b..ec669d3 100644
--- a/tests/test-libglnx-macros.c
+++ b/tests/test-libglnx-macros.c
@@ -26,6 +26,13 @@
 #include <gio/gio.h>
 #include <string.h>
 
+static void
+test_info (void)
+{
+  g_info ("hello, world");
+  g_info ("answer=%d", 42);
+}
+
 static void
 test_inset (void)
 {
@@ -104,6 +111,7 @@ test_hash_table_foreach (void)
 int main (int argc, char **argv)
 {
   g_test_init (&argc, &argv, NULL);
+  g_test_add_func ("/info", test_info);
   g_test_add_func ("/inset", test_inset);
   g_test_add_func ("/hash_table_foreach", test_hash_table_foreach);
   return g_test_run();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]