summaryrefslogtreecommitdiffstats
path: root/phosphor-rsyslog-config/server-conf.hpp
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-10-26 18:14:00 -0700
committerPatrick Venture <venture@google.com>2018-10-26 18:16:27 -0700
commitf18bf836d206b1bc5b4fd849127a2e706eddf0aa (patch)
tree5c61f65861a2350f84080f21c6b996d33d0c2ab3 /phosphor-rsyslog-config/server-conf.hpp
parentaabb92ef56c4faa8f05487e9fcdf83f1053f1a22 (diff)
downloadphosphor-logging-f18bf836d206b1bc5b4fd849127a2e706eddf0aa.tar.gz
phosphor-logging-f18bf836d206b1bc5b4fd849127a2e706eddf0aa.zip
add .clang-format
Change-Id: I2c36b7886a25d0b235693b0776019d29608e1d52 Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'phosphor-rsyslog-config/server-conf.hpp')
-rw-r--r--phosphor-rsyslog-config/server-conf.hpp172
1 files changed, 85 insertions, 87 deletions
diff --git a/phosphor-rsyslog-config/server-conf.hpp b/phosphor-rsyslog-config/server-conf.hpp
index 8660416..8e1b2cb 100644
--- a/phosphor-rsyslog-config/server-conf.hpp
+++ b/phosphor-rsyslog-config/server-conf.hpp
@@ -1,10 +1,11 @@
#pragma once
+#include "xyz/openbmc_project/Network/Client/server.hpp"
+
+#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <string>
-#include <phosphor-logging/log.hpp>
-#include "xyz/openbmc_project/Network/Client/server.hpp"
namespace phosphor
{
@@ -24,96 +25,93 @@ namespace sdbusRule = sdbusplus::bus::match::rules;
*/
class Server : public Iface
{
- public:
- Server() = delete;
- Server(const Server&) = delete;
- Server& operator=(const Server&) = delete;
- Server(Server&&) = delete;
- Server& operator=(Server&&) = delete;
- virtual ~Server() = default;
-
- /** @brief Constructor to put object onto bus at a dbus path.
- * @param[in] bus - Bus to attach to.
- * @param[in] path - Path to attach at.
- * @param[in] filePath - rsyslog remote logging config file
- */
- Server(sdbusplus::bus::bus& bus,
- const std::string& path,
- const char* filePath) :
- Iface(bus, path.c_str(), true),
- configFilePath(filePath),
- hostnameChange(
- bus,
- sdbusRule::propertiesChanged(
- "/org/freedesktop/hostname1", "org.freedesktop.hostname1"),
- std::bind(std::mem_fn(&Server::hostnameChanged),
- this, std::placeholders::_1))
+ public:
+ Server() = delete;
+ Server(const Server&) = delete;
+ Server& operator=(const Server&) = delete;
+ Server(Server&&) = delete;
+ Server& operator=(Server&&) = delete;
+ virtual ~Server() = default;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] path - Path to attach at.
+ * @param[in] filePath - rsyslog remote logging config file
+ */
+ Server(sdbusplus::bus::bus& bus, const std::string& path,
+ const char* filePath) :
+ Iface(bus, path.c_str(), true),
+ configFilePath(filePath),
+ hostnameChange(
+ bus,
+ sdbusRule::propertiesChanged("/org/freedesktop/hostname1",
+ "org.freedesktop.hostname1"),
+ std::bind(std::mem_fn(&Server::hostnameChanged), this,
+ std::placeholders::_1))
+ {
+ try
{
- try
- {
- restore(configFilePath.c_str());
- }
- catch(const std::exception& e)
- {
- log<level::ERR>(e.what());
- }
-
- emit_object_added();
+ restore(configFilePath.c_str());
}
-
- using NetworkClient::address;
- using NetworkClient::port;
-
- /** @brief Override that updates rsyslog config file as well
- * @param[in] value - remote server address
- * @returns value of changed address
- */
- virtual std::string address(std::string value) override;
-
- /** @brief Override that updates rsyslog config file as well
- * @param[in] value - remote server port
- * @returns value of changed port
- */
- virtual uint16_t port(uint16_t value) override;
-
- /** @brief Restart rsyslog's systemd unit
- */
- virtual void restart();
-
- private:
- /** @brief Update remote server address and port in
- * rsyslog config file.
- * @param[in] serverAddress - remote server address
- * @param[in] serverPort - remote server port
- * @param[in] filePath - rsyslog config file path
- */
- void writeConfig(
- const std::string& serverAddress,
- uint16_t serverPort,
- const char* filePath);
-
- /** @brief Checks if input IP address is valid (uses getaddrinfo)
- * @param[in] address - server address
- * @returns true if valid, false otherwise
- */
- bool addressValid(const std::string& address);
-
- /** @brief Populate existing config into D-Bus properties
- * @param[in] filePath - rsyslog config file path
- */
- void restore(const char* filePath);
-
- std::string configFilePath{};
-
- /** @brief React to hostname change
- * @param[in] msg - sdbusplus message
- */
- void hostnameChanged(sdbusplus::message::message& msg)
+ catch (const std::exception& e)
{
- restart();
+ log<level::ERR>(e.what());
}
- sdbusplus::bus::match_t hostnameChange;
+ emit_object_added();
+ }
+
+ using NetworkClient::address;
+ using NetworkClient::port;
+
+ /** @brief Override that updates rsyslog config file as well
+ * @param[in] value - remote server address
+ * @returns value of changed address
+ */
+ virtual std::string address(std::string value) override;
+
+ /** @brief Override that updates rsyslog config file as well
+ * @param[in] value - remote server port
+ * @returns value of changed port
+ */
+ virtual uint16_t port(uint16_t value) override;
+
+ /** @brief Restart rsyslog's systemd unit
+ */
+ virtual void restart();
+
+ private:
+ /** @brief Update remote server address and port in
+ * rsyslog config file.
+ * @param[in] serverAddress - remote server address
+ * @param[in] serverPort - remote server port
+ * @param[in] filePath - rsyslog config file path
+ */
+ void writeConfig(const std::string& serverAddress, uint16_t serverPort,
+ const char* filePath);
+
+ /** @brief Checks if input IP address is valid (uses getaddrinfo)
+ * @param[in] address - server address
+ * @returns true if valid, false otherwise
+ */
+ bool addressValid(const std::string& address);
+
+ /** @brief Populate existing config into D-Bus properties
+ * @param[in] filePath - rsyslog config file path
+ */
+ void restore(const char* filePath);
+
+ std::string configFilePath{};
+
+ /** @brief React to hostname change
+ * @param[in] msg - sdbusplus message
+ */
+ void hostnameChanged(sdbusplus::message::message& msg)
+ {
+ restart();
+ }
+
+ sdbusplus::bus::match_t hostnameChange;
};
} // namespace rsyslog_config
OpenPOWER on IntegriCloud