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-sequencer/main.cpp b/power-sequencer/main.cpp
index 6f1dca0..039a102 100644
--- a/power-sequencer/main.cpp
+++ b/power-sequencer/main.cpp
@@ -21,7 +21,6 @@
#include "ucd90160.hpp"
#include <CLI/CLI.hpp>
-#include <phosphor-logging/log.hpp>
#include <sdeventplus/event.hpp>
#include <chrono>
diff --git a/power-sequencer/mihawk-cpld.cpp b/power-sequencer/mihawk-cpld.cpp
index 5a6f09b..6f9883f 100644
--- a/power-sequencer/mihawk-cpld.cpp
+++ b/power-sequencer/mihawk-cpld.cpp
@@ -13,7 +13,6 @@
#include <elog-errors.hpp>
#include <org/open_power/Witherspoon/Fault/error.hpp>
#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
#include <chrono>
diff --git a/power-sequencer/pgood_monitor.cpp b/power-sequencer/pgood_monitor.cpp
index d86acef..acceb6b 100644
--- a/power-sequencer/pgood_monitor.cpp
+++ b/power-sequencer/pgood_monitor.cpp
@@ -21,7 +21,7 @@
#include "utility.hpp"
#include <org/open_power/Witherspoon/Fault/error.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
namespace phosphor
{
@@ -116,8 +116,8 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(e.what());
- log<level::ERR>("Unexpected failure prevented PGOOD checking");
+ lg2::error("Unexpected failure prevented PGOOD checking: {ERROR}",
+ "ERROR", e);
}
// Letting the service fail won't help anything, so don't do it.
diff --git a/power-sequencer/runtime_monitor.cpp b/power-sequencer/runtime_monitor.cpp
index 487a2a6..7fa8665 100644
--- a/power-sequencer/runtime_monitor.cpp
+++ b/power-sequencer/runtime_monitor.cpp
@@ -21,7 +21,7 @@
#include "utility.hpp"
#include <org/open_power/Witherspoon/Fault/error.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
namespace phosphor
{
@@ -42,7 +42,7 @@
void RuntimeMonitor::onPowerLost(sdbusplus::message_t&)
{
- log<level::INFO>("PGOOD failure detected. Checking for faults.");
+ lg2::info("PGOOD failure detected. Checking for faults.");
try
{
@@ -60,7 +60,9 @@
catch (const std::exception& e)
{
// No need to crash
- log<level::ERR>(e.what());
+ lg2::error(
+ "Exception occurred while checking for PGOOD faults in onPowerLost: {ERROR}",
+ "ERROR", e);
}
}
diff --git a/power-sequencer/ucd90160.cpp b/power-sequencer/ucd90160.cpp
index 1b2be11..e8868e8 100644
--- a/power-sequencer/ucd90160.cpp
+++ b/power-sequencer/ucd90160.cpp
@@ -21,7 +21,7 @@
#include <elog-errors.hpp>
#include <org/open_power/Witherspoon/Fault/error.hpp>
#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/Device/error.hpp>
#include <map>
@@ -137,9 +137,9 @@
// warnings so they won't cause errors
if (vout)
{
- log<level::INFO>("A voltage rail has bits on in STATUS_VOUT",
- entry("STATUS_VOUT=0x%X", vout),
- entry("PAGE=%d", page));
+ lg2::info("A voltage rail has bits on in STATUS_VOUT,"
+ "STATUS_VOUT={STATUS_VOUT}. PAGE={PAGE}",
+ "STATUS_VOUT", lg2::hex, vout, "PAGE", page);
}
// Log errors if any non-warning bits on
@@ -158,7 +158,7 @@
}
catch (const device_error::ReadFailure& e)
{
- log<level::ERR>("ReadFailure when collecting metadata");
+ lg2::error("ReadFailure when collecting metadata");
commit<device_error::ReadFailure>();
}
@@ -225,7 +225,7 @@
{
if (!accessError)
{
- log<level::ERR>(e.what());
+ lg2::error("Access Error Exception: {ERROR}", "ERROR", e);
accessError = true;
}
continue;
@@ -256,7 +256,7 @@
}
catch (const device_error::ReadFailure& e)
{
- log<level::ERR>("ReadFailure when collecting metadata");
+ lg2::error("ReadFailure when collecting metadata");
commit<device_error::ReadFailure>();
}
@@ -287,7 +287,7 @@
}
catch (const device_error::ReadFailure& e)
{
- log<level::ERR>("ReadFailure when collecting metadata");
+ lg2::error("ReadFailure when collecting metadata");
commit<device_error::ReadFailure>();
}
@@ -319,8 +319,8 @@
if (gpioDevicePath.empty())
{
- log<level::ERR>("Could not find GPIO device path",
- entry("BASE_PATH=%s", path.c_str()));
+ lg2::error("Could not find GPIO device path, BASE_PATH={BASE_PATH}",
+ "BASE_PATH", path);
}
return gpioDevicePath;
@@ -359,9 +359,9 @@
if (device.empty())
{
- log<level::ERR>(
- "Missing GPIO device - cannot do GPIO analysis of fault",
- entry("ANALYSIS_TYPE=%d\n", type));
+ lg2::error(
+ "Missing GPIO device - cannot do GPIO analysis of fault, ANALYSIS_TYPE={ANALYSIS_TYPE}",
+ "ANALYSIS_TYPE", type);
return errorFound;
}
@@ -387,9 +387,9 @@
if (!gpioAccessError)
{
// GPIO only throws InternalErrors - not worth committing.
- log<level::ERR>(
- "GPIO read failed while analyzing a power fault",
- entry("CHIP_PATH=%s", path.c_str()));
+ lg2::error(
+ "GPIO read failed while analyzing a power fault, CHIP_PATH={CHIP_PATH}",
+ "CHIP_PATH", path);
gpioAccessError = true;
}
@@ -450,7 +450,7 @@
}
catch (const device_error::ReadFailure& e)
{
- log<level::ERR>("ReadFailure when collecting metadata");
+ lg2::error("ReadFailure when collecting metadata");
commit<device_error::ReadFailure>();
}
@@ -472,7 +472,7 @@
}
catch (const device_error::ReadFailure& e)
{
- log<level::ERR>("ReadFailure when collecting metadata");
+ lg2::error("ReadFailure when collecting metadata");
commit<device_error::ReadFailure>();
}
@@ -494,7 +494,7 @@
}
catch (const device_error::ReadFailure& e)
{
- log<level::ERR>("ReadFailure when collecting metadata");
+ lg2::error("ReadFailure when collecting metadata");
commit<device_error::ReadFailure>();
}
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{};
}