phosphor-rsyslog-conf: implement restore

Upon startup, if a remote logging config exists, relay that information
into appropriate D-Bus properties.

Change-Id: Ib873667a50f0c8a6af6a3b571f68d6075808ed10
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/phosphor-rsyslog-config/server-conf.cpp b/phosphor-rsyslog-config/server-conf.cpp
index 1b46965..0b5bc62 100644
--- a/phosphor-rsyslog-config/server-conf.cpp
+++ b/phosphor-rsyslog-config/server-conf.cpp
@@ -2,7 +2,6 @@
 #include "utils.hpp"
 #include "xyz/openbmc_project/Common/error.hpp"
 #include <fstream>
-#include <phosphor-logging/log.hpp>
 #include <phosphor-logging/elog.hpp>
 #if __has_include("../../usr/include/phosphor-logging/elog-errors.hpp")
 #include "../../usr/include/phosphor-logging/elog-errors.hpp"
@@ -128,5 +127,28 @@
     return true;
 }
 
+void Server::restore(const char* filePath)
+{
+    std::fstream stream(filePath, std::fstream::in);
+    std::string line;
+
+    getline(stream, line);
+
+    // Ignore if line is commented
+    if ('#' != line.at(0))
+    {
+        auto pos = line.find(':');
+        if (pos != std::string::npos)
+        {
+            //"*.* @@<address>:<port>"
+            constexpr auto start = 6; // Skip "*.* @@"
+            auto serverAddress = line.substr(start, pos - start);
+            auto serverPort = line.substr(pos + 1);
+            NetworkClient::address(std::move(serverAddress));
+            NetworkClient::port(std::stoul(serverPort));
+        }
+    }
+}
+
 } // namespace rsyslog_config
 } // namespace phosphor