buffet: Pretty print GetDeviceInfo and GetState

Modify the dbus calls for GetDeviceInfo and GetState to
return pretty printed JSON instead of the standard JSON output
(everything on one long line). I think the main users of this
function will be tools like buffet_client that will be displaying
it for human consumption.

TEST=FEATURES=test emerge-${BOARD} buffet
BUG=none

Change-Id: I208f188fa3a8ffe52bd2d3e50289f4e99b8c0dbc
Reviewed-on: https://chromium-review.googlesource.com/263497
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Nathan Bullock <nathanbullock@google.com>
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Nathan Bullock <nathanbullock@google.com>
diff --git a/buffet/buffet_client.cc b/buffet/buffet_client.cc
index 355d39b..e8ec78d 100644
--- a/buffet/buffet_client.cc
+++ b/buffet/buffet_client.cc
@@ -299,8 +299,7 @@
       return ReportError(error.get());
     }
 
-    printf("Device Info: %s\n",
-           device_info.empty() ? "<unregistered>" : device_info.c_str());
+    printf("%s\n", device_info.c_str());
     OnJobComplete();
   }
 
@@ -350,7 +349,7 @@
     if (!manager_proxy->GetState(&json, &error)) {
       return ReportError(error.get());
     }
-    printf("Device State: %s\n", json.c_str());
+    printf("%s\n", json.c_str());
     OnJobComplete();
   }
 
diff --git a/buffet/manager.cc b/buffet/manager.cc
index e486d5a..31115b7 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -104,7 +104,8 @@
   }
 
   std::string device_info_str;
-  base::JSONWriter::Write(device_info.get(), &device_info_str);
+  base::JSONWriter::WriteWithOptions(device_info.get(),
+      base::JSONWriter::OPTIONS_PRETTY_PRINT, &device_info_str);
   response->Return(device_info_str);
 }
 
@@ -161,7 +162,8 @@
   auto json = state_manager_->GetStateValuesAsJson(error);
   if (!json)
     return false;
-  base::JSONWriter::Write(json.get(), state);
+  base::JSONWriter::WriteWithOptions(
+      json.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, state);
   return true;
 }
 
@@ -199,7 +201,8 @@
     return;
   }
   std::string command_str;
-  base::JSONWriter::Write(command->ToJson().get(), &command_str);
+  base::JSONWriter::WriteWithOptions(command->ToJson().get(),
+      base::JSONWriter::OPTIONS_PRETTY_PRINT, &command_str);
   response->Return(command_str);
 }
 
@@ -220,7 +223,8 @@
       command_manager_->GetCommandDictionary().GetCommandsAsJson(true, &error);
   CHECK(commands);
   std::string json;
-  base::JSONWriter::Write(commands.get(), &json);
+  base::JSONWriter::WriteWithOptions(commands.get(),
+      base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
   dbus_adaptor_.SetCommandDefs(json);
 }