phosphor-ryslog-conf: add way to disable logging

Remote logging via rsyslog can be disabled by writing 0 to the port, or
an empty string to the address.

Change-Id: I50bce3ff008af1b9c488a09a2b36c01abbe5497d
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 16c792d..1372e85 100644
--- a/phosphor-rsyslog-config/server-conf.cpp
+++ b/phosphor-rsyslog-config/server-conf.cpp
@@ -11,6 +11,12 @@
 
 std::string Server::address(std::string value)
 {
+    auto serverAddress = address();
+    if (serverAddress == value)
+    {
+        return serverAddress;
+    }
+
     writeConfig(value, port(), configFilePath.c_str());
     auto result = NetworkClient::address(value);
     return result;
@@ -18,6 +24,12 @@
 
 uint16_t Server::port(uint16_t value)
 {
+    auto serverPort = port();
+    if (serverPort == value)
+    {
+        return serverPort;
+    }
+
     writeConfig(address(), value, configFilePath.c_str());
     auto result = NetworkClient::port(value);
     return result;
@@ -28,14 +40,20 @@
                  uint16_t serverPort,
                  const char* filePath)
 {
+    std::fstream stream(filePath, std::fstream::out);
+
     if (serverPort && !serverAddress.empty())
     {
-        std::fstream stream(filePath, std::fstream::out);
-        // write '*.* @@remote-host:port'
+        // write '*.* @@<remote-host>:<port>'
         stream << "*.* @@" << serverAddress << ":" << serverPort;
-
-        utils::restart();
     }
+    else // this is a disable request
+    {
+        // write '#*.* @@remote-host:port'
+        stream << "#*.* @@remote-host:port";
+    }
+
+    utils::restart();
 }
 
 } // namespace rsyslog_config