Log transaction id on each journal entry

For each journal entry, add the transaction id for the process
that called the log interface. This will be used to identify all
the journal entries associated with a dbus message.

Change-Id: Id934253bd77a517315e6cdba01a8ac819ad95b52
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index ea96862..49c54f0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,8 +20,10 @@
 CLEANFILES=elog-gen.hpp
 
 # systemd required for journal interfaces
-logging_test_LDFLAGS = $(SYSTEMD_LIBS)
-phosphor_log_manager_LDFLAGS = $(SYSTEMD_LIBS)
+logging_test_LDFLAGS = $(SYSTEMD_LIBS) $(SDBUSPLUS_LIBS)
+logging_test_CXXFLAGS = $(SYSTEMD_CFLAGS) $(SDBUSPLUS_CFLAGS)
+phosphor_log_manager_LDFLAGS = $(SYSTEMD_LIBS) $(SDBUSPLUS_LIBS)
+phosphor_log_manager_CXXFLAGS = $(SYSTEMD_CFLAGS) $(SDBUSPLUS_CFLAGS)
 
 ELOG_MAKO ?= elog-gen-template.mako.hpp
 ELOG_YAML_DIR ?= tools/example/xyz/openbmc_project/Example/
diff --git a/configure.ac b/configure.ac
index 82f77a2..4d47f3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,8 @@
 LT_INIT
 
 PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221])
+PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],,
+    AC_MSG_ERROR(["Requires sdbusplus package."]))
 
 AC_CHECK_HEADER(systemd/sd-journal.h, ,[AC_MSG_ERROR([Could not find \
 systemd/sd-journal.h...systemd developement package required])])
diff --git a/log.hpp b/log.hpp
index 1f1031c..a5ba738 100644
--- a/log.hpp
+++ b/log.hpp
@@ -18,6 +18,7 @@
 
 #include <tuple>
 #include <systemd/sd-journal.h>
+#include <sdbusplus/server/transaction.hpp>
 
 namespace phosphor
 {
@@ -115,7 +116,7 @@
 } // namespace details
 
 template <level L, typename Msg, typename ...Entry>
-void log(Msg msg, Entry... entry)
+void log(Msg msg, Entry... e)
 {
     static_assert((std::is_same<const char*, std::decay_t<Msg>>::value ||
                    std::is_same<char*, std::decay_t<Msg>>::value),
@@ -124,9 +125,13 @@
     constexpr const char *msg_str = "MESSAGE=%s";
     const auto msg_tuple = std::make_tuple(msg_str, std::forward<Msg>(msg));
 
+    constexpr auto transactionStr = "TRANSACTION_ID=%lld";
+    auto transactionId = sdbusplus::server::transaction::get_id();
+
     auto log_tuple = std::tuple_cat(details::prio<L>(),
                                     msg_tuple,
-                                    std::forward<Entry>(entry)...);
+                                    entry(transactionStr, transactionId),
+                                    std::forward<Entry>(e)...);
     details::log(log_tuple);
 }
 
@@ -141,4 +146,3 @@
 } // namespace logging
 
 } // namespace phosphor
-