PEL: Changing the remaining traces to lg2 style
Some of the logging traces of PEL files still uses old style of logging.
Changing the remaining traces in PEL files to lg2 style of logging.Some
of the traces in phosphor logging code which use the old style is also
considered.
Change-Id: I0daf9589af443881cb61730047c23db17fdec2c3
Signed-off-by: Arya K Padman <aryakpadman@gmail.com>
diff --git a/extensions/openpower-pels/callout.cpp b/extensions/openpower-pels/callout.cpp
index 705b1e4..dfc08bd 100644
--- a/extensions/openpower-pels/callout.cpp
+++ b/extensions/openpower-pels/callout.cpp
@@ -15,7 +15,9 @@
*/
#include "callout.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
+
+#include <map>
namespace openpower
{
@@ -24,8 +26,6 @@
namespace src
{
-using namespace phosphor::logging;
-
constexpr size_t locationCodeMaxSize = 80;
Callout::Callout(Stream& pel)
@@ -70,8 +70,8 @@
break;
}
default:
- log<level::ERR>("Invalid Callout subsection type",
- entry("CALLOUT_TYPE=0x%X", type));
+ lg2::error("Invalid Callout subsection type {CALLOUT_TYPE}",
+ "CALLOUT_TYPE", lg2::hex, type);
throw std::runtime_error("Invalid Callout subsection type");
break;
}
diff --git a/extensions/openpower-pels/device_callouts.cpp b/extensions/openpower-pels/device_callouts.cpp
index c446a4f..b3f3455 100644
--- a/extensions/openpower-pels/device_callouts.cpp
+++ b/extensions/openpower-pels/device_callouts.cpp
@@ -17,7 +17,7 @@
#include "paths.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <fstream>
#include <regex>
@@ -29,7 +29,6 @@
constexpr auto calloutFileSuffix = "_dev_callouts.json";
namespace fs = std::filesystem;
-using namespace phosphor::logging;
namespace util
{
@@ -56,7 +55,7 @@
if (fs::exists(path))
{
- log<level::INFO>("Found device callout debug file");
+ lg2::info("Found device callout debug file");
fullPath = path;
break;
}
diff --git a/extensions/openpower-pels/entry_points.cpp b/extensions/openpower-pels/entry_points.cpp
index 08cecb5..29b9d33 100644
--- a/extensions/openpower-pels/entry_points.cpp
+++ b/extensions/openpower-pels/entry_points.cpp
@@ -21,7 +21,7 @@
#include "manager.hpp"
#include "pldm_interface.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -69,9 +69,8 @@
{
// Log message and continue,
// This is to help continue creating PEL in raw format.
- log<level::ERR>(
- std::format("Failed to set PDBG_DTB: ({})", strerror(errno))
- .c_str());
+ lg2::error("Failed to set PDBG_DTB: ({ERRNO})", "ERRNO",
+ strerror(errno));
}
#endif
}
diff --git a/extensions/openpower-pels/extended_user_data.cpp b/extensions/openpower-pels/extended_user_data.cpp
index 441993a..92d1c70 100644
--- a/extensions/openpower-pels/extended_user_data.cpp
+++ b/extensions/openpower-pels/extended_user_data.cpp
@@ -19,15 +19,13 @@
#ifdef PELTOOL
#include "user_data_json.hpp"
#endif
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
namespace openpower::pels
{
-using namespace phosphor::logging;
-
void ExtendedUserData::unflatten(Stream& stream)
{
stream >> _header;
@@ -60,10 +58,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Cannot unflatten ExtendedUserData section: {}",
- e.what())
- .c_str());
+ lg2::error("Cannot unflatten ExtendedUserData section: {EXCEPTION}",
+ "EXCEPTION", e);
_valid = false;
}
}
@@ -89,10 +85,8 @@
{
if (header().id != static_cast<uint16_t>(SectionID::extUserData))
{
- log<level::ERR>(
- std::format("Invalid ExtendedUserData section ID: {0:#x}",
- header().id)
- .c_str());
+ lg2::error("Invalid ExtendedUserData section ID: {HEADER_ID}",
+ "HEADER_ID", lg2::hex, header().id);
_valid = false;
}
else
diff --git a/extensions/openpower-pels/extended_user_header.cpp b/extensions/openpower-pels/extended_user_header.cpp
index 1867673..3f5a886 100644
--- a/extensions/openpower-pels/extended_user_header.cpp
+++ b/extensions/openpower-pels/extended_user_header.cpp
@@ -19,7 +19,7 @@
#include "pel_types.hpp"
#include "pel_values.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -29,7 +29,7 @@
{
namespace pv = openpower::pels::pel_values;
-using namespace phosphor::logging;
+
const size_t defaultSymptomIDWord = 3;
const size_t symptomIDMaxSize = 80;
@@ -42,9 +42,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Cannot unflatten extended user header: {}", e.what())
- .c_str());
+ lg2::error("Cannot unflatten extended user header: {EXCEPTION}",
+ "EXCEPTION", e);
_valid = false;
}
}
@@ -110,19 +109,15 @@
if (header().id != static_cast<uint16_t>(SectionID::extendedUserHeader))
{
- log<level::ERR>(
- std::format("Invalid ExtendedUserHeader section ID: {0:#x}",
- header().id)
- .c_str());
+ lg2::error("Invalid ExtendedUserHeader section ID: {HEADER_ID}",
+ "HEADER_ID", lg2::hex, header().id);
failed = true;
}
if (header().version != extendedUserHeaderVersion)
{
- log<level::ERR>(
- std::format("Invalid ExtendedUserHeader version: {0:#x}",
- header().version)
- .c_str());
+ lg2::error("Invalid ExtendedUserHeader version: {HEADER_VERSION}",
+ "HEADER_VERSION", lg2::hex, header().version);
failed = true;
}
diff --git a/extensions/openpower-pels/failing_mtms.cpp b/extensions/openpower-pels/failing_mtms.cpp
index 7355e08..a056ce4 100644
--- a/extensions/openpower-pels/failing_mtms.cpp
+++ b/extensions/openpower-pels/failing_mtms.cpp
@@ -19,7 +19,7 @@
#include "pel_types.hpp"
#include "pel_values.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -29,7 +29,7 @@
{
namespace pv = openpower::pels::pel_values;
-using namespace phosphor::logging;
+
static constexpr uint8_t failingMTMSVersion = 0x01;
FailingMTMS::FailingMTMS(const DataInterfaceBase& dataIface) :
@@ -53,9 +53,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Cannot unflatten failing MTM section: {}", e.what())
- .c_str());
+ lg2::error("Cannot unflatten failing MTM section: {EXCEPTION}",
+ "EXCEPTION", e);
_valid = false;
}
}
@@ -66,17 +65,15 @@
if (header().id != static_cast<uint16_t>(SectionID::failingMTMS))
{
- log<level::ERR>(
- std::format("Invalid failing MTMS section ID: {0:#x}", header().id)
- .c_str());
+ lg2::error("Invalid failing MTMS section ID: {HEADER_ID}", "HEADER_ID",
+ lg2::hex, header().id);
failed = true;
}
if (header().version != failingMTMSVersion)
{
- log<level::ERR>(std::format("Invalid failing MTMS version: {0:#x}",
- header().version)
- .c_str());
+ lg2::error("Invalid failing MTMS version: {HEADER_VERSION}",
+ "HEADER_VERSION", lg2::hex, header().version);
failed = true;
}
diff --git a/extensions/openpower-pels/fapi_data_process.cpp b/extensions/openpower-pels/fapi_data_process.cpp
index b809725..252068c 100644
--- a/extensions/openpower-pels/fapi_data_process.cpp
+++ b/extensions/openpower-pels/fapi_data_process.cpp
@@ -10,6 +10,7 @@
#include <phal_exception.H>
#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <algorithm>
#include <cstdlib>
@@ -28,7 +29,6 @@
namespace phal
{
-using namespace phosphor::logging;
using namespace openpower::phal::exception;
/**
@@ -120,24 +120,20 @@
catch (const std::exception& e)
{
// log message and continue with default data
- log<level::ERR>(std::format("getLocationCode({}): Exception({})",
- pdbg_target_path(target), e.what())
- .c_str());
+ lg2::error("getLocationCode({TARGET_PATH}): Exception({EXCEPTION})",
+ "TARGET_PATH", pdbg_target_path(target), "EXCEPTION", e);
}
if (DT_GET_PROP(ATTR_PHYS_DEV_PATH, target, targetInfo->physDevPath))
{
- log<level::ERR>(
- std::format("Could not read({}) PHYS_DEV_PATH attribute",
- pdbg_target_path(target))
- .c_str());
+ lg2::error("Could not read({TARGET_PATH}) PHYS_DEV_PATH attribute",
+ "TARGET_PATH", pdbg_target_path(target));
}
if (DT_GET_PROP(ATTR_MRU_ID, target, targetInfo->mruId))
{
- log<level::ERR>(std::format("Could not read({}) ATTR_MRU_ID attribute",
- pdbg_target_path(target))
- .c_str());
+ lg2::error("Could not read({TARGET_PATH}) ATTR_MRU_ID attribute",
+ "TARGET_PATH", pdbg_target_path(target));
}
return requireAttrFound;
@@ -173,10 +169,9 @@
fmt += std::format("{:02X} ", value);
}
- log<level::ERR>(std::format("Given ATTR_PHYS_BIN_PATH value {} "
- "not found in phal device tree",
- fmt)
- .c_str());
+ lg2::error(
+ "Given ATTR_PHYS_BIN_PATH value {ATTR_PHYS_BIN_PATH} not found in phal device tree",
+ "ATTR_PHYS_BIN_PATH", fmt);
return false;
}
else if (ret == requireAttrNotFound)
@@ -208,10 +203,9 @@
auto it = priorityMap.find(phalPriority);
if (it == priorityMap.end())
{
- log<level::ERR>(std::format("Unsupported phal priority({}) is given "
- "to get pel priority format",
- phalPriority)
- .c_str());
+ lg2::error(
+ "Unsupported phal priority({PHAL_PRIORITY}) is given to get pel priority format",
+ "PHAL_PRIORITY", phalPriority);
return "H";
}
@@ -261,10 +255,8 @@
json& pelJSONFmtCalloutDataList,
FFDCData& ffdcUserData)
{
- log<level::INFO>(
- std::format("processClockInfoErrorHelper: FFDC Message[{}]",
- ffdc.message)
- .c_str());
+ lg2::info("processClockInfoErrorHelper: FFDC Message[{FFDC_MSG}]",
+ "FFDC_MSG", ffdc.message);
// Adding hardware procedures return code details
ffdcUserData.emplace_back("HWP_RC", ffdc.hwp_errorinfo.rc);
@@ -468,10 +460,8 @@
else if ((ffdc.ffdc_type != FFDC_TYPE_NONE) &&
(ffdc.ffdc_type != FFDC_TYPE_UNSUPPORTED))
{
- log<level::ERR>(std::format("Unsupported phal FFDC type to create PEL. "
- "MSG: {}",
- ffdc.message)
- .c_str());
+ lg2::error("Unsupported phal FFDC type to create PEL. MSG: {FFDC_MSG}",
+ "FFDC_MSG", ffdc.message);
}
}
diff --git a/extensions/openpower-pels/fru_identity.cpp b/extensions/openpower-pels/fru_identity.cpp
index ca523c4..15a7bda 100644
--- a/extensions/openpower-pels/fru_identity.cpp
+++ b/extensions/openpower-pels/fru_identity.cpp
@@ -17,12 +17,10 @@
#include "pel_values.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
-using namespace phosphor::logging;
-
namespace openpower
{
namespace pels
@@ -255,9 +253,8 @@
}
else
{
- log<level::ERR>(
- std::format("Invalid maintenance procedure {}", procedure)
- .c_str());
+ lg2::error("Invalid maintenance procedure {PROCEDURE}", "PROCEDURE",
+ procedure);
strncpy(_pnOrProcedureID.data(), "INVALID",
_pnOrProcedureID.size());
}
@@ -287,8 +284,7 @@
}
else
{
- log<level::ERR>("Invalid symbolic FRU",
- entry("FRU=%s", symbolicFRU.c_str()));
+ lg2::error("Invalid symbolic FRU {FRU}", "FRU", symbolicFRU);
strncpy(_pnOrProcedureID.data(), "INVALID",
_pnOrProcedureID.size());
}
diff --git a/extensions/openpower-pels/generic.cpp b/extensions/openpower-pels/generic.cpp
index 52616fa..486419a 100644
--- a/extensions/openpower-pels/generic.cpp
+++ b/extensions/openpower-pels/generic.cpp
@@ -15,7 +15,7 @@
*/
#include "generic.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -24,8 +24,6 @@
namespace pels
{
-using namespace phosphor::logging;
-
void Generic::unflatten(Stream& stream)
{
stream >> _header;
@@ -56,9 +54,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Cannot unflatten generic section: {}", e.what())
- .c_str());
+ lg2::error("Cannot unflatten generic section: {EXCEPTION}", "EXCEPTION",
+ e);
_valid = false;
}
}
diff --git a/extensions/openpower-pels/journal.cpp b/extensions/openpower-pels/journal.cpp
index 70a4552..5a4238f 100644
--- a/extensions/openpower-pels/journal.cpp
+++ b/extensions/openpower-pels/journal.cpp
@@ -17,7 +17,7 @@
#include "util.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -63,8 +63,8 @@
if (duration.count() > 100)
{
- log<level::INFO>(
- std::format("Journal sync took {}ms", duration.count()).c_str());
+ lg2::info("Journal sync took {DURATION}ms", "DURATION",
+ duration.count());
}
}
@@ -74,7 +74,7 @@
// The message registry JSON schema will also fail if a zero is in the JSON
if (0 == maxMessages)
{
- log<level::ERR>(
+ lg2::error(
"maxMessages value of zero passed into Journal::getMessages");
return std::vector<std::string>{};
}
diff --git a/extensions/openpower-pels/log_id.cpp b/extensions/openpower-pels/log_id.cpp
index ea00ef3..5fda994 100644
--- a/extensions/openpower-pels/log_id.cpp
+++ b/extensions/openpower-pels/log_id.cpp
@@ -17,7 +17,7 @@
#include "paths.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <chrono>
#include <filesystem>
@@ -29,7 +29,6 @@
{
namespace fs = std::filesystem;
-using namespace phosphor::logging;
constexpr uint32_t startingLogID = 1;
constexpr uint32_t bmcLogIDPrefix = 0x50000000;
@@ -87,7 +86,7 @@
if (idFile.fail())
{
// Just make up an ID
- log<level::ERR>("Unable to read PEL ID File!");
+ lg2::error("Unable to read PEL ID File!");
return detail::getTimeBasedLogID();
}
}
@@ -103,7 +102,7 @@
if (idFile.fail())
{
// Just make up an ID so we don't reuse one next time
- log<level::ERR>("Unable to write PEL ID File!");
+ lg2::error("Unable to write PEL ID File!");
return detail::getTimeBasedLogID();
}
@@ -123,8 +122,7 @@
if (rf.eof())
{
fs::remove(filename);
- log<level::WARNING>(
- "PEL ID file seems corrupted. Deleting it.");
+ lg2::warning("PEL ID file seems corrupted. Deleting it.");
break;
}
rf.read(&ch, sizeof(ch));
diff --git a/extensions/openpower-pels/mru.cpp b/extensions/openpower-pels/mru.cpp
index 1a9ce00..e53966a 100644
--- a/extensions/openpower-pels/mru.cpp
+++ b/extensions/openpower-pels/mru.cpp
@@ -15,7 +15,7 @@
*/
#include "mru.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
namespace openpower
{
@@ -24,8 +24,6 @@
namespace src
{
-using namespace phosphor::logging;
-
// The MRU substructure supports up to 15 MRUs.
static constexpr size_t maxMRUs = 15;
@@ -48,11 +46,12 @@
(sizeof(MRUCallout) * _mrus.size());
if (_size != actualSize)
{
- log<level::WARNING>("MRU callout section in PEL has listed size that "
- "doesn't match actual size",
- entry("SUBSTRUCTURE_SIZE=%lu", _size),
- entry("NUM_MRUS=%lu", _mrus.size()),
- entry("ACTUAL_SIZE=%lu", actualSize));
+ lg2::warning(
+ "MRU callout section in PEL with {NUM_MRUS} MRUs has listed size "
+ "{SUBSTRUCTURE_SIZE} that doesn't match the actual size "
+ "{ACTUAL_SIZE}",
+ "SUBSTRUCTURE_SIZE", _size, "NUM_MRUS", _mrus.size(), "ACTUAL_SIZE",
+ actualSize);
}
}
@@ -60,7 +59,7 @@
{
if (mrus.empty())
{
- log<level::ERR>("Trying to create a MRU section with no MRUs");
+ lg2::error("Trying to create a MRU section with no MRUs");
throw std::runtime_error{"Trying to create a MRU section with no MRUs"};
}
diff --git a/extensions/openpower-pels/phal_service_actions.cpp b/extensions/openpower-pels/phal_service_actions.cpp
index c07893d..aaa3c9d 100644
--- a/extensions/openpower-pels/phal_service_actions.cpp
+++ b/extensions/openpower-pels/phal_service_actions.cpp
@@ -3,7 +3,7 @@
#include <attributes_info.H>
#include <libphal.H>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -13,7 +13,6 @@
{
namespace phal
{
-using namespace phosphor::logging;
/**
* @brief Helper function to get EntrySeverity based on
@@ -40,11 +39,10 @@
}
else
{
- log<level::ERR>(
- std::format("GUARD: Unsupported GardType [{}] was given ",
- "to get the hardware isolation entry severity type",
- guardType.c_str())
- .c_str());
+ lg2::error(
+ "GUARD: Unsupported GuardType [{GUARD_TYPE}] was given to get the "
+ "hardware isolation entry severity type",
+ "GUARD_TYPE", guardType);
}
return std::nullopt;
}
@@ -73,7 +71,7 @@
if (!jsonCallouts.is_array())
{
- log<level::ERR>("GUARD: Callout JSON isn't an array");
+ lg2::error("GUARD: Callout JSON isn't an array");
return;
}
for (const auto& _callout : jsonCallouts)
@@ -93,7 +91,7 @@
// "CreateWithEntityPath"
if (!_callout.contains("EntityPath"))
{
- log<level::ERR>(
+ lg2::error(
"GUARD: Callout data, missing EntityPath information");
continue;
}
@@ -107,14 +105,13 @@
ss << " 0x" << std::hex << static_cast<int>(entityPath[a]);
}
std::string s = ss.str();
- log<level::INFO>(std::format("GUARD :({})", s).c_str());
+ lg2::info("GUARD: ({GUARD_TARGET})", "GUARD_TARGET", s);
// Get Guard type
auto severity = EntrySeverity::Warning;
if (!_callout.contains("GuardType"))
{
- log<level::ERR>(
- "GUARD: doesn't have Severity, setting to warning");
+ lg2::error("GUARD: doesn't have Severity, setting to warning");
}
else
{
@@ -133,10 +130,8 @@
}
catch (const std::exception& e)
{
- log<level::INFO>(
- std::format("GUARD: Failed entry creation exception:({})",
- e.what())
- .c_str());
+ lg2::info("GUARD: Failed entry creation exception:({EXCEPTION})",
+ "EXCEPTION", e);
}
}
}
@@ -166,7 +161,7 @@
if (!jsonCallouts.is_array())
{
- log<level::ERR>("Deconfig: Callout JSON isn't an array");
+ lg2::error("Deconfig: Callout JSON isn't an array");
return;
}
for (const auto& _callout : jsonCallouts)
@@ -186,32 +181,30 @@
if (!_callout.contains("EntityPath"))
{
- log<level::ERR>(
+ lg2::error(
"Deconfig: Callout data missing EntityPath information");
continue;
}
using EntityPath = std::vector<uint8_t>;
auto entityPath = _callout.at("EntityPath").get<EntityPath>();
- log<level::INFO>("Deconfig: adding deconfigure record");
+ lg2::info("Deconfig: adding deconfigure record");
// convert to libphal required format.
ATTR_PHYS_BIN_PATH_Type physBinPath;
std::copy(entityPath.begin(), entityPath.end(), physBinPath);
// libphal api to deconfigure the target
if (!pdbg_targets_init(NULL))
{
- log<level::ERR>("pdbg_targets_init failed, skipping deconfig "
- "record update");
+ lg2::error(
+ "pdbg_targets_init failed, skipping deconfig record update");
return;
}
openpower::phal::pdbg::deconfigureTgt(physBinPath, plid);
}
catch (const std::exception& e)
{
- log<level::INFO>(
- std::format(
- "Deconfig: Failed to create records, exception:({})",
- e.what())
- .c_str());
+ lg2::info(
+ "Deconfig: Failed to create records, exception:({EXCEPTION})",
+ "EXCEPTION", e);
}
}
}
diff --git a/extensions/openpower-pels/private_header.cpp b/extensions/openpower-pels/private_header.cpp
index 1b4fdbb..e32719f 100644
--- a/extensions/openpower-pels/private_header.cpp
+++ b/extensions/openpower-pels/private_header.cpp
@@ -20,7 +20,7 @@
#include "pel_types.hpp"
#include "pel_values.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -30,7 +30,6 @@
{
namespace pv = openpower::pels::pel_values;
-using namespace phosphor::logging;
PrivateHeader::PrivateHeader(uint16_t componentID, uint32_t obmcLogID,
uint64_t timestamp)
@@ -79,9 +78,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Cannot unflatten private header: {}", e.what())
- .c_str());
+ lg2::error("Cannot unflatten private header: {EXCEPTION}", "EXCEPTION",
+ e);
_valid = false;
}
}
@@ -129,26 +127,22 @@
if (header().id != static_cast<uint16_t>(SectionID::privateHeader))
{
- log<level::ERR>(std::format("Invalid private header section ID: {0:#x}",
- header().id)
- .c_str());
+ lg2::error("Invalid private header section ID: {HEADER_ID}",
+ "HEADER_ID", lg2::hex, header().id);
failed = true;
}
if (header().version != privateHeaderVersion)
{
- log<level::ERR>(std::format("Invalid private header version: {0:#x}",
- header().version)
- .c_str());
+ lg2::error("Invalid private header version: {HEADER_VERSION}",
+ "HEADER_VERSION", lg2::hex, header().version);
failed = true;
}
if (_sectionCount < minSectionCount)
{
- log<level::ERR>(
- std::format("Invalid section count in private header: {0:#x}",
- _sectionCount)
- .c_str());
+ lg2::error("Invalid section count in private header: {SECTION_COUNT}",
+ "SECTION_COUNT", lg2::hex, _sectionCount);
failed = true;
}
diff --git a/extensions/openpower-pels/sbe_ffdc_handler.cpp b/extensions/openpower-pels/sbe_ffdc_handler.cpp
index fc97651..36198a1 100644
--- a/extensions/openpower-pels/sbe_ffdc_handler.cpp
+++ b/extensions/openpower-pels/sbe_ffdc_handler.cpp
@@ -28,7 +28,7 @@
#include <ekb/hwpf/fapi2/include/target_types.H>
#include <libekb.H>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
#include <new>
@@ -74,7 +74,7 @@
SbeFFDC::SbeFFDC(const AdditionalData& aData, const PelFFDC& files) :
ffdcType(FFDC_TYPE_NONE), chipType(fapi2::TARGET_TYPE_PROC_CHIP)
{
- log<level::INFO>("SBE FFDC processing requested");
+ lg2::info("SBE FFDC processing requested");
// SRC6 field in the additional data contains Processor position
// associated to the SBE FFDC
@@ -82,7 +82,7 @@
auto src6 = aData.getValue("SRC6");
if (src6 == std::nullopt)
{
- log<level::ERR>("Fail to extract SRC6 data: failing to get proc index");
+ lg2::error("Fail to extract SRC6 data: failing to get proc index");
return;
}
try
@@ -91,8 +91,7 @@
}
catch (const std::exception& err)
{
- log<level::ERR>(
- std::format("Conversion failure errormsg({})", err.what()).c_str());
+ lg2::error("Conversion failure errormsg({ERR})", "ERR", err);
return;
}
auto type = aData.getValue("CHIP_TYPE");
@@ -104,16 +103,14 @@
}
catch (const std::exception& err)
{
- log<level::ERR>(
- std::format("Conversion failure errormsg({})", err.what())
- .c_str());
+ lg2::error("Conversion failure errormsg({ERR})", "ERR", err);
return;
}
}
if (files.empty())
{
- log<level::INFO>("SbeFFDC : No files found, skipping ffdc processing");
+ lg2::info("SbeFFDC : No files found, skipping ffdc processing");
return;
}
@@ -130,8 +127,7 @@
void SbeFFDC::parse(int fd)
{
- log<level::INFO>(
- std::format("SBE FFDC file fd:({}), parsing started", fd).c_str());
+ lg2::info("SBE FFDC file fd:({FD}), parsing started", "FD", fd);
uint32_t ffdcBufOffset = 0;
uint32_t pktCount = 0;
@@ -140,8 +136,7 @@
auto ffdcData = util::readFD(fd);
if (ffdcData.empty())
{
- log<level::ERR>(
- std::format("Empty SBE FFDC file fd:({}), skipping", fd).c_str());
+ lg2::error("Empty SBE FFDC file fd:({FD}), skipping", "FD", fd);
return;
}
@@ -161,10 +156,11 @@
lenWords = ntohs(ffdc->lengthinWords);
auto fapiRc = ntohl(ffdc->fapiRc);
- auto msg =
- std::format("P10 FFDC magic: {} length in words:{} Fapirc:{}",
- magicBytes, lenWords, fapiRc);
- log<level::INFO>(msg.c_str());
+ lg2::info(
+ "P10 FFDC magic: {MAGIC_BYTES} length in words:{LEN_WORDS} "
+ "Fapirc:{FAPI_RC}",
+ "MAGIC_BYTES", magicBytes, "LEN_WORDS", lenWords, "FAPI_RC",
+ fapiRc);
ffdcPkt.fapiRc = fapiRc;
// Not interested in the first 2 words (these are not ffdc)
@@ -179,7 +175,7 @@
}
else
{
- log<level::ERR>("FFDC packet size is zero skipping");
+ lg2::error("FFDC packet size is zero skipping");
return;
}
pktCount++;
@@ -191,10 +187,11 @@
lenWords = ntohs(ffdc->lengthinWords);
auto fapiRc = ntohl(ffdc->fapiRc);
- auto msg =
- std::format("P0Z FFDC magic: {} length in words:{} Fapirc:{}",
- magicBytes, lenWords, fapiRc);
- log<level::INFO>(msg.c_str());
+ lg2::info(
+ "P0Z FFDC magic: {MAGIC_BYTES} length in words:{LEN_WORDS} "
+ "Fapirc:{FAPI_RC}",
+ "MAGIC_BYTES", magicBytes, "LEN_WORDS", lenWords, "FAPI_RC",
+ fapiRc);
ffdcPkt.fapiRc = fapiRc;
// Not interested in the first 3 words (these are not ffdc)
@@ -209,13 +206,13 @@
}
else
{
- log<level::ERR>("FFDC packet size is zero skipping");
+ lg2::error("FFDC packet size is zero skipping");
return;
}
}
else
{
- log<level::ERR>("Invalid FFDC magic code in Header: Skipping ");
+ lg2::error("Invalid FFDC magic code in Header: Skipping ");
return;
}
@@ -228,7 +225,7 @@
}
else
{
- log<level::INFO>("SBE FFDC: Internal FFDC packet");
+ lg2::info("SBE FFDC: Internal FFDC packet");
}
// Update Buffer offset in Bytes
@@ -236,10 +233,10 @@
}
if (pktCount == sbeMaxFfdcPackets)
{
- log<level::ERR>(std::format("Received more than the limit of ({})"
- " FFDC packets, processing only ({})",
- sbeMaxFfdcPackets, pktCount)
- .c_str());
+ lg2::error("Received more than the limit of ({SBEMAXFFDCPACKETS}) FFDC "
+ "packets, processing only ({PKTCOUNT})",
+ "SBEMAXFFDCPACKETS", sbeMaxFfdcPackets, "PKTCOUNT",
+ pktCount);
}
}
@@ -252,13 +249,13 @@
if (!pdbg_targets_init(NULL))
{
- log<level::ERR>("pdbg_targets_init failed, skipping ffdc processing");
+ lg2::error("pdbg_targets_init failed, skipping ffdc processing");
return;
}
if (libekb_init())
{
- log<level::ERR>("libekb_init failed, skipping ffdc processing");
+ lg2::error("libekb_init failed, skipping ffdc processing");
return;
}
@@ -270,7 +267,7 @@
}
catch (...)
{
- log<level::ERR>("libekb_get_sbe_ffdc failed, skipping ffdc processing");
+ lg2::error("libekb_get_sbe_ffdc failed, skipping ffdc processing");
return;
}
@@ -325,7 +322,7 @@
{
if (ffdcType == FFDC_TYPE_SPARE_CLOCK_INFO)
{
- log<level::INFO>(
+ lg2::info(
"Found spare clock error, changing severity to informational");
return LogSeverity::Informational;
}
diff --git a/extensions/openpower-pels/service_indicators.cpp b/extensions/openpower-pels/service_indicators.cpp
index 8826276..7e26272 100644
--- a/extensions/openpower-pels/service_indicators.cpp
+++ b/extensions/openpower-pels/service_indicators.cpp
@@ -15,7 +15,7 @@
*/
#include "service_indicators.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <bitset>
#include <format>
@@ -23,8 +23,6 @@
namespace openpower::pels::service_indicators
{
-using namespace phosphor::logging;
-
static constexpr auto platformSaiLedGroup =
"/xyz/openbmc_project/led/groups/platform_system_attention_indicator";
@@ -94,10 +92,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Failed to assert platform SAI LED group: {}",
- e.what())
- .c_str());
+ lg2::error("Failed to assert platform SAI LED group: {EXCEPTION}",
+ "EXCEPTION", e);
}
}
}
@@ -214,10 +210,9 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(std::format("Could not get inventory path for "
- "location code {} ({}).",
- locCode, e.what())
- .c_str());
+ lg2::error("Could not get inventory path for "
+ "location code {LOCCODE} ({EXCEPTION}).",
+ "LOCCODE", locCode, "EXCEPTION", e);
// Unless we can set the LEDs for all FRUs, we can't turn
// on any of them, so clear the list and quit.
@@ -240,10 +235,9 @@
}
catch (const std::exception& e)
{
- log<level::INFO>(
- std::format("Could not write Functional property on {} ({})",
- path, e.what())
- .c_str());
+ lg2::info(
+ "Could not write Functional property on {PATH} ({EXCEPTION})",
+ "PATH", path, "EXCEPTION", e);
}
}
}
@@ -259,11 +253,9 @@
}
catch (const std::exception& e)
{
- log<level::INFO>(
- std::format(
- "Could not set critical association on object path {} ({})",
- path, e.what())
- .c_str());
+ lg2::info(
+ "Could not set critical association on object path {PATH} ({EXCEPTION})",
+ "PATH", path, "EXCEPTION", e);
}
}
}
diff --git a/extensions/openpower-pels/user_data.cpp b/extensions/openpower-pels/user_data.cpp
index a24a8f3..cb4acd1 100644
--- a/extensions/openpower-pels/user_data.cpp
+++ b/extensions/openpower-pels/user_data.cpp
@@ -22,7 +22,7 @@
#include "user_data_json.hpp"
#endif
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
@@ -31,8 +31,6 @@
namespace pels
{
-using namespace phosphor::logging;
-
void UserData::unflatten(Stream& stream)
{
stream >> _header;
@@ -63,8 +61,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Cannot unflatten user data: {}", e.what()).c_str());
+ lg2::error("Cannot unflatten user data: {EXCEPTION}", "EXCEPTION", e);
_valid = false;
}
}
@@ -87,9 +84,8 @@
{
if (header().id != static_cast<uint16_t>(SectionID::userData))
{
- log<level::ERR>(
- std::format("Invalid UserData section ID: {0:#x}", header().id)
- .c_str());
+ lg2::error("Invalid UserData section ID: {HEADER_ID}", "HEADER_ID",
+ lg2::hex, header().id);
_valid = false;
}
else
diff --git a/extensions/openpower-pels/user_header.cpp b/extensions/openpower-pels/user_header.cpp
index db61af8..3088c13 100644
--- a/extensions/openpower-pels/user_header.cpp
+++ b/extensions/openpower-pels/user_header.cpp
@@ -20,7 +20,7 @@
#include "pel_values.hpp"
#include "severity.hpp"
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <format>
#include <iostream>
@@ -31,7 +31,6 @@
{
namespace pv = openpower::pels::pel_values;
-using namespace phosphor::logging;
void UserHeader::unflatten(Stream& stream)
{
@@ -69,11 +68,9 @@
pel_values::subsystemValues);
if (subsystemString == "invalid")
{
- log<level::WARNING>(
- std::format(
- "UH: Invalid SubSystem value in PEL_SUBSYSTEM: {:#X}",
- eventSubsystem)
- .c_str());
+ lg2::warning(
+ "UH: Invalid SubSystem value in PEL_SUBSYSTEM: {PEL_SUBSYSTEM}",
+ "PEL_SUBSYSTEM", lg2::hex, eventSubsystem);
}
else
{
@@ -92,7 +89,7 @@
else
{
// Gotta use something, how about 'others'.
- log<level::WARNING>(
+ lg2::warning(
"No PEL subystem value supplied for error, using 'others'");
_eventSubsystem = 0x70;
}
@@ -162,10 +159,9 @@
{
// Either someone screwed up the message registry
// or getSystemNames failed.
- log<level::ERR>(
- "Failed finding the severity in the message registry",
- phosphor::logging::entry("ERROR=%s",
- entry.name.c_str()));
+ lg2::error(
+ "Failed finding the severity in the message registry ERROR={ERROR}",
+ "ERROR", entry.name);
// Have to choose something, just use informational.
_eventSeverity = 0;
@@ -228,8 +224,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(
- std::format("Cannot unflatten user header: {}", e.what()).c_str());
+ lg2::error("Cannot unflatten user header: {EXCEPTION}", "EXCEPTION", e);
_valid = false;
}
}
@@ -239,17 +234,15 @@
bool failed = false;
if (header().id != static_cast<uint16_t>(SectionID::userHeader))
{
- log<level::ERR>(
- std::format("Invalid user header section ID: {0:#x}", header().id)
- .c_str());
+ lg2::error("Invalid user header section ID: {HEADER_ID}", "HEADER_ID",
+ lg2::hex, header().id);
failed = true;
}
if (header().version != userHeaderVersion)
{
- log<level::ERR>(
- std::format("Invalid user header version: {0:#x}", header().version)
- .c_str());
+ lg2::error("Invalid user header version: {HEADER_VERSION}",
+ "HEADER_VERSION", lg2::hex, header().version);
failed = true;
}
@@ -319,8 +312,9 @@
}
catch (const std::exception& e)
{
- log<level::ERR>("Failed trying to look up system names on D-Bus",
- entry("ERROR=%s", e.what()));
+ lg2::error(
+ "Failed trying to look up system names on D-Bus ERROR={ERROR}",
+ "ERROR", e);
return std::nullopt;
}
}