blob: 16c792d4d4eb52fb8824805e931a9e3a5a71b244 [file] [log] [blame]
Deepak Kodihallic4966192018-08-23 02:19:58 -05001#include "server-conf.hpp"
2#include "utils.hpp"
3#include <fstream>
4
5namespace phosphor
6{
7namespace rsyslog_config
8{
9
10namespace utils = phosphor::rsyslog_utils;
11
12std::string Server::address(std::string value)
13{
14 writeConfig(value, port(), configFilePath.c_str());
15 auto result = NetworkClient::address(value);
16 return result;
17}
18
19uint16_t Server::port(uint16_t value)
20{
21 writeConfig(address(), value, configFilePath.c_str());
22 auto result = NetworkClient::port(value);
23 return result;
24}
25
26void Server::writeConfig(
27 const std::string& serverAddress,
28 uint16_t serverPort,
29 const char* filePath)
30{
31 if (serverPort && !serverAddress.empty())
32 {
33 std::fstream stream(filePath, std::fstream::out);
34 // write '*.* @@remote-host:port'
35 stream << "*.* @@" << serverAddress << ":" << serverPort;
36
37 utils::restart();
38 }
39}
40
41} // namespace rsyslog_config
42} // namespace phosphor