lg2: commit: simplify commit functions

Eliminate the template indirection for the commit function in favor
of a base-class overload.  There was previously a public template
specialization of `lg2::commit` and a private base-class implementation
(in the `details` namespace).  The template implementations provided
no stronger type-checking, since it was already a concept requiring
inheritance from the base-class.  The template precluded simple code
such as:

```cpp
    try
    {
        //...
    }
    catch (const sdbusplus::exception::generated_event_base& e)
    {
        lg2::commit(e);
    }
```

By making the base-class types public, rather than hidden in the
details namespace, and removing the templates, the code is simpler
and more usable.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If0a3e1331eff36aec4b9f7e4950636360d59306e
diff --git a/lib/include/phosphor-logging/commit.hpp b/lib/include/phosphor-logging/commit.hpp
index aa34df3..d3b291c 100644
--- a/lib/include/phosphor-logging/commit.hpp
+++ b/lib/include/phosphor-logging/commit.hpp
@@ -1,6 +1,5 @@
 #pragma once
 
-#include <phosphor-logging/lg2/commit.hpp>
 #include <sdbusplus/async.hpp>
 #include <sdbusplus/exception.hpp>
 
@@ -8,31 +7,22 @@
 {
 /** Commit a generated event/error.
  *
- *  @param t - The event to commit.
+ *  @param e - The event to commit.
  *  @return The object path of the resulting event.
  *
  *  Note: Similar to elog(), this will use the default dbus connection to
  *  perform the operation.
  */
-template <typename T>
-    requires std::is_base_of_v<sdbusplus::exception::generated_event_base, T>
-auto commit(T&& t) -> sdbusplus::message::object_path
-{
-    return details::commit(std::forward<T>(t));
-}
+auto commit(sdbusplus::exception::generated_event_base&& e)
+    -> sdbusplus::message::object_path;
 
 /** Commit a generated event/error (using async context).
  *
  *  @param ctx - The async context to use.
- *  @param t - The event to commit.
+ *  @param e - The event to commit.
  *  @return The object path of the resulting event.
  */
-template <typename T>
-    requires std::is_base_of_v<sdbusplus::exception::generated_event_base, T>
 auto commit(sdbusplus::async::context& ctx,
-            T&& t) -> sdbusplus::async::task<sdbusplus::message::object_path>
-{
-    return details::commit(ctx, std::forward<T>(t));
-}
-
+            sdbusplus::exception::generated_event_base&& e)
+    -> sdbusplus::async::task<sdbusplus::message::object_path>;
 } // namespace lg2
diff --git a/lib/include/phosphor-logging/lg2/commit.hpp b/lib/include/phosphor-logging/lg2/commit.hpp
deleted file mode 100644
index 47c5be1..0000000
--- a/lib/include/phosphor-logging/lg2/commit.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#pragma once
-
-#include <sdbusplus/async.hpp>
-#include <sdbusplus/exception.hpp>
-
-namespace lg2::details
-{
-
-/* Non-template versions of the commit functions */
-
-auto commit(sdbusplus::exception::generated_event_base&& t)
-    -> sdbusplus::message::object_path;
-
-auto commit(sdbusplus::async::context& ctx,
-            sdbusplus::exception::generated_event_base&& t)
-    -> sdbusplus::async::task<sdbusplus::message::object_path>;
-
-} // namespace lg2::details
diff --git a/lib/lg2_commit.cpp b/lib/lg2_commit.cpp
index 4f37cb6..d5ae41b 100644
--- a/lib/lg2_commit.cpp
+++ b/lib/lg2_commit.cpp
@@ -5,14 +5,16 @@
 #include <sys/syslog.h>
 
 #include <nlohmann/json.hpp>
+#include <phosphor-logging/commit.hpp>
 #include <phosphor-logging/lg2.hpp>
-#include <phosphor-logging/lg2/commit.hpp>
 #include <sdbusplus/async.hpp>
 #include <sdbusplus/exception.hpp>
 #include <xyz/openbmc_project/Logging/Create/client.hpp>
 #include <xyz/openbmc_project/Logging/Entry/client.hpp>
 
