Move power-supply and power-sequencer to lg2
Update the logging API for files in power-supply and
power-sequencer from the older phosphor::logging::log style of
journal traces to the newer lg2::log style.
Tested:
* Verified commit passed CI unit tests.
* Verified commit built using bitbake.
Change-Id: I4436b5a422ff4cb64bedcd357f632b99837627d4
Signed-off-by: Anwaar Hadi <anwaar.hadi@ibm.com>
diff --git a/power-supply/main.cpp b/power-supply/main.cpp
index c57cc9f..9049fd6 100644
--- a/power-supply/main.cpp
+++ b/power-supply/main.cpp
@@ -19,7 +19,6 @@
#include "power_supply.hpp"
#include <CLI/CLI.hpp>
-#include <phosphor-logging/log.hpp>
#include <sdeventplus/event.hpp>
#include <iostream>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index 66d2d94..0094ac6 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -25,7 +25,7 @@
#include "utility.hpp"
#include <org/open_power/Witherspoon/Fault/error.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
#include <functional>
@@ -83,8 +83,8 @@
}
catch (const ReadFailure& e)
{
- log<level::INFO>("Unable to read the 2 byte STATUS_WORD value to check "
- "for power-supply input faults.");
+ lg2::info("Unable to read the 2 byte STATUS_WORD value to check "
+ "for power-supply input faults.");
}
presentMatch = std::make_unique<match_t>(
bus, match::rules::propertiesChanged(inventoryPath, INVENTORY_IFACE),
@@ -112,7 +112,7 @@
fruJson = loadJSONFromFile(PSU_JSON_PATH);
if (fruJson == nullptr)
{
- log<level::ERR>("InternalFailure when parsing the JSON file");
+ lg2::error("InternalFailure when parsing the JSON file");
return;
}
inventoryPMBusAccessType = getPMBusAccessType(fruJson);
@@ -130,8 +130,7 @@
}
catch (const std::exception& e)
{
- log<level::INFO>("Unable to capture metadata",
- entry("CMD=%s", cmd.c_str()));
+ lg2::info("Unable to capture metadata, CMD={CMD}", "CMD", cmd);
}
}
}
@@ -260,8 +259,8 @@
{
if (inputFault == 0)
{
- log<level::INFO>("INPUT or VIN_UV fault",
- entry("STATUS_WORD=0x%04X", statusWord));
+ lg2::info("INPUT or VIN_UV fault, STATUS_WORD={STATUS_WORD}",
+ "STATUS_WORD", lg2::hex | lg2::field16, statusWord);
}
inputFault++;
@@ -280,8 +279,8 @@
// the powerOnFault de-glitching.
powerOnFault = 0;
- log<level::INFO>("INPUT_FAULT_WARN cleared",
- entry("POWERSUPPLY=%s", inventoryPath.c_str()));
+ lg2::info("INPUT_FAULT_WARN cleared, POWERSUPPLY={POWERSUPPLY}",
+ "POWERSUPPLY", inventoryPath);
resolveError(inventoryPath,
std::string(PowerSupplyInputFault::errName));
@@ -329,15 +328,15 @@
if ((statusWord & status_word::POWER_GOOD_NEGATED) ||
(statusWord & status_word::UNIT_IS_OFF))
{
- log<level::INFO>("PGOOD or UNIT_IS_OFF bit bad",
- entry("STATUS_WORD=0x%04X", statusWord));
+ lg2::info("PGOOD or UNIT_IS_OFF bit bad, STATUS_WORD={STATUS_WORD}",
+ "STATUS_WORD", lg2::hex | lg2::field16, statusWord);
powerOnFault++;
}
else
{
if (powerOnFault > 0)
{
- log<level::INFO>("PGOOD and UNIT_IS_OFF bits good");
+ lg2::info("PGOOD and UNIT_IS_OFF bits good");
powerOnFault = 0;
}
}
@@ -605,9 +604,8 @@
}
catch (const std::exception& e)
{
- log<level::INFO>("Failed to resolve error",
- entry("CALLOUT=%s", callout.c_str()),
- entry("ERROR=%s", message.c_str()));
+ lg2::info("Failed to resolve error, CALLOUT={CALLOUT}, ERROR={ERROR}",
+ "CALLOUT", callout, "ERROR", message);
}
}
@@ -665,7 +663,7 @@
if (service.empty())
{
- log<level::ERR>("Unable to get inventory manager service");
+ lg2::error("Unable to get inventory manager service");
return;
}
@@ -678,7 +676,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(e.what(), entry("PATH=%s", inventoryPath.c_str()));
+ lg2::error("Exception in updateInventory: {ERROR}, PATH={PATH}",
+ "ERROR", e, "PATH", inventoryPath);
}
}
diff --git a/power-supply/record_manager.cpp b/power-supply/record_manager.cpp
index 622b234..f87c59a 100644
--- a/power-supply/record_manager.cpp
+++ b/power-supply/record_manager.cpp
@@ -17,7 +17,7 @@
#include <math.h>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <chrono>
@@ -28,8 +28,6 @@
namespace history
{
-using namespace phosphor::logging;
-
bool RecordManager::add(const std::vector<uint8_t>& rawRecord)
{
if (rawRecord.size() == 0)
@@ -69,11 +67,11 @@
{
if (id != FIRST_SEQUENCE_ID)
{
- log<level::INFO>(
+ lg2::info(
"Noncontiguous INPUT_HISTORY sequence ID "
- "found. Clearing old entries",
- entry("OLD_ID=%ld", previousID),
- entry("NEW_ID=%ld", id));
+ "found. Clearing old entries. OLD_ID={OLD_ID}, "
+ "NEW_ID={NEW_ID}",
+ "OLD_ID", previousID, "NEW_ID", id);
}
records.clear();
}
@@ -130,8 +128,7 @@
{
if (data.size() != RAW_RECORD_SIZE)
{
- log<level::ERR>("Invalid INPUT_HISTORY size",
- entry("SIZE=%d", data.size()));
+ lg2::error("Invalid INPUT_HISTORY size {SIZE}", "SIZE", data.size());
throw InvalidRecordException{};
}