PEL: Print Private Header into JSON aligned
"Private Header": {
"Section Version": "1",
"Sub-section type": "0",
"Created by": "0x1000",
"Created at": "12/05/2019 18:32:42",
"Committed at": "12/05/2019 18:32:42",
"Creator Subsystem": "BMC",
"CSSVER": "",
"Platform Log Id": "0x50000C00",
"Entry Id": "0x50000C00"
}
Testing: Manually run peltool and verified output
Signed-off-by: Harisuddin Mohamed Isa <harisuddin@gmail.com>
Change-Id: Ib6ef49f1b29486a97e86700b19ac982e43bede37
diff --git a/extensions/openpower-pels/private_header.cpp b/extensions/openpower-pels/private_header.cpp
index 2c1a860..19deaba 100644
--- a/extensions/openpower-pels/private_header.cpp
+++ b/extensions/openpower-pels/private_header.cpp
@@ -15,6 +15,7 @@
*/
#include "private_header.hpp"
+#include "json_utils.hpp"
#include "log_id.hpp"
#include "pel_types.hpp"
#include "pel_values.hpp"
@@ -113,17 +114,17 @@
std::string phPlatformIDStr(tmpPhVal);
sprintf(tmpPhVal, "0x%X", _id);
std::string phLogEntryIDStr(tmpPhVal);
- std::string ph = "{\"Section Version\": \"" + phVerStr +
- "\"}, \n {\"Sub-section type\": \"" + phStStr +
- "\"}, \n "
- "{\"Log Committed by\": \"" +
- phCbStr + "\"}, \n {\"Entry Creation\": \"" +
- phCreateTStr + "\"}, \n {\"Entry Commit\": \"" +
- phCommitTStr + "\"}, \n {\"Creator ID\": \"" + creator +
- "\"}, \n {\"Creator Implementation\": \"" +
- phCreatorVersionStr + "\"},\n {\"Platform Log ID\": \"" +
- phPlatformIDStr + "\"},\n {\"Log Entry ID\": \"" +
- phLogEntryIDStr + "\"}";
+ std::string ph;
+ jsonInsert(ph, "Section Version", phVerStr, 1);
+ jsonInsert(ph, "Sub-section type", phStStr, 1);
+ jsonInsert(ph, "Created by", phCbStr, 1);
+ jsonInsert(ph, "Created at", phCreateTStr, 1);
+ jsonInsert(ph, "Committed at", phCommitTStr, 1);
+ jsonInsert(ph, "Creator Subsystem", creator, 1);
+ jsonInsert(ph, "CSSVER", phCreatorVersionStr, 1);
+ jsonInsert(ph, "Platform Log Id", phPlatformIDStr, 1);
+ jsonInsert(ph, "Entry Id", phLogEntryIDStr, 1);
+ ph.erase(ph.size() - 2);
return ph;
}