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.c b/mboxd.c
index 1307fe6..e5b6fe8 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -92,10 +92,11 @@
 					strerror(errno));
 			}
 
+			MSG_DBG("Received signal: %d\n", info.ssi_signo);
 			switch (info.ssi_signo) {
 			case SIGINT:
 			case SIGTERM:
-				MSG_OUT("Caught Signal - Exiting...\n");
+				MSG_INFO("Caught Signal - Exiting...\n");
 				context->terminate = true;
 				break;
 			case SIGHUP:
@@ -116,7 +117,9 @@
 			}
 		}
 		if (context->fds[DBUS_FD].revents & POLLIN) { /* DBUS */
-			while ((rc = sd_bus_process(context->bus, NULL)) > 0);
+			while ((rc = sd_bus_process(context->bus, NULL)) > 0) {
+				MSG_DBG("DBUS Event\n");
+			}
 			if (rc < 0) {
 				MSG_ERR("Error handling DBUS event: %s\n",
 						strerror(-rc));
@@ -126,6 +129,7 @@
 			break; /* This should mean we clean up nicely */
 		}
 		if (context->fds[MBOX_FD].revents & POLLIN) { /* MBOX */
+			MSG_DBG("MBOX Event\n");
 			rc = dispatch_mbox(context);
 			if (rc < 0) {
 				MSG_ERR("Error handling MBOX event\n");
@@ -272,10 +276,10 @@
 		return false;
 	}
 
-	MSG_OUT("Flash size: 0x%.8x\n", context->flash_size);
+	MSG_INFO("Flash size: 0x%.8x\n", context->flash_size);
 
 	if (verbosity) {
-		MSG_OUT("%s logging\n", verbosity == MBOX_LOG_DEBUG ? "Debug" :
+		MSG_INFO("%s logging\n", verbosity == MBOX_LOG_DEBUG ? "Debug" :
 					"Verbose");
 	}
 
@@ -305,7 +309,7 @@
 		context->fds[i].fd = -1;
 	}
 
-	MSG_OUT("Starting Daemon\n");
+	MSG_INFO("Starting Daemon\n");
 
 	rc = init_signals(context, &set);
 	if (rc) {
@@ -349,13 +353,13 @@
 		goto finish;
 	}
 
-	MSG_OUT("Entering Polling Loop\n");
+	MSG_INFO("Entering Polling Loop\n");
 	rc = poll_loop(context);
 
-	MSG_OUT("Exiting Poll Loop: %d\n", rc);
+	MSG_INFO("Exiting Poll Loop: %d\n", rc);
 
 finish:
-	MSG_OUT("Daemon Exiting...\n");
+	MSG_INFO("Daemon Exiting...\n");
 	clr_bmc_events(context, BMC_EVENT_DAEMON_READY, SET_BMC_EVENT);
 
 	free_mboxd_dbus(context);