diff options
author | Harisuddin Mohamed Isa <harisuddin@gmail.com> | 2020-01-10 10:51:02 +0800 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2020-01-14 16:29:59 +0000 |
commit | 2ecb465b0bd5249a3107fb1ee0ee5384bf1fdc4c (patch) | |
tree | 45392a816b04a326966ca25331eb4e0f14f8bbcb | |
parent | bad5f8a2331a150824002cf54227af71ffc34fe8 (diff) | |
download | phosphor-logging-2ecb465b0bd5249a3107fb1ee0ee5384bf1fdc4c.tar.gz phosphor-logging-2ecb465b0bd5249a3107fb1ee0ee5384bf1fdc4c.zip |
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
-rw-r--r-- | extensions/openpower-pels/private_header.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
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::optional<std::string> PrivateHeader::getJSON() const 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; } |