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/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;
}