Fix a bug for zero arg EventLog entries
When the EventLog is pushed to the files, there is a case where we can't
know the difference between a message with zero args, and a message with
one arg, where the first arg is empty string. They both show up in the
log similar to
<DATE> OpenBMC.MessageId,
This causes Redfish to return a LogEntry with one empty argument.
This commit uses the registry information to resize the args array
appropriately, dependent on what message is being sent, effectively
ignoring what the developer put into their logs. If there's too many
args, they're removed, if there's not enough args, empty args are added.
Tested:
GET /redfish/v1/Systems/system/LogServices/EventLog/Entries
Returned an entry with the properties:
"Message": "Power restore policy applied.",
"MessageArgs": [],
"MessageId": "OpenBMC.0.1.PowerRestorePolicyApplied",
Which appear to be correct.
Change-Id: I7d6f150bddad88d1c3da9d0424268d1eac902145
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 678ab43..72930cc 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1315,6 +1315,8 @@
std::vector<std::string_view> messageArgs(logEntryIter,
logEntryFields.end());
+ messageArgs.resize(message->numberOfArgs);
+
std::string msg = redfish::registries::fillMessageArgs(messageArgs,
message->message);
if (msg.empty())