mboxd: Introduce a new DEBUG log level
Currently there is no output on the console unless -v is specified on
the command line which enables error output. A second -v will provide
info output.
We probably want error output irrespective of whether a -v was given
on the command line because people generally want to know why their
program stopped working.
Make error output unconditional.
A single -v will give minimal informational output which is a good
level to see what the daemon is doing without barfing all over the
console.
A second -v will enable debug output which will print highly verbose
information which will be useful for debugging. Probably don't enable
this under normal circumstances.
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Change-Id: I3da25f7e4e9e976c17389fcceb1d85ef98de7e0a
diff --git a/mboxd_dbus.c b/mboxd_dbus.c
index a72e48b..6673ca6 100644
--- a/mboxd_dbus.c
+++ b/mboxd_dbus.c
@@ -159,7 +159,7 @@
{
context->terminate = 1;
- MSG_OUT("DBUS Kill - Exiting...\n");
+ MSG_INFO("DBUS Kill - Exiting...\n");
return 0;
}
@@ -276,7 +276,7 @@
struct mbox_dbus_msg req = { 0 }, resp = { 0 };
struct mbox_context *context;
sd_bus_message *n;
- int rc;
+ int rc, i;
context = (struct mbox_context *) userdata;
if (!context) {
@@ -292,6 +292,7 @@
rc = -E_DBUS_INTERNAL;
goto out;
}
+ MSG_DBG("DBUS request: %u\n", req.cmd);
/* Read the args */
rc = sd_bus_message_read_array(m, 'y', (const void **) &req.args,
@@ -301,6 +302,10 @@
rc = -E_DBUS_INTERNAL;
goto out;
}
+ MSG_DBG("DBUS num_args: %u\n", (unsigned) req.num_args);
+ for (i = 0; i < req.num_args; i++) {
+ MSG_DBG("DBUS arg[%d]: %u\n", i, req.args[i]);
+ }
/* Handle the command */
if (req.cmd >= NUM_DBUS_CMDS) {
@@ -332,6 +337,12 @@
goto cleanup;
}
+ MSG_DBG("DBUS response: %u\n", resp.cmd);
+ MSG_DBG("DBUS num_args: %u\n", (unsigned) resp.num_args);
+ for (i = 0; i < resp.num_args; i++) {
+ MSG_DBG("DBUS arg[%d]: %u\n", i, resp.args[i]);
+ }
+
rc = sd_bus_send(NULL, n, NULL); /* Send response */
if (rc < 0)
MSG_ERR("sd_bus_send failed: %d\n", rc);