Add multi-host support
This refactoring includes:
- added multi-host mode support;
- added support for graceful shutdown of the service;
- added support to flush the log buffer as it fills;
- D-Bus service xyz.openbmc_project.HostLogger replaced with SIGUSR1
signal handler;
- self diagnostic messages now registered via phosphor-logging;
- added unit tests;
- build system migrated from autotools to meson;
- source code aligned with OpenBMC conventions.
Change-Id: If6c1dfde278af685d8563450543a6587a282c7e4
Signed-off-by: Artem Senichev <a.senichev@yadro.com>
diff --git a/src/service.hpp b/src/service.hpp
new file mode 100644
index 0000000..86c02c7
--- /dev/null
+++ b/src/service.hpp
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright (C) 2020 YADRO
+
+#pragma once
+
+#include "config.hpp"
+#include "dbus_loop.hpp"
+#include "file_storage.hpp"
+#include "host_console.hpp"
+#include "log_buffer.hpp"
+
+/**
+ * @class Service
+ * @brief Log service: watches for events and handles them.
+ */
+class Service
+{
+ public:
+ /**
+ * @brief Constructor.
+ *
+ * @param[in] config service configuration
+ *
+ * @throw std::exception in case of errors
+ */
+ Service(const Config& config);
+
+ /**
+ * @brief Run the service.
+ *
+ * @throw std::exception in case of errors
+ */
+ void run();
+
+ private:
+ /**
+ * @brief Flush log buffer to a file.
+ */
+ void flush();
+
+ /**
+ * @brief Read data from host console and put it into the log buffer.
+ */
+ void readConsole();
+
+ private:
+ /** @brief Service configuration. */
+ const Config& config;
+ /** @brief D-Bus event loop. */
+ DbusLoop dbusLoop;
+ /** @brief Host console connection. */
+ HostConsole hostConsole;
+ /** @brief Intermediate storage: container for parsed log messages. */
+ LogBuffer logBuffer;
+ /** @brief Persistent storage. */
+ FileStorage fileStorage;
+};