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/test/config_test.cpp b/test/config_test.cpp
new file mode 100644
index 0000000..15fbc4b
--- /dev/null
+++ b/test/config_test.cpp
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright (C) 2020 YADRO
+
+#include "config.hpp"
+
+#include <gtest/gtest.h>
+
+// Names of environment variables
+static const char* SOCKET_ID = "SOCKET_ID";
+static const char* BUF_MAXSIZE = "BUF_MAXSIZE";
+static const char* BUF_MAXTIME = "BUF_MAXTIME";
+static const char* FLUSH_FULL = "FLUSH_FULL";
+static const char* HOST_STATE = "HOST_STATE";
+static const char* OUT_DIR = "OUT_DIR";
+static const char* MAX_FILES = "MAX_FILES";
+
+/**
+ * @class ConfigTest
+ * @brief Configuration tests.
+ */
+class ConfigTest : public ::testing::Test
+{
+  protected:
+    void SetUp() override
+    {
+        resetEnv();
+    }
+
+    void TearDown() override
+    {
+        resetEnv();
+    }
+
+    /** @brief Reset environment variables. */
+    void resetEnv() const
+    {
+        unsetenv(SOCKET_ID);
+        unsetenv(BUF_MAXSIZE);
+        unsetenv(BUF_MAXTIME);
+        unsetenv(FLUSH_FULL);
+        unsetenv(HOST_STATE);
+        unsetenv(OUT_DIR);
+        unsetenv(MAX_FILES);
+    }
+};
+
+TEST_F(ConfigTest, Defaults)
+{
+    Config cfg;
+    EXPECT_STREQ(cfg.socketId, "");
+    EXPECT_EQ(cfg.bufMaxSize, 3000);
+    EXPECT_EQ(cfg.bufMaxTime, 0);
+    EXPECT_EQ(cfg.bufFlushFull, false);
+    EXPECT_STREQ(cfg.hostState, "/xyz/openbmc_project/state/host0");
+    EXPECT_STREQ(cfg.outDir, "/var/lib/obmc/hostlogs");
+    EXPECT_EQ(cfg.maxFiles, 10);
+}
+
+TEST_F(ConfigTest, Load)
+{
+    setenv(SOCKET_ID, "id123", 1);
+    setenv(BUF_MAXSIZE, "1234", 1);
+    setenv(BUF_MAXTIME, "4321", 1);
+    setenv(FLUSH_FULL, "true", 1);
+    setenv(HOST_STATE, "host123", 1);
+    setenv(OUT_DIR, "path123", 1);
+    setenv(MAX_FILES, "1122", 1);
+
+    Config cfg;
+    EXPECT_STREQ(cfg.socketId, "id123");
+    EXPECT_EQ(cfg.bufMaxSize, 1234);
+    EXPECT_EQ(cfg.bufMaxTime, 4321);
+    EXPECT_EQ(cfg.bufFlushFull, true);
+    EXPECT_STREQ(cfg.hostState, "host123");
+    EXPECT_STREQ(cfg.outDir, "path123");
+    EXPECT_EQ(cfg.maxFiles, 1122);
+}
+
+TEST_F(ConfigTest, InvalidNumeric)
+{
+    setenv(BUF_MAXSIZE, "-1234", 1);
+    ASSERT_THROW(Config(), std::invalid_argument);
+}
+
+TEST_F(ConfigTest, InvalidBoolean)
+{
+    setenv(FLUSH_FULL, "invalid", 1);
+    ASSERT_THROW(Config(), std::invalid_argument);
+}
+
+TEST_F(ConfigTest, InvalidConfig)
+{
+    setenv(BUF_MAXSIZE, "0", 1);
+    setenv(BUF_MAXTIME, "0", 1);
+    setenv(FLUSH_FULL, "true", 1);
+    ASSERT_THROW(Config(), std::invalid_argument);
+}