Fix signal monitor init when power-control is not available

On start-up if power-control is not available, the signal monitors
don't get initialized correctly.  This changes so if power-control
is not available on start-up, init is handled when power-control
starts.

Also fix an error log to print in decimal.

Tested:
Manually started power-control after host-error-monitor and
confirmed that the signal monitors start correctly.

Change-Id: I34784258e43cd2166fb4921cab06708ce9f78174
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/include/host_error_monitor.hpp b/include/host_error_monitor.hpp
index 336af02..8710a44 100644
--- a/include/host_error_monitor.hpp
+++ b/include/host_error_monitor.hpp
@@ -106,9 +106,9 @@
 static void printPECIError(const std::string& reg, const size_t addr,
                            const EPECIStatus peciStatus, const size_t cc)
 {
-    std::cerr << "Failed to read " << reg << " on CPU address " << addr
-              << ". Error: " << peciStatus << ": cc: 0x" << std::hex << cc
-              << "\n";
+    std::cerr << "Failed to read " << reg << " on CPU address " << std::dec
+              << addr << ". Error: " << peciStatus << ": cc: 0x" << std::hex
+              << cc << "\n";
 }
 
 static void beep(std::shared_ptr<sdbusplus::asio::connection> conn,
diff --git a/src/host_error_monitor.cpp b/src/host_error_monitor.cpp
index d01eac9..22754be 100644
--- a/src/host_error_monitor.cpp
+++ b/src/host_error_monitor.cpp
@@ -34,6 +34,19 @@
 
 static void init()
 {
+    static bool initialized = false;
+
+    if (!initialized)
+    {
+        initialized = true;
+        if (!error_monitors::startMonitors(io, conn))
+        {
+            throw std::runtime_error("Failed to start signal monitors");
+        }
+    }
+}
+static void initializeHostState()
+{
     // Get the current host state to prepare to start the signal monitors
     conn->async_method_call(
         [](boost::system::error_code ec,
@@ -50,11 +63,8 @@
             }
             hostOff = *state == "xyz.openbmc_project.State.Host.HostState.Off";
 
-            // Now we have the host state, start the signal monitors
-            if (!error_monitors::startMonitors(io, conn))
-            {
-                throw std::runtime_error("Failed to start signal monitors");
-            }
+            // Now we have the host state, we can init if needed
+            init();
         },
         "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0",
         "org.freedesktop.DBus.Properties", "Get",
@@ -96,6 +106,9 @@
 
             hostOff = *state == "xyz.openbmc_project.State.Host.HostState.Off";
 
+            // Now we have the host state, we can init if needed
+            init();
+
             if (!hostOff)
             {
                 // Notify error monitors when the host turns on
@@ -122,7 +135,7 @@
         host_error_monitor::startHostStateMonitor();
 
     // Initialize the signal monitors
-    host_error_monitor::init();
+    host_error_monitor::initializeHostState();
 
     host_error_monitor::io.run();