Add the stream mode

The stream mode behaves differently in versus the existing buffer mode.

1. It leverages rsyslog to persist logs;
2. It leverages logrotate to rotate and compress logs;
3. It persists logs as soon as they are collected.

Add configuration options to choose modes at start up time. When stream
mode is disabled, no difference compared to the existing service.

See README.md for details.

This change also adds mock classes for unit test purpose.

Change-Id: Ic7d02e826c7d9372621c096c6e768e6216974150
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
diff --git a/src/main.cpp b/src/main.cpp
index cb8d2bc..756440f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,12 +1,16 @@
 // SPDX-License-Identifier: Apache-2.0
 // Copyright (C) 2020 YADRO
 
+#include "buffer_service.hpp"
 #include "config.hpp"
 #include "service.hpp"
+#include "stream_service.hpp"
 #include "version.hpp"
 
 #include <getopt.h>
 
+#include <phosphor-logging/log.hpp>
+
 /** @brief Print version info. */
 static void printVersion()
 {
@@ -63,9 +67,28 @@
 
     try
     {
-        Config cfg;
-        Service svc(cfg);
-        svc.run();
+        Config config;
+        DbusLoop dbus_loop;
+        HostConsole host_console(config.socketId);
+        using phosphor::logging::level;
+        using phosphor::logging::log;
+        if (config.mode == Mode::streamMode)
+        {
+            log<level::INFO>("HostLogger is in stream mode.");
+            StreamService service(config.streamDestination, dbus_loop,
+                                  host_console);
+            service.run();
+        }
+        else
+        {
+            log<level::INFO>("HostLogger is in buffer mode.");
+            LogBuffer logBuffer(config.bufMaxSize, config.bufMaxTime);
+            FileStorage fileStorage(config.outDir, config.socketId,
+                                    config.maxFiles);
+            BufferService service(config, dbus_loop, host_console, logBuffer,
+                                  fileStorage);
+            service.run();
+        }
     }
     catch (const std::exception& ex)
     {