Add name to InventoryAdded/Removed journal entries
Add the name of the inventory item into the journal messages that print
when inventory adds or removes occur so that it's obvious which part is
being referred to.
Journal output:
entity-manager[3395]: Inventory Added: Blyth Panel
And in the journal metadata:
NAME=Blyth Panel
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I6dd74cf449def18e627a8089468c5bca8de33784
diff --git a/include/entity_manager.hpp b/include/entity_manager.hpp
index a851866..3eae773 100644
--- a/include/entity_manager.hpp
+++ b/include/entity_manager.hpp
@@ -113,6 +113,7 @@
std::string model = "Unknown";
std::string type = "Unknown";
std::string sn = "Unknown";
+ std::string name = "Unknown";
if (findType != record.end())
{
@@ -140,10 +141,17 @@
}
}
- sd_journal_send("MESSAGE=%s", "Inventory Added", "PRIORITY=%i", LOG_INFO,
- "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.InventoryAdded",
+ auto findName = record.find("Name");
+ if (findName != record.end())
+ {
+ name = findName->get<std::string>();
+ }
+
+ sd_journal_send("MESSAGE=Inventory Added: %s", name.c_str(), "PRIORITY=%i",
+ LOG_INFO, "REDFISH_MESSAGE_ID=%s",
+ "OpenBMC.0.1.InventoryAdded",
"REDFISH_MESSAGE_ARGS=%s,%s,%s", model.c_str(),
- type.c_str(), sn.c_str(), NULL);
+ type.c_str(), sn.c_str(), "NAME=%s", name.c_str(), NULL);
}
inline void logDeviceRemoved(const nlohmann::json& record)
@@ -159,6 +167,7 @@
std::string model = "Unknown";
std::string type = "Unknown";
std::string sn = "Unknown";
+ std::string name = "Unknown";
if (findType != record.end())
{
@@ -186,8 +195,15 @@
}
}
- sd_journal_send("MESSAGE=%s", "Inventory Removed", "PRIORITY=%i", LOG_INFO,
- "REDFISH_MESSAGE_ID=%s", "OpenBMC.0.1.InventoryRemoved",
+ auto findName = record.find("Name");
+ if (findName != record.end())
+ {
+ name = findName->get<std::string>();
+ }
+
+ sd_journal_send("MESSAGE=Inventory Removed: %s", name.c_str(),
+ "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s",
+ "OpenBMC.0.1.InventoryRemoved",
"REDFISH_MESSAGE_ARGS=%s,%s,%s", model.c_str(),
- type.c_str(), sn.c_str(), NULL);
+ type.c_str(), sn.c_str(), "NAME=%s", name.c_str(), NULL);
}