qemu-devel
[Top][All Lists]
Advanced

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

[RFC PATCH 09/19] tools/vhost-user-rpmb: add a --verbose/debug flags for


From: Alex Bennée
Subject: [RFC PATCH 09/19] tools/vhost-user-rpmb: add a --verbose/debug flags for logging
Date: Fri, 25 Sep 2020 13:51:37 +0100

This gives us two levels of informational output when tracing what the
daemon is doing.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tools/vhost-user-rpmb/main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/vhost-user-rpmb/main.c b/tools/vhost-user-rpmb/main.c
index 269c86cbb633..1be0d4b8a567 100644
--- a/tools/vhost-user-rpmb/main.c
+++ b/tools/vhost-user-rpmb/main.c
@@ -6,6 +6,9 @@
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
+#define G_LOG_DOMAIN "vhost-user-rpmb"
+#define G_LOG_USE_STRUCTURED 1
+
 #include <glib.h>
 #include <gio/gio.h>
 #include <gio/gunixsocketaddress.h>
@@ -25,12 +28,16 @@
 static gchar *socket_path;
 static gint socket_fd = -1;
 static gboolean print_cap;
+static gboolean verbose;
+static gboolean debug;
 
 static GOptionEntry options[] =
 {
     { "socket-path", 0, 0, G_OPTION_ARG_FILENAME, &socket_path, "Location of 
vhost-user Unix domain socket, incompatible with --fd", "PATH" },
     { "fd", 0, 0, G_OPTION_ARG_INT, &socket_fd, "Specify the file-descriptor 
of the backend, incompatible with --socket-path", "FD" },
     { "print-capabilities", 0, 0, G_OPTION_ARG_NONE, &print_cap, "Output to 
stdout the backend capabilities in JSON format and exit", NULL},
+    { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be more verbose in 
output", NULL},
+    { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "Include debug output", NULL},
     { NULL }
 };
 
@@ -84,6 +91,7 @@ static void vrpmb_panic(VuDev *dev, const char *msg)
 
 static uint64_t vrpmb_get_features(VuDev *dev)
 {
+    g_info("%s: replying", __func__);
     return 0;
 }
 
@@ -209,6 +217,17 @@ int main (int argc, char *argv[])
         exit(EXIT_FAILURE);
     }
 
+    if (verbose || debug) {
+        g_log_set_handler(NULL, G_LOG_LEVEL_MASK, g_log_default_handler, NULL);
+        if (debug) {
+            g_setenv("G_MESSAGES_DEBUG", "all", true);
+        }
+    } else {
+        g_log_set_handler(NULL,
+                          G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | 
G_LOG_LEVEL_ERROR,
+                          g_log_default_handler, NULL);
+    }
+
     /*
      * Now create a vhost-user socket that we will receive messages
      * on. Once we have our handler set up we can enter the glib main
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]