Update SEL Logger add function to accept additional metadata
This change makes the selAddSystemRecord() function a template
that can take additional metadata and pass it on to
sd_journal_send().
Tested: Sent various test messages that include additional
metadata and verified that it is correctly added to the journal
entry.
Change-Id: I43b4216d01124ce81915c092d34797b714dba787
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/include/sel_logger.hpp b/include/sel_logger.hpp
index aa9d8d6..28214e3 100644
--- a/include/sel_logger.hpp
+++ b/include/sel_logger.hpp
@@ -32,8 +32,8 @@
static constexpr size_t selEvtDataMaxSize = 3;
static constexpr size_t selOemDataMaxSize = 13;
-static uint16_t selAddSystemRecord(const std::string &message,
- const std::string &path,
- const std::vector<uint8_t> &selData,
- const bool &assert,
- const uint16_t &genId = selBMCGenID);
+template <typename... T>
+static uint16_t
+ selAddSystemRecord(const std::string &message, const std::string &path,
+ const std::vector<uint8_t> &selData, const bool &assert,
+ const uint16_t &genId, T &&... metadata);
diff --git a/include/threshold_event_monitor.hpp b/include/threshold_event_monitor.hpp
index de3a867..0b75114 100644
--- a/include/threshold_event_monitor.hpp
+++ b/include/threshold_event_monitor.hpp
@@ -191,7 +191,7 @@
" Threshold=" + std::to_string(thresholdVal));
selAddSystemRecord(journalMsg, std::string(msg.get_path()), eventData,
- assert);
+ assert, selBMCGenID);
};
sdbusplus::bus::match::match thresholdEventMatcher(
static_cast<sdbusplus::bus::bus &>(*conn),
diff --git a/src/sel_logger.cpp b/src/sel_logger.cpp
index 5903244..22ee2f1 100644
--- a/src/sel_logger.cpp
+++ b/src/sel_logger.cpp
@@ -104,10 +104,11 @@
hexStr = stream.str();
}
-static uint16_t selAddSystemRecord(const std::string &message,
- const std::string &path,
- const std::vector<uint8_t> &selData,
- const bool &assert, const uint16_t &genId)
+template <typename... T>
+static uint16_t
+ selAddSystemRecord(const std::string &message, const std::string &path,
+ const std::vector<uint8_t> &selData, const bool &assert,
+ const uint16_t &genId, T &&... metadata)
{
// Only 3 bytes of SEL event data are allowed in a system record
if (selData.size() > selEvtDataMaxSize)
@@ -118,12 +119,13 @@
toHexStr(selData, selDataStr);
unsigned int recordId = getNewRecordId();
- sd_journal_send(
- "MESSAGE=%s", message.c_str(), "PRIORITY=%i", selPriority,
- "MESSAGE_ID=%s", selMessageId, "IPMI_SEL_RECORD_ID=%d", recordId,
- "IPMI_SEL_RECORD_TYPE=%x", selSystemType, "IPMI_SEL_GENERATOR_ID=%x",
- genId, "IPMI_SEL_SENSOR_PATH=%s", path.c_str(), "IPMI_SEL_EVENT_DIR=%x",
- assert, "IPMI_SEL_DATA=%s", selDataStr.c_str(), NULL);
+ sd_journal_send("MESSAGE=%s", message.c_str(), "PRIORITY=%i", selPriority,
+ "MESSAGE_ID=%s", selMessageId, "IPMI_SEL_RECORD_ID=%d",
+ recordId, "IPMI_SEL_RECORD_TYPE=%x", selSystemType,
+ "IPMI_SEL_GENERATOR_ID=%x", genId,
+ "IPMI_SEL_SENSOR_PATH=%s", path.c_str(),
+ "IPMI_SEL_EVENT_DIR=%x", assert, "IPMI_SEL_DATA=%s",
+ selDataStr.c_str(), std::forward<T>(metadata)..., NULL);
return recordId;
}