log_manager: Cleanup main function

The design direction changed after the commit that added the
log_manager main function, so updating it to the correct usage.

Change-Id: I88459fb65ba6b8272f0f9f85b55f9f837487ffea
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/log_manager.cpp b/log_manager.cpp
index 06beaa6..c9edd7e 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -109,32 +109,5 @@
     return;
 }
 
-Manager::Manager(sdbusplus::bus::bus &&bus,
-                 const char* busname,
-                 const char* obj) :
-    details::ServerObject<details::ManagerIface>(bus, obj),
-    _bus(std::move(bus)),
-    _manager(sdbusplus::server::manager::manager(_bus, obj))
-{
-    _bus.request_name(busname);
-}
-
-void Manager::run() noexcept
-{
-    while(true)
-    {
-        try
-        {
-            _bus.process_discard();
-            _bus.wait();
-        }
-        catch (std::exception &e)
-        {
-            std::cerr << e.what() << std::endl;
-        }
-    }
-}
-
 } // namespace logging
 } // namepsace phosphor
-
diff --git a/log_manager.hpp b/log_manager.hpp
index 2b4281d..13e38d9 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include <sdbusplus/server.hpp>
+#include <sdbusplus/bus.hpp>
 #include "xyz/openbmc_project/Logging/Internal/Manager/server.hpp"
 
 namespace phosphor
@@ -23,28 +23,22 @@
  *  @details A concrete implementation for the
  *  xyz.openbmc_project.Logging.Internal.Manager DBus API.
  */
-class Manager final :
-    public details::ServerObject<details::ManagerIface>
+class Manager : public details::ServerObject<details::ManagerIface>
 {
     public:
         Manager() = delete;
         Manager(const Manager&) = delete;
         Manager& operator=(const Manager&) = delete;
-        Manager(Manager&&) = default;
-        Manager& operator=(Manager&&) = default;
-        ~Manager() = default;
+        Manager(Manager&&) = delete;
+        Manager& operator=(Manager&&) = delete;
+        virtual ~Manager() = default;
 
-        /** @brief Constructor for the Log Manager object
-         *  @param[in] bus - DBus bus to attach to.
-         *  @param[in] busname - Name of DBus bus to own.
-         *  @param[in] obj - Object path to attach to.
+        /** @brief Constructor to put object onto bus at a dbus path.
+         *  @param[in] bus - Bus to attach to.
+         *  @param[in] path - Path to attach at.
          */
-        Manager(sdbusplus::bus::bus&& bus,
-                    const char* busname,
-                    const char* obj);
-
-        /** @brief Start processing DBus messages. */
-        void run() noexcept;
+        Manager(sdbusplus::bus::bus& bus, const char* path) :
+                details::ServerObject<details::ManagerIface>(bus, path) {};
 
         /*
          * @fn commit()
@@ -57,13 +51,6 @@
          *                     error log to be committed.
          */
         void commit(uint64_t transactionId, std::string errMsg) override;
-
-    private:
-        /** @brief Persistent sdbusplus DBus bus connection. */
-        sdbusplus::bus::bus _bus;
-
-        /** @brief sdbusplus org.freedesktop.DBus.ObjectManager reference. */
-        sdbusplus::server::manager::manager _manager;
 };
 
 } // namespace logging
diff --git a/log_manager_main.cpp b/log_manager_main.cpp
index c5e426b..10b6e76 100644
--- a/log_manager_main.cpp
+++ b/log_manager_main.cpp
@@ -1,22 +1,27 @@
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server/manager.hpp>
 #include "config.h"
 #include "log_manager.hpp"
-#include <sdbusplus/bus.hpp>
-#include <cstdlib>
-#include <iostream>
-#include <exception>
 
 int main(int argc, char *argv[])
 {
-    try {
-        auto manager = phosphor::logging::Manager(
-                sdbusplus::bus::new_system(),
-                BUSNAME_LOGGING,
-                OBJ_INTERNAL);
-        manager.run();
-        exit(EXIT_SUCCESS);
+    auto bus = sdbusplus::bus::new_default();
+
+    // Add sdbusplus ObjectManager.
+    sdbusplus::server::manager::manager objManager(bus, OBJ_INTERNAL);
+
+    phosphor::logging::Manager manager(bus, OBJ_INTERNAL);
+
+    bus.request_name(BUSNAME_LOGGING);
+
+    // TODO Create error log dbus object on demand, when the Commit interface
+    // creates an error log it'd call this entry interface to create an object.
+
+    while(true)
+    {
+        bus.process_discard();
+        bus.wait();
     }
-    catch (const std::exception &e) {
-        std::cerr << e.what() << std::endl;
-    }
-    exit(EXIT_FAILURE);
+
+    return 0;
 }
diff --git a/xyz/openbmc_project/Logging/Internal/Manager/server.hpp b/xyz/openbmc_project/Logging/Internal/Manager/server.hpp
index 3bec2a9..bbbdef8 100644
--- a/xyz/openbmc_project/Logging/Internal/Manager/server.hpp
+++ b/xyz/openbmc_project/Logging/Internal/Manager/server.hpp
@@ -23,15 +23,16 @@
          *     Not allowed:
          *         - Default constructor to avoid nullptrs.
          *         - Copy operations due to internal unique_ptr.
+         *         - Move operations due to 'this' being registered as the
+         *           'context' with sdbus.
          *     Allowed:
-         *         - Move operations.
          *         - Destructor.
          */
         Manager() = delete;
         Manager(const Manager&) = delete;
         Manager& operator=(const Manager&) = delete;
-        Manager(Manager&&) = default;
-        Manager& operator=(Manager&&) = default;
+        Manager(Manager&&) = delete;
+        Manager& operator=(Manager&&) = delete;
         virtual ~Manager() = default;
 
         /** @brief Constructor to put object onto bus at a dbus path.