lg2: commit: extract source location information and add to event

sdbusplus will add PID and std::source_location information, from
the event origination point, to the event.  Extract this and add
it to the event.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I6364ba0f74231fca2815c770bc3e56c2780d199e
diff --git a/lib/lg2_commit.cpp b/lib/lg2_commit.cpp
index 60dd30e..4d75594 100644
--- a/lib/lg2_commit.cpp
+++ b/lib/lg2_commit.cpp
@@ -56,6 +56,36 @@
     auto j = t.to_json()[t.name()];
     for (const auto& item : j.items())
     {
+        // Special cases for the "_SOURCE" fields, which contain debug
+        // information about the origin of the event.
+        if (item.key() == "_SOURCE")
+        {
+            for (const auto& source_item : item.value().items())
+            {
+                if (source_item.key() == "PID")
+                {
+                    result.emplace("_PID", source_item.value().dump());
+                    continue;
+                }
+                if (source_item.key() == "FILE")
+                {
+                    result.emplace("_CODE_FILE", source_item.value());
+                    continue;
+                }
+                if (source_item.key() == "FUNCTION")
+                {
+                    result.emplace("_CODE_FUNC", source_item.value());
+                    continue;
+                }
+                if (source_item.key() == "LINE")
+                {
+                    result.emplace("_CODE_LINE", source_item.value().dump());
+                    continue;
+                }
+            }
+            continue;
+        }
+
         result.emplace(item.key(), item.value().dump());
     }