Enable bmcweb dynamic logging

Create a CLI app called "bmcweb" that can set logging levels on
"bmcwebd", the new bmcweb daemon.  Create a dbus connection to set log
level using the CLI app Define the "setLogLevel" method on dbus to
control logging level in bmcwebd Add logic to move logging level from
build option to dynamic overloading

Reason: bmcweb picks up logging level as a compile flag. We want it to
be more flexible to debug errors in the field. Using the bmcweb CLI
app, we can set log levels on the bmcweb daemon during runtime.
Splitting bmcweb.

For example, to set logging level to INFO on the target:
bmcweb -l INFO

Change-Id: I7192e4d0ac7aa3a91babecc473521be27ea8acd1
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/src/webserver_cli.cpp b/src/webserver_cli.cpp
new file mode 100644
index 0000000..e17d800
--- /dev/null
+++ b/src/webserver_cli.cpp
@@ -0,0 +1,56 @@
+#include "boost_formatters.hpp"
+#include "logging.hpp"
+
+#include <CLI/CLI.hpp>
+#include <boost/asio/io_context.hpp>
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/bus.hpp>
+
+#include <string>
+
+// Override default log option:
+static void cliLogLevel(const std::string& logLevel)
+{
+    crow::getBmcwebCurrentLoggingLevel() = crow::getLogLevelFromName(logLevel);
+}
+
+int main(int argc, char** argv) noexcept(false)
+{
+    CLI::App app("BMCWeb SetLogLevel CLI");
+
+    cliLogLevel("INFO");
+
+    // Define sdbus interfaces:
+    std::string service = "xyz.openbmc_project.bmcweb";
+    std::string path = "/xyz/openbmc_project/bmcweb";
+    std::string iface = "xyz.openbmc_project.bmcweb";
+    std::string method = "SetLogLevel";
+
+    std::string loglevel;
+    app.add_option("-l,--loglevel", loglevel, "Set bmcweb log level");
+
+    CLI11_PARSE(app, argc, argv)
+
+    BMCWEB_LOG_INFO("Working on log-level: {}", loglevel);
+
+    // Set up dbus connection:
+    boost::asio::io_context io;
+    auto conn = std::make_shared<sdbusplus::asio::connection>(io);
+
+    // Attempt to async_call to set logging level
+    conn->async_method_call(
+        [&io](boost::system::error_code& ec) mutable {
+        if (ec)
+        {
+            BMCWEB_LOG_ERROR("SetLogLevel returned error with {}", ec);
+            return;
+        }
+        BMCWEB_LOG_INFO("Successfully changed log-level ");
+        io.stop();
+    },
+        service, path, iface, method, loglevel);
+
+    io.run();
+
+    return 0;
+}