From c05bba459941ae17aa9508529ccd0284e5300213 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Wed, 28 Jun 2023 08:33:29 -0700 Subject: 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 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 --- redfish-core/lib/log_services.hpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'redfish-core/lib') diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 678ab43eaf..72930cc79f 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -1315,6 +1315,8 @@ static LogParseError std::vector messageArgs(logEntryIter, logEntryFields.end()); + messageArgs.resize(message->numberOfArgs); + std::string msg = redfish::registries::fillMessageArgs(messageArgs, message->message); if (msg.empty()) -- cgit v1.2.3