diff options
author | Matt Spinler <spinler@us.ibm.com> | 2020-01-22 15:07:25 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2020-01-31 15:00:11 +0000 |
commit | c7c3e40249fcba41b4c6b15676fc1054e6ce1049 (patch) | |
tree | 5bea4111ba5bc7b2173944bbf219bc97d0414219 /extensions | |
parent | 6d663820c905b03e50013bb1dd1bc6d2cf880405 (diff) | |
download | phosphor-logging-c7c3e40249fcba41b4c6b15676fc1054e6ce1049.tar.gz phosphor-logging-c7c3e40249fcba41b4c6b15676fc1054e6ce1049.zip |
PEL: Move util namespace to bottom of pel.cpp
It makes more sense for the util code to be at the bottom
of the file rather than in the middle.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I46fe120849377bdf9397aa72addda1e9dfa4e56c
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/openpower-pels/pel.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp index 6d3f010..625d177 100644 --- a/extensions/openpower-pels/pel.cpp +++ b/extensions/openpower-pels/pel.cpp @@ -204,43 +204,6 @@ void PEL::checkRulesAndFix() _uh->setEventType(eventType); } -namespace util -{ - -std::unique_ptr<UserData> makeADUserDataSection(const AdditionalData& ad) -{ - assert(!ad.empty()); - nlohmann::json json; - - // Remove the 'ESEL' entry, as it contains a full PEL in the value. - if (ad.getValue("ESEL")) - { - auto newAD = ad; - newAD.remove("ESEL"); - json = newAD.toJSON(); - } - else - { - json = ad.toJSON(); - } - - auto jsonString = json.dump(); - std::vector<uint8_t> jsonData(jsonString.begin(), jsonString.end()); - - // Pad to a 4 byte boundary - while ((jsonData.size() % 4) != 0) - { - jsonData.push_back(0); - } - - return std::make_unique<UserData>( - static_cast<uint16_t>(ComponentID::phosphorLogging), - static_cast<uint8_t>(UserDataFormat::json), - static_cast<uint8_t>(UserDataFormatVersion::json), jsonData); -} - -} // namespace util - void PEL::printSectionInJSON(const Section& section, std::string& buf, std::map<uint16_t, size_t>& pluralSections) const { @@ -333,5 +296,42 @@ void PEL::toJSON() const std::cout << buf << std::endl; } +namespace util +{ + +std::unique_ptr<UserData> makeADUserDataSection(const AdditionalData& ad) +{ + assert(!ad.empty()); + nlohmann::json json; + + // Remove the 'ESEL' entry, as it contains a full PEL in the value. + if (ad.getValue("ESEL")) + { + auto newAD = ad; + newAD.remove("ESEL"); + json = newAD.toJSON(); + } + else + { + json = ad.toJSON(); + } + + auto jsonString = json.dump(); + std::vector<uint8_t> jsonData(jsonString.begin(), jsonString.end()); + + // Pad to a 4 byte boundary + while ((jsonData.size() % 4) != 0) + { + jsonData.push_back(0); + } + + return std::make_unique<UserData>( + static_cast<uint16_t>(ComponentID::phosphorLogging), + static_cast<uint8_t>(UserDataFormat::json), + static_cast<uint8_t>(UserDataFormatVersion::json), jsonData); +} + +} // namespace util + } // namespace pels } // namespace openpower |