summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2018-08-27 05:45:02 -0500
committerDeepak Kodihalli <dkodihal@in.ibm.com>2018-08-29 03:39:52 -0500
commit0febd26b542399cbbfe1c4c01b10a24d9cf4f860 (patch)
tree870a01847f51a2785c4b355258a5f296e9e9b446
parentc49661925b0c59a4355aca6813a85d749c21e764 (diff)
downloadphosphor-logging-0febd26b542399cbbfe1c4c01b10a24d9cf4f860.zip
phosphor-logging-0febd26b542399cbbfe1c4c01b10a24d9cf4f860.tar.gz
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>
-rw-r--r--README.md5
-rw-r--r--phosphor-rsyslog-config/server-conf.cpp26
2 files changed, 27 insertions, 4 deletions
diff --git a/README.md b/README.md
index e0ea54a..f8ab729 100644
--- a/README.md
+++ b/README.md
@@ -62,10 +62,15 @@ curl -b cjar -k -H "Content-Type: application/json" -X PUT \
https://<BMC IP address>//xyz/openbmc_project/network/config/attr/HostName
```
+#### Disabling remote logging
+Remote logging can be disabled by writing 0 to the port, or an empty string("")
+to the IP.
+
#### Changing the rsyslog server
When switching to a new server from an existing one (i.e the address, or port,
or both change), it is recommended to disable the existing configuration first.
+
## Adding application specific error YAML
* This document captures steps for adding application specific error YAML files
and generating local elog-errors.hpp header file for application use.
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 @@ namespace utils = phosphor::rsyslog_utils;
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 @@ std::string Server::address(std::string value)
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 @@ void Server::writeConfig(
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
OpenPOWER on IntegriCloud