-namespace lg2::details
+namespace lg2
+{
+namespace details
 {
 
 using Create = sdbusplus::client::xyz::openbmc_project::logging::Create<>;
@@ -97,52 +99,6 @@
     return result;
 }
 
-auto commit(sdbusplus::exception::generated_event_base&& t)
-    -> sdbusplus::message::object_path
-{
-    if constexpr (LG2_COMMIT_JOURNAL)
-    {
-        lg2::error("OPENBMC_MESSAGE_ID={DATA}", "DATA", t.to_json().dump());
-    }
-
-    if constexpr (LG2_COMMIT_DBUS)
-    {
-        auto b = sdbusplus::bus::new_default();
-        auto m =
-            b.new_method_call(Create::default_service, Create::instance_path,
-                              Create::interface, "Create");
-
-        m.append(t.name(), severity_from_syslog(t.severity()),
-                 data_from_json(t));
-
-        auto reply = b.call(m);
-
-        return reply.unpack<sdbusplus::message::object_path>();
-    }
-
-    return {};
-}
-
-auto commit(sdbusplus::async::context& ctx,
-            sdbusplus::exception::generated_event_base&& t)
-    -> sdbusplus::async::task<sdbusplus::message::object_path>
-{
-    if constexpr (LG2_COMMIT_JOURNAL)
-    {
-        lg2::error("OPENBMC_MESSAGE_ID={DATA}", "DATA", t.to_json().dump());
-    }
-
-    if constexpr (LG2_COMMIT_DBUS)
-    {
-        co_return co_await Create(ctx)
-            .service(Create::default_service)
-            .path(Create::instance_path)
-            .create(t.name(), severity_from_syslog(t.severity()),
-                    data_from_json(t));
-    }
-    co_return {};
-}
-
 auto extractEvent(sdbusplus::exception::generated_event_base&& t)
     -> std::tuple<std::string, Entry::Level, std::vector<std::string>>
 {
@@ -158,4 +114,56 @@
             std::move(additional_data)};
 }
 
-} // namespace lg2::details
+} // namespace details
+
+auto commit(sdbusplus::exception::generated_event_base&& t)
+    -> sdbusplus::message::object_path
+{
+    if constexpr (LG2_COMMIT_JOURNAL)
+    {
+        lg2::error("OPENBMC_MESSAGE_ID={DATA}", "DATA", t.to_json().dump());
+    }
+
+    if constexpr (LG2_COMMIT_DBUS)
+    {
+        using details::Create;
+
+        auto b = sdbusplus::bus::new_default();
+        auto m =
+            b.new_method_call(Create::default_service, Create::instance_path,
+                              Create::interface, "Create");
+
+        m.append(t.name(), details::severity_from_syslog(t.severity()),
+                 details::data_from_json(t));
+
+        auto reply = b.call(m);
+
+        return reply.unpack<sdbusplus::message::object_path>();
+    }
+
+    return {};
+}
+
+auto commit(sdbusplus::async::context& ctx,
+            sdbusplus::exception::generated_event_base&& t)
+    -> sdbusplus::async::task<sdbusplus::message::object_path>
+{
+    using details::Create;
+
+    if constexpr (LG2_COMMIT_JOURNAL)
+    {
+        lg2::error("OPENBMC_MESSAGE_ID={DATA}", "DATA", t.to_json().dump());
+    }
+
+    if constexpr (LG2_COMMIT_DBUS)
+    {
+        co_return co_await Create(ctx)
+            .service(Create::default_service)
+            .path(Create::instance_path)
+            .create(t.name(), details::severity_from_syslog(t.severity()),
+                    details::data_from_json(t));
+    }
+    co_return {};
+}
+
+} // namespace lg2
diff --git a/log_create_main.cpp b/log_create_main.cpp
index 4347152..9d6b569 100644
--- a/log_create_main.cpp
+++ b/log_create_main.cpp
@@ -35,7 +35,7 @@
     }
     catch (sdbusplus::exception::generated_event_base& e)
     {
-        auto path = lg2::details::commit(std::move(e));
+        auto path = lg2::commit(std::move(e));
         std::cout << path.str << std::endl;
         return 0;
     }