Log vpd write action to file
This commit implements changes to log VPD write action to file.
VPD WriteKeyword API is exposed on DBus and can be triggered by any
application. VPD write also has the potential to corrupt data in some
cases. Hence all VPD write actions need to be logged. This commit also
implements an utility API to convert WriteVpdParams to string data type.
Test:
```
- execute vpd-tool writeKeyword on Op Panel's VINI record, CC keyword
- observe vpd-tool writeKeyword is successful and following log entry is
added in /var/lib/vpd/vpdWrite.log
2025-09-18 08:17:02.367 [Info] FileName: /usr/src/debug/openpower-fru-vpd
/1.0+git/vpd-manager/src/manager.cpp, Line: 277 VPD write successful on
path[/xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson
] : Record: VINI Keyword: CC Value: 0x36423630
- execute vpd-tool writeKeyword with invalid Keyword, observe no new log
added to /var/lib/vpd/vpdWrite.log
```
Change-Id: I209d761d3504dea6a1b65577fb4f3ee548c8adf6
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index 27b1f63..dd94d3b 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -270,6 +270,19 @@
l_fruPath, l_writeParams, l_sysCfgJsonObj);
}
+ // log VPD write success or failure
+ auto l_logger = Logger::getLoggerInstance();
+
+ uint16_t l_errorCode;
+ l_logger->logMessage(
+ "VPD write " +
+ std::string(
+ (l_rc != constants::FAILURE) ? "successful" : "failed") +
+ " on path[" + i_vpdPath + "] : " +
+ vpdSpecificUtility::convertWriteVpdParamsToString(l_writeParams,
+ l_errorCode),
+ PlaceHolder::VPD_WRITE);
+
return l_rc;
}
catch (const std::exception& l_exception)