Add SYSLOG_IDENTIFIER to the BMC journal Message
journalctl prints the SYSLOG_IDENTIFIER from each journal entry
to help identify the application that printed the message.
If it exists in the journal entry, this adds the SYSLOG_IDENTIFIER
to the beginning of the Redfish Message field.
Tested:
Confirmed that the Journal resource entries still display correctly
and include the SYSLOG_IDENTIFIER.
Change-Id: I0dfb020e5de13a280d5f1a64c2cf36f1d65a60fa
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 39f1de5..adc1c80 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1752,6 +1752,19 @@
// Get the Log Entry contents
int ret = 0;
+ std::string message;
+ std::string_view syslogID;
+ ret = getJournalMetadata(journal, "SYSLOG_IDENTIFIER", syslogID);
+ if (ret < 0)
+ {
+ BMCWEB_LOG_ERROR << "Failed to read SYSLOG_IDENTIFIER field: "
+ << strerror(-ret);
+ }
+ if (!syslogID.empty())
+ {
+ message += std::string(syslogID) + ": ";
+ }
+
std::string_view msg;
ret = getJournalMetadata(journal, "MESSAGE", msg);
if (ret < 0)
@@ -1759,6 +1772,7 @@
BMCWEB_LOG_ERROR << "Failed to read MESSAGE field: " << strerror(-ret);
return 1;
}
+ message += std::string(msg);
// Get the severity from the PRIORITY field
long int severity = 8; // Default to an invalid priority
@@ -1782,7 +1796,7 @@
bmcJournalLogEntryID},
{"Name", "BMC Journal Entry"},
{"Id", bmcJournalLogEntryID},
- {"Message", msg},
+ {"Message", std::move(message)},
{"EntryType", "Oem"},
{"Severity",
severity <= 2 ? "Critical" : severity <= 4 ? "Warning" : "OK"},