logs: provide option to display log

This is a very basic display that just dumps the formatted json data of
the xyz.openbmc_project.Logging.Entry interface. There is much more that
could be done here but this is 100% more then what we have and could be
built upon later if found useful.

Tested:
root@witherspoon:~# obmcutil showlog /xyz/openbmc_project/logging/entry/54
{
	"type" : "a{sv}",
	"data" : [
		{
			"Id" : {
				"type" : "u",
				"data" : 54
			},
			"Timestamp" : {
				"type" : "t",
				"data" : 1589483560788
			},
			"Severity" : {
				"type" : "s",
				"data" : "xyz.openbmc_project.Logging.Entry.Level.Error"
			},
			"Message" : {
				"type" : "s",
				"data" : "xyz.openbmc_project.Common.Error.Timeout"
			},
			"AdditionalData" : {
				"type" : "as",
				"data" : [
					"CALLOUT_INVENTORY_PATH=/xyz/openbmc_project/inventory/system/chassis/motherboard",
					"TIMEOUT_IN_MSEC=5"
				]
			},
			"Resolved" : {
				"type" : "b",
				"data" : false
			},
			"UpdateTimestamp" : {
				"type" : "t",
				"data" : 1589483560788
			}
		}
	]
}

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I1f47093ec3b24fd21bbf7c693a2e89bdf83feeda
diff --git a/obmcutil b/obmcutil
index 1741d9d..016cfa2 100755
--- a/obmcutil
+++ b/obmcutil
@@ -4,7 +4,7 @@
 
 OPTS="bmcstate,bootprogress,chassiskill,chassisoff,chassison,chassisstate,hoststate,\
 osstate,power,poweroff,poweron,state,status,hostrebootoff,hostrebooton,recoveryoff,recoveryon,\
-bmcrebootoff, bmcrebooton, listbootblock listlogs"
+bmcrebootoff, bmcrebooton, listbootblock listlogs showlog"
 
 USAGE="Usage: obmcutil [-h] [--wait] [--verbose]
                 {$OPTS}"
@@ -66,6 +66,9 @@
     echo "obmcutil listlogs      List all phosphor-logging entries on the"
     echo "                       system"
     echo ""
+    echo "obmcutil showlog <log> Display details of input log. Format of <log>"
+    echo "                       should match listlogs output"
+    echo ""
     echo "optional arguments:"
     echo "  -h, --help          show this help message and exit"
     echo "  -w, --wait          block until state transition succeeds or fails"
@@ -251,6 +254,15 @@
             xyz.openbmc_project.Logging.Entry
 }
 
+# display input log details
+show_log()
+{
+    busctl -j call xyz.openbmc_project.Logging \
+           $1 \
+           org.freedesktop.DBus.Properties \
+           GetAll s xyz.openbmc_project.Logging.Entry
+}
+
 handle_cmd ()
 {
     case "$1" in
@@ -401,6 +413,9 @@
         listlogs)
             list_logs
             ;;
+        showlog)
+            show_log $2
+            ;;
         *)
             print_usage_err "Invalid command '$1'"
             ;;
@@ -424,7 +439,9 @@
             ;;
         *)
             G_ORIG_CMD=$arg
-            handle_cmd $arg
+            # pass all arguments to handle_cmd in case command takes additional
+            # parameters
+            handle_cmd "$@"
             break
             ;;
     esac