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/zlib_file.hpp b/src/zlib_file.hpp
new file mode 100644
index 0000000..5f501ab
--- /dev/null
+++ b/src/zlib_file.hpp
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright (C) 2020 YADRO
+
+#pragma once
+
+#include <zlib.h>
+
+#include <ctime>
+#include <string>
+
+/**
+ * @class ZlibFile
+ * @brief Log file writer.
+ */
+class ZlibFile
+{
+ public:
+ /**
+ * @brief Constructor create new file for writing logs.
+ *
+ * @param[in] fileName path to the file
+ *
+ * @throw ZlibException in case of errors
+ */
+ ZlibFile(const std::string& fileName);
+
+ ~ZlibFile();
+
+ ZlibFile(const ZlibFile&) = delete;
+ ZlibFile& operator=(const ZlibFile&) = delete;
+
+ /**
+ * @brief Close file.
+ *
+ * @throw ZlibException in case of errors
+ */
+ void close();
+
+ /**
+ * @brief Write single log message to the file.
+ *
+ * @param[in] timeStamp time stamp of the log message
+ * @param[in] message log message text
+ *
+ * @throw ZlibException in case of errors
+ */
+ void write(const tm& timeStamp, const std::string& message) const;
+
+ private:
+ /** @brief File name. */
+ std::string fileName;
+ /** @brief zLib file descriptor. */
+ gzFile fd;
+};