src: remove bool debug
Follow-up commit to the lg2 conversion.
Patching is not needed to get debug logs with lg2.
Tested: Inspection only.
Change-Id: Ie44b2debc7f4dff3a431a15f53720ae2da044a68
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 2489fc8..f46fd46 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -26,7 +26,6 @@
#include <variant>
#include <vector>
-static constexpr bool debug = false;
namespace thresholds
{
Level findThresholdLevel(uint8_t sev)
@@ -325,15 +324,12 @@
if (cDebugThrottle >= 1000)
{
cDebugThrottle = 0;
- if constexpr (debug)
- {
- lg2::error("checkThresholds: High T= {HIGH_TRUE}, F= {HIGH_FALSE},"
- " M= {HIGH_MIDSTATE}, Low T= {LOW_TRUE}, F= {LOW_FALSE},"
- " M= {LOW_MIDSTATE}",
- "HIGH_TRUE", cHiTrue, "HIGH_FALSE", cHiFalse,
- "HIGH_MIDSTATE", cHiMidstate, "LOW_TRUE", cLoTrue,
- "LOW_FALSE", cLoFalse, "LOW_MIDSTATE", cLoMidstate);
- }
+ lg2::debug("checkThresholds: High T= {HIGH_TRUE}, F= {HIGH_FALSE},"
+ " M= {HIGH_MIDSTATE}, Low T= {LOW_TRUE}, F= {LOW_FALSE},"
+ " M= {LOW_MIDSTATE}",
+ "HIGH_TRUE", cHiTrue, "HIGH_FALSE", cHiFalse,
+ "HIGH_MIDSTATE", cHiMidstate, "LOW_TRUE", cLoTrue,
+ "LOW_FALSE", cLoFalse, "LOW_MIDSTATE", cLoMidstate);
}
return thresholdChanges;
@@ -528,11 +524,8 @@
if (auto val = readFile(attrPath, scaleFactor))
{
*val += offset;
- if (debug)
- {
- lg2::info("Threshold: '{PATH}': '{VALUE}'", "PATH",
- attrPath, "VALUE", *val);
- }
+ lg2::debug("Threshold: '{PATH}': '{VALUE}'", "PATH",
+ attrPath, "VALUE", *val);
thresholdVector.emplace_back(level, direction, *val,
hysteresis);
}
diff --git a/src/adc/ADCSensorMain.cpp b/src/adc/ADCSensorMain.cpp
index 7949280..ae1efb9 100644
--- a/src/adc/ADCSensorMain.cpp
+++ b/src/adc/ADCSensorMain.cpp
@@ -50,7 +50,6 @@
#include <variant>
#include <vector>
-static constexpr bool debug = false;
static constexpr float pollRateDefault = 0.5;
static constexpr float gpioBridgeSetupTimeDefault = 0.02;
@@ -169,11 +168,8 @@
}
if (sensorData == nullptr)
{
- if constexpr (debug)
- {
- lg2::error("failed to find match for '{PATH}'", "PATH",
- path.string());
- }
+ lg2::debug("failed to find match for '{PATH}'", "PATH",
+ path.string());
continue;
}
diff --git a/src/exit-air/ExitAirTempSensor.cpp b/src/exit-air/ExitAirTempSensor.cpp
index d4220dd..09613b1 100644
--- a/src/exit-air/ExitAirTempSensor.cpp
+++ b/src/exit-air/ExitAirTempSensor.cpp
@@ -62,8 +62,6 @@
constexpr const char* cfmSettingPath = "/xyz/openbmc_project/control/cfm_limit";
constexpr const char* cfmSettingIface = "xyz.openbmc_project.Control.CFMLimit";
-static constexpr bool debug = false;
-
static constexpr double cfmMaxReading = 255;
static constexpr double cfmMinReading = 0;
@@ -428,10 +426,7 @@
[&](const auto& item) { return item.first.ends_with(tachName); });
if (findReading == tachReadings.end())
{
- if constexpr (debug)
- {
- lg2::error("Can't find '{NAME}' in readings", "NAME", tachName);
- }
+ lg2::debug("Can't find '{NAME}' in readings", "NAME", tachName);
continue; // haven't gotten a reading
}
@@ -456,10 +451,7 @@
rpm /= findRange->second.second;
rpm *= 100;
- if constexpr (debug)
- {
- lg2::info("Tach '{NAME}' at '{RPM}'", "NAME", tachName, "RPM", rpm);
- }
+ lg2::debug("Tach '{NAME}' at '{RPM}'", "NAME", tachName, "RPM", rpm);
// Do a linear interpolation to get Ci
// Ci = C1 + (C2 - C1)/(RPM2 - RPM1) * (TACHi - TACH1)
@@ -486,22 +478,16 @@
// Now calculate the CFM for this tach
// CFMi = Ci * Qmaxi * TACHi
totalCFM += ci * maxCFM * rpm;
- if constexpr (debug)
- {
- lg2::error(
- "totalCFM = {CFM}, Ci = {CI}, MaxCFM = {MAXCFM}, rpm = {RPM}, c1 = {C1}"
- ", c2 = {C2}, max = {MAX}, min = {MIN}",
- "CFM", totalCFM, "CI", ci, "MAXCFM", maxCFM, "RPM", rpm, "C1",
- c1, "C2", c2, "MAX", tachMaxPercent, "MIN", tachMinPercent);
- }
+ lg2::debug(
+ "totalCFM = {CFM}, Ci = {CI}, MaxCFM = {MAXCFM}, rpm = {RPM}, c1 = {C1}"
+ ", c2 = {C2}, max = {MAX}, min = {MIN}",
+ "CFM", totalCFM, "CI", ci, "MAXCFM", maxCFM, "RPM", rpm, "C1", c1,
+ "C2", c2, "MAX", tachMaxPercent, "MIN", tachMinPercent);
}
// divide by 100 since rpm is in percent
value = totalCFM / 100;
- if constexpr (debug)
- {
- lg2::error("cfm value = {VALUE}", "VALUE", value);
- }
+ lg2::debug("cfm value = {VALUE}", "VALUE", value);
return true;
}
@@ -637,11 +623,8 @@
}
double reading =
std::visit(VariantToDoubleVisitor(), value);
- if constexpr (debug)
- {
- lg2::error("'{PATH}' reading '{VALUE}'", "PATH",
- cbPath, "VALUE", reading);
- }
+ lg2::debug("'{PATH}' reading '{VALUE}'", "PATH",
+ cbPath, "VALUE", reading);
self->powerReadings[cbPath] = reading;
},
matches[0].first, cbPath, properties::interface,
@@ -774,13 +757,10 @@
return false;
}
- if constexpr (debug)
- {
- lg2::info(
- "Power Factor: {POWER_FACTOR}, Inlet Temp: {INLET_TEMP}, Total Power: {TOTAL_POWER}",
- "POWER_FACTOR", powerFactor, "INLET_TEMP", inletTemp, "TOTAL_POWER",
- totalPower);
- };
+ lg2::debug(
+ "Power Factor: {POWER_FACTOR}, Inlet Temp: {INLET_TEMP}, Total Power: {TOTAL_POWER}",
+ "POWER_FACTOR", powerFactor, "INLET_TEMP", inletTemp, "TOTAL_POWER",
+ totalPower);
// Calculate the exit air temp
// Texit = Tfp + (1.76 * TotalPower / CFM * Faltitude)
@@ -788,10 +768,7 @@
reading /= cfm;
reading += inletTemp;
- if constexpr (debug)
- {
- lg2::info("Reading 1: '{VALUE}'", "VALUE", reading);
- }
+ lg2::debug("Reading 1: '{VALUE}'", "VALUE", reading);
// Now perform the exponential average
// Calculate alpha based on SDR values and CFM
@@ -829,17 +806,11 @@
alphaDT = 1.0;
}
- if constexpr (debug)
- {
- lg2::info("AlphaDT: '{ADT}'", "ADT", alphaDT);
- }
+ lg2::debug("AlphaDT: '{ADT}'", "ADT", alphaDT);
reading = ((reading * alphaDT) + (lastReading * (1.0 - alphaDT)));
- if constexpr (debug)
- {
- lg2::info("Reading 2: '{VALUE}'", "VALUE", reading);
- }
+ lg2::debug("Reading 2: '{VALUE}'", "VALUE", reading);
val = reading;
lastReading = reading;
diff --git a/src/external/ExternalSensor.cpp b/src/external/ExternalSensor.cpp
index 51a439a..4a3b369 100644
--- a/src/external/ExternalSensor.cpp
+++ b/src/external/ExternalSensor.cpp
@@ -20,8 +20,6 @@
#include <utility>
#include <vector>
-static constexpr bool debug = false;
-
ExternalSensor::ExternalSensor(
const std::string& objectType, sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
@@ -64,16 +62,13 @@
objectServer.add_interface(objectPath, association::interface);
setInitialProperties(sensorUnits);
- if constexpr (debug)
- {
- lg2::error(
- "ExternalSensor '{NAME}' constructed: path '{PATH}', type '{TYPE}', "
- "min '{MIN}', max '{MAX}', timeout '{TIMEOUT}' us",
- "NAME", name, "PATH", objectPath, "TYPE", objectType, "MIN",
- minReading, "MAX", maxReading, "TIMEOUT",
- std::chrono::duration_cast<std::chrono::microseconds>(writeTimeout)
- .count());
- }
+ lg2::debug(
+ "ExternalSensor '{NAME}' constructed: path '{PATH}', type '{TYPE}', "
+ "min '{MIN}', max '{MAX}', timeout '{TIMEOUT}' us",
+ "NAME", name, "PATH", objectPath, "TYPE", objectType, "MIN", minReading,
+ "MAX", maxReading, "TIMEOUT",
+ std::chrono::duration_cast<std::chrono::microseconds>(writeTimeout)
+ .count());
}
// Separate function from constructor, because of a gotcha: can't use the
@@ -94,10 +89,7 @@
lockThis->externalSetTrigger();
return;
}
- if constexpr (debug)
- {
- lg2::error("ExternalSensor receive ignored, sensor gone");
- }
+ lg2::debug("ExternalSensor receive ignored, sensor gone");
};
}
@@ -113,10 +105,7 @@
}
objServer.remove_interface(sensorInterface);
- if constexpr (debug)
- {
- lg2::error("ExternalSensor '{NAME}' destructed", "NAME", name);
- }
+ lg2::debug("ExternalSensor '{NAME}' destructed", "NAME", name);
}
void ExternalSensor::checkThresholds()
@@ -190,11 +179,8 @@
void ExternalSensor::externalSetTrigger()
{
- if constexpr (debug)
- {
- lg2::error("ExternalSensor '{NAME}' received '{VALUE}'", "NAME", name,
- "VALUE", value);
- }
+ lg2::debug("ExternalSensor '{NAME}' received '{VALUE}'", "NAME", name,
+ "VALUE", value);
if (std::isfinite(value))
{
diff --git a/src/external/ExternalSensorMain.cpp b/src/external/ExternalSensorMain.cpp
index c8b21b4..04edb4f 100644
--- a/src/external/ExternalSensorMain.cpp
+++ b/src/external/ExternalSensorMain.cpp
@@ -55,8 +55,6 @@
// https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/41452
// https://github.com/openbmc/docs/tree/master/designs/
-static constexpr bool debug = false;
-
static const char* sensorType = "ExternalSensor";
void updateReaper(
@@ -117,10 +115,7 @@
if (!needCheck)
{
- if constexpr (debug)
- {
- lg2::error("Next ExternalSensor timer idle");
- }
+ lg2::debug("Next ExternalSensor timer idle");
return;
}
@@ -143,13 +138,9 @@
updateReaper(sensors, timer, std::chrono::steady_clock::now());
});
- if constexpr (debug)
- {
- lg2::error(
- "Next ExternalSensor timer '{VALUE}' us", "VALUE",
- std::chrono::duration_cast<std::chrono::microseconds>(nextCheck)
- .count());
- }
+ lg2::debug("Next ExternalSensor timer '{VALUE}' us", "VALUE",
+ std::chrono::duration_cast<std::chrono::microseconds>(nextCheck)
+ .count());
}
void createSensors(
@@ -161,10 +152,7 @@
sensorsChanged,
boost::asio::steady_timer& reaperTimer)
{
- if constexpr (debug)
- {
- lg2::error("ExternalSensor considering creating sensors");
- }
+ lg2::debug("ExternalSensor considering creating sensors");
auto getter = std::make_shared<GetSensorConfiguration>(
dbusConnection,
@@ -293,12 +281,8 @@
sensorsChanged->erase(it);
findSensor->second = nullptr;
found = true;
- if constexpr (debug)
- {
- lg2::error(
- "ExternalSensor '{NAME}' change found",
- "NAME", sensorName);
- }
+ lg2::debug("ExternalSensor '{NAME}' change found",
+ "NAME", sensorName);
break;
}
}
@@ -330,11 +314,8 @@
updateReaper(sensors, reaperTimer, now);
});
- if constexpr (debug)
- {
- lg2::error("ExternalSensor '{NAME}' created", "NAME",
- sensorName);
- }
+ lg2::debug("ExternalSensor '{NAME}' created", "NAME",
+ sensorName);
}
});
@@ -343,10 +324,7 @@
int main()
{
- if constexpr (debug)
- {
- lg2::error("ExternalSensor service starting up");
- }
+ lg2::debug("ExternalSensor service starting up");
boost::asio::io_context io;
auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);
@@ -378,11 +356,8 @@
const auto* messagePath = message.get_path();
sensorsChanged->insert(messagePath);
- if constexpr (debug)
- {
- lg2::error("ExternalSensor change event received: '{PATH}'",
- "PATH", messagePath);
- }
+ lg2::debug("ExternalSensor change event received: '{PATH}'", "PATH",
+ messagePath);
// this implicitly cancels the timer
filterTimer.expires_after(std::chrono::seconds(1));
@@ -409,10 +384,7 @@
setupPropertiesChangedMatches(
*systemBus, std::to_array<const char*>({sensorType}), eventHandler);
- if constexpr (debug)
- {
- lg2::error("ExternalSensor service entering main loop");
- }
+ lg2::debug("ExternalSensor service entering main loop");
io.run();
}
diff --git a/src/intel-cpu/IntelCPUSensorMain.cpp b/src/intel-cpu/IntelCPUSensorMain.cpp
index eede838..19b81e8 100644
--- a/src/intel-cpu/IntelCPUSensorMain.cpp
+++ b/src/intel-cpu/IntelCPUSensorMain.cpp
@@ -63,8 +63,6 @@
#endif
// clang-format on
-static constexpr bool debug = false;
-
boost::container::flat_map<std::string, std::shared_ptr<IntelCPUSensor>>
gCpuSensors;
boost::container::flat_map<std::string,
@@ -238,11 +236,8 @@
// shouldn't have an empty name file
continue;
}
- if (debug)
- {
- lg2::info("Checking: '{PATH}': '{NAME}'", "PATH", hwmonNamePath,
- "NAME", hwmonName);
- }
+ lg2::debug("Checking: '{PATH}': '{NAME}'", "PATH", hwmonNamePath,
+ "NAME", hwmonName);
std::string sensorType;
const SensorData* sensorData = nullptr;
@@ -341,11 +336,8 @@
auto findSensor = gCpuSensors.find(sensorName);
if (findSensor != gCpuSensors.end())
{
- if (debug)
- {
- lg2::info("Skipped: '{PATH}': '{NAME}' is already created",
- "PATH", inputPath, "NAME", sensorName);
- }
+ lg2::debug("Skipped: '{PATH}': '{NAME}' is already created",
+ "PATH", inputPath, "NAME", sensorName);
continue;
}
@@ -399,11 +391,8 @@
show, dtsOffset);
sensorPtr->setupRead();
createdSensors.insert(sensorName);
- if (debug)
- {
- lg2::info("Mapped: '{PATH}' to '{NAME}'", "PATH", inputPath,
- "NAME", sensorName);
- }
+ lg2::debug("Mapped: '{PATH}' to '{NAME}'", "PATH", inputPath,
+ "NAME", sensorName);
}
}
@@ -448,11 +437,8 @@
if (directoryName.starts_with(busStr) &&
directoryName.ends_with(addrHexStr))
{
- if (debug)
- {
- lg2::info("'{PARAMETERS}' on bus '{BUS}' is already exported",
- "PARAMETERS", parameters, "BUS", busStr);
- }
+ lg2::debug("'{PARAMETERS}' on bus '{BUS}' is already exported",
+ "PARAMETERS", parameters, "BUS", busStr);
std::ofstream delDeviceFile(delDevice);
if (!delDeviceFile.good())
@@ -647,11 +633,8 @@
keepPinging = true;
}
- if (debug)
- {
- lg2::info("'{NAME}', state: '{STATE}'", "NAME", config.name,
- "STATE", config.state);
- }
+ lg2::debug("'{NAME}', state: '{STATE}'", "NAME", config.name, "STATE",
+ config.state);
peci_Unlock(peciFd);
}
@@ -782,12 +765,9 @@
uint64_t addr = std::visit(VariantToUnsignedIntVisitor(),
findAddress->second);
- if (debug)
- {
- lg2::info(
- "bus: {BUS}, addr: {ADDR}, name: {NAME}, type: {TYPE}",
- "BUS", bus, "ADDR", addr, "NAME", name, "TYPE", type);
- }
+ lg2::debug(
+ "bus: {BUS}, addr: {ADDR}, name: {NAME}, type: {TYPE}",
+ "BUS", bus, "ADDR", addr, "NAME", name, "TYPE", type);
cpuConfigs.emplace(bus, addr, name, State::OFF);
}
@@ -845,10 +825,7 @@
return;
}
- if (debug)
- {
- lg2::info("'{PATH}' is changed", "PATH", message.get_path());
- }
+ lg2::debug("'{PATH}' is changed", "PATH", message.get_path());
// this implicitly cancels the timer
filterTimer.expires_after(std::chrono::seconds(1));
diff --git a/src/intrusion/ChassisIntrusionSensor.cpp b/src/intrusion/ChassisIntrusionSensor.cpp
index 445adbe..3103ff5 100644
--- a/src/intrusion/ChassisIntrusionSensor.cpp
+++ b/src/intrusion/ChassisIntrusionSensor.cpp
@@ -49,8 +49,6 @@
#include <linux/i2c-dev.h>
}
-static constexpr bool debug = false;
-
static constexpr unsigned int defaultPollSec = 1;
static constexpr unsigned int sensorFailedPollSec = 5;
static unsigned int intrusionSensorPollSec = defaultPollSec;
@@ -83,11 +81,8 @@
return;
}
- if constexpr (debug)
- {
- lg2::info("Update value from '{VALUE}' to '{NEWVALUE}'", "VALUE",
- mValue, "NEWVALUE", newValue);
- }
+ lg2::debug("Update value from '{VALUE}' to '{NEWVALUE}'", "VALUE", mValue,
+ "NEWVALUE", newValue);
// Automatic Rearm mode allows direct update
// Manual Rearm mode requires a rearm action to clear the intrusion
@@ -128,10 +123,7 @@
int32_t statusReg = pchStatusRegIntrusion;
int32_t value = i2c_smbus_read_byte_data(mBusFd, statusReg);
- if constexpr (debug)
- {
- lg2::info("Pch type: raw value is '{VALUE}'", "VALUE", value);
- }
+ lg2::debug("Pch type: raw value is '{VALUE}'", "VALUE", value);
if (value < 0)
{
@@ -142,10 +134,7 @@
// Get status value with mask
value &= statusMask;
- if constexpr (debug)
- {
- lg2::info("Pch type: masked raw value is '{VALUE}'", "VALUE", value);
- }
+ lg2::debug("Pch type: masked raw value is '{VALUE}'", "VALUE", value);
return value;
}
@@ -191,10 +180,7 @@
{
mGpioLine.event_read();
auto value = mGpioLine.get_value();
- if constexpr (debug)
- {
- lg2::info("Gpio type: raw value is '{VALUE}'", "VALUE", value);
- }
+ lg2::debug("Gpio type: raw value is '{VALUE}'", "VALUE", value);
return value;
}
@@ -246,10 +232,7 @@
try
{
value = std::stoi(line);
- if constexpr (debug)
- {
- lg2::info("Hwmon type: raw value is '{VALUE}'", "VALUE", value);
- }
+ lg2::debug("Hwmon type: raw value is '{VALUE}'", "VALUE", value);
}
catch (const std::invalid_argument& e)
{
@@ -464,12 +447,9 @@
// Expecting only one hwmon file for one given chassis
mHwmonPath = paths[0].string();
- if constexpr (debug)
- {
- lg2::info(
- "Found '{NUM_PATHS}' paths for intrusion status. The first path is: '{PATH}'",
- "NUM_PATHS", paths.size(), "PATH", mHwmonPath);
- }
+ lg2::debug(
+ "Found '{NUM_PATHS}' paths for intrusion status. The first path is: '{PATH}'",
+ "NUM_PATHS", paths.size(), "PATH", mHwmonPath);
}
ChassisIntrusionSensor::~ChassisIntrusionSensor()
diff --git a/src/intrusion/IntrusionSensorMain.cpp b/src/intrusion/IntrusionSensorMain.cpp
index 4432ed5..bc25fe3 100644
--- a/src/intrusion/IntrusionSensorMain.cpp
+++ b/src/intrusion/IntrusionSensorMain.cpp
@@ -45,8 +45,6 @@
#include <variant>
#include <vector>
-static constexpr bool debug = false;
-
static constexpr const char* sensorType = "ChassisIntrusionSensor";
static constexpr const char* nicType = "NIC";
static constexpr auto nicTypes{std::to_array<const char*>({nicType})};
@@ -131,12 +129,9 @@
pSensor = std::make_shared<ChassisIntrusionGpioSensor>(
autoRearm, io, objServer, gpioInverted);
pSensor->start();
- if (debug)
- {
- lg2::info(
- "find chassis intrusion sensor polarity inverted flag is '{GPIO_INVERTED}'",
- "GPIO_INVERTED", gpioInverted);
- }
+ lg2::debug(
+ "find chassis intrusion sensor polarity inverted flag is '{GPIO_INVERTED}'",
+ "GPIO_INVERTED", gpioInverted);
return;
}
catch (const std::bad_variant_access& e)
@@ -199,12 +194,9 @@
pSensor = std::make_shared<ChassisIntrusionPchSensor>(
autoRearm, io, objServer, busId, slaveAddr);
pSensor->start();
- if (debug)
- {
- lg2::info(
- "find matched bus '{BUS}', matched slave addr '{ADDR}'",
- "BUS", busId, "ADDR", slaveAddr);
- }
+ lg2::debug(
+ "find matched bus '{BUS}', matched slave addr '{ADDR}'",
+ "BUS", busId, "ADDR", slaveAddr);
return;
}
catch (const std::bad_variant_access& e)
@@ -234,7 +226,6 @@
}
}
-static constexpr bool debugLanLeash = false;
boost::container::flat_map<int, bool> lanStatusMap;
boost::container::flat_map<int, std::string> lanInfoMap;
boost::container::flat_map<std::string, int> pathSuffixMap;
@@ -272,11 +263,8 @@
if (pEthIndex != nullptr && pName != nullptr)
{
lanInfoMap[*pEthIndex] = *pName;
- if (debugLanLeash)
- {
- lg2::info("find name of eth{ETH_INDEX} is '{NAME}'",
- "ETH_INDEX", *pEthIndex, "NAME", *pName);
- }
+ lg2::debug("find name of eth{ETH_INDEX} is '{NAME}'",
+ "ETH_INDEX", *pEthIndex, "NAME", *pName);
}
}
}
@@ -358,15 +346,12 @@
}
}
- if (debugLanLeash)
- {
- lg2::info(
- "ethNum = {ETH_INDEX}, state = {LAN_STATUS}, oldLanConnected = {OLD_LAN_CONNECTED}, "
- "newLanConnected = {NEW_LAN_CONNECTED}",
- "ETH_INDEX", ethNum, "LAN_STATUS", *pState, "OLD_LAN_CONNECTED",
- (oldLanConnected ? "true" : "false"), "NEW_LAN_CONNECTED",
- (newLanConnected ? "true" : "false"));
- }
+ lg2::debug(
+ "ethNum = {ETH_INDEX}, state = {LAN_STATUS}, oldLanConnected = {OLD_LAN_CONNECTED}, "
+ "newLanConnected = {NEW_LAN_CONNECTED}",
+ "ETH_INDEX", ethNum, "LAN_STATUS", *pState, "OLD_LAN_CONNECTED",
+ (oldLanConnected ? "true" : "false"), "NEW_LAN_CONNECTED",
+ (newLanConnected ? "true" : "false"));
if (oldLanConnected != newLanConnected)
{
@@ -405,10 +390,7 @@
// iterate through all found eth files, and save ifindex
for (const std::filesystem::path& fileName : files)
{
- if (debugLanLeash)
- {
- lg2::info("Reading '{NAME}'", "NAME", fileName);
- }
+ lg2::debug("Reading '{NAME}'", "NAME", fileName);
std::ifstream sysFile(fileName);
if (!sysFile.good())
{
@@ -437,12 +419,9 @@
// save pathSuffix
pathSuffixMap[pathSuffix] = ethNum;
- if (debugLanLeash)
- {
- lg2::info(
- "ethNum = {ETH_INDEX}, ifindex = {LINE}, pathSuffix = {PATH}",
- "ETH_INDEX", ethNum, "LINE", line, "PATH", pathSuffix);
- }
+ lg2::debug(
+ "ethNum = {ETH_INDEX}, ifindex = {LINE}, pathSuffix = {PATH}",
+ "ETH_INDEX", ethNum, "LINE", line, "PATH", pathSuffix);
// init lan connected status from networkd
conn->async_method_call(
@@ -464,13 +443,9 @@
bool isLanConnected =
(*pState == "routable" || *pState == "carrier" ||
*pState == "degraded");
- if (debugLanLeash)
- {
- lg2::info(
- "ethNum = {ETH_INDEX}, init LAN status = {STATUS}",
- "ETH_INDEX", ethNum, "STATUS",
- (isLanConnected ? "true" : "false"));
- }
+ lg2::debug("ethNum = {ETH_INDEX}, init LAN status = {STATUS}",
+ "ETH_INDEX", ethNum, "STATUS",
+ (isLanConnected ? "true" : "false"));
lanStatusMap[ethNum] = isLanConnected;
},
"org.freedesktop.network1",
diff --git a/src/ipmb/IpmbSensor.cpp b/src/ipmb/IpmbSensor.cpp
index a1f5db2..a6c4ac1 100644
--- a/src/ipmb/IpmbSensor.cpp
+++ b/src/ipmb/IpmbSensor.cpp
@@ -50,8 +50,6 @@
#include <variant>
#include <vector>
-constexpr const bool debug = false;
-
static constexpr double ipmbMaxReading = 0xFF;
static constexpr double ipmbMinReading = 0;
@@ -431,16 +429,14 @@
return;
}
const std::vector<uint8_t>& data = std::get<5>(response);
- if constexpr (debug)
+
+ std::ostringstream tempStream;
+ for (int d : data)
{
- std::ostringstream tempStream;
- for (int d : data)
- {
- tempStream << std::setfill('0') << std::setw(2) << std::hex << d
- << " ";
- }
- lg2::info("'{NAME}': '{DATA}'", "NAME", name, "DATA", tempStream.str());
+ tempStream << std::setfill('0') << std::setw(2) << std::hex << d << " ";
}
+ lg2::debug("'{NAME}': '{DATA}'", "NAME", name, "DATA", tempStream.str());
+
if (data.empty())
{
incrementError();
diff --git a/src/mcu/MCUTempSensor.cpp b/src/mcu/MCUTempSensor.cpp
index 16eeb9e..adefffc 100644
--- a/src/mcu/MCUTempSensor.cpp
+++ b/src/mcu/MCUTempSensor.cpp
@@ -53,8 +53,6 @@
#include <linux/i2c-dev.h>
}
-constexpr const bool debug = false;
-
constexpr const char* sensorType = "MCUTempSensor";
static constexpr double mcuTempMaxReading = 0xFF;
static constexpr double mcuTempMinReading = 0;
@@ -182,11 +180,8 @@
if (ret >= 0)
{
double v = static_cast<double>(temp) / 1000;
- if constexpr (debug)
- {
- lg2::error("Value update to '{VALUE}' raw reading '{RAW}'",
- "VALUE", v, "RAW", temp);
- }
+ lg2::debug("Value update to '{VALUE}' raw reading '{RAW}'", "VALUE",
+ v, "RAW", temp);
updateValue(v);
}
else
@@ -243,15 +238,12 @@
std::string sensorClass =
loadVariant<std::string>(cfg, "Class");
- if constexpr (debug)
- {
- lg2::error(
- "Configuration parsed for '{INTERFACE}' with Name: {NAME}, Bus: {BUS}, "
- "Address: {ADDRESS}, Reg: {REG}, Class: {CLASS}",
- "INTERFACE", intf, "NAME", name, "BUS", busId,
- "ADDRESS", mcuAddress, "REG", tempReg, "CLASS",
- sensorClass);
- }
+ lg2::debug(
+ "Configuration parsed for '{INTERFACE}' with Name: {NAME}, Bus: {BUS}, "
+ "Address: {ADDRESS}, Reg: {REG}, Class: {CLASS}",
+ "INTERFACE", intf, "NAME", name, "BUS", busId,
+ "ADDRESS", mcuAddress, "REG", tempReg, "CLASS",
+ sensorClass);
auto& sensor = sensors[name];
diff --git a/src/psu/PSUSensor.cpp b/src/psu/PSUSensor.cpp
index 2ba212e..bc9430f 100644
--- a/src/psu/PSUSensor.cpp
+++ b/src/psu/PSUSensor.cpp
@@ -42,8 +42,6 @@
static constexpr const char* sensorPathPrefix = "/xyz/openbmc_project/sensors/";
-static constexpr bool debug = false;
-
PSUSensor::PSUSensor(
const std::string& path, const std::string& objectType,
sdbusplus::asio::object_server& objectServer,
@@ -63,16 +61,13 @@
{
buffer = std::make_shared<std::array<char, 128>>();
std::string unitPath = sensor_paths::getPathForUnits(sensorUnits);
- if constexpr (debug)
- {
- lg2::debug(
- "Constructed sensor - path: {PATH}, type: {TYPE}, config: {CONFIG}, "
- "typename: {TYPENAME}, factor: {FACTOR}, min: {MIN}, max: {MAX}, "
- "offset: {OFFSET}, name: {NAME}",
- "PATH", path, "TYPE", objectType, "CONFIG", sensorConfiguration,
- "TYPENAME", unitPath, "FACTOR", factor, "MIN", min, "MAX", max,
- "OFFSET", offset, "NAME", sensorName);
- }
+ lg2::debug(
+ "Constructed sensor - path: {PATH}, type: {TYPE}, config: {CONFIG}, "
+ "typename: {TYPENAME}, factor: {FACTOR}, min: {MIN}, max: {MAX}, "
+ "offset: {OFFSET}, name: {NAME}",
+ "PATH", path, "TYPE", objectType, "CONFIG", sensorConfiguration,
+ "TYPENAME", unitPath, "FACTOR", factor, "MIN", min, "MAX", max,
+ "OFFSET", offset, "NAME", sensorName);
if (pollRate > 0.0)
{
sensorPollMs = static_cast<unsigned int>(pollRate * 1000);
diff --git a/src/psu/PSUSensorMain.cpp b/src/psu/PSUSensorMain.cpp
index 63bc6b5..3e73874 100644
--- a/src/psu/PSUSensorMain.cpp
+++ b/src/psu/PSUSensorMain.cpp
@@ -61,7 +61,6 @@
#include <variant>
#include <vector>
-static constexpr bool debug = false;
static std::regex i2cDevRegex(R"((\/i2c\-\d+\/\d+-[a-fA-F0-9]{4,4})(\/|$))");
static const I2CDeviceTypeMap sensorTypes{
@@ -441,13 +440,10 @@
if ((*confBus != bus) || (*confAddr != addr))
{
- if constexpr (debug)
- {
- lg2::error(
- "Configuration skipping '{CONFBUS}'-'{CONFADDR}' because not {BUS}-{ADDR}",
- "CONFBUS", *confBus, "CONFADDR", *confAddr, "BUS", bus,
- "ADDR", addr);
- }
+ lg2::debug(
+ "Configuration skipping '{CONFBUS}'-'{CONFADDR}' because not {BUS}-{ADDR}",
+ "CONFBUS", *confBus, "CONFADDR", *confAddr, "BUS", bus,
+ "ADDR", addr);
continue;
}
@@ -550,10 +546,7 @@
/* read max value in sysfs for in, curr, power, temp, ... */
if (!findFiles(directory, R"(\w\d+_max$)", sensorPaths, 0))
{
- if constexpr (debug)
- {
- lg2::error("No max name in PSU");
- }
+ lg2::debug("No max name in PSU");
}
float pollRate = getPollRate(*baseConfig, PSUSensor::defaultSensorPoll);
@@ -622,12 +615,9 @@
std::ifstream labelFile(labelPath);
if (!labelFile.good())
{
- if constexpr (debug)
- {
- lg2::error(
- "Input file '{PATH}' has no corresponding label file",
- "PATH", sensorPath.string());
- }
+ lg2::debug(
+ "Input file '{PATH}' has no corresponding label file",
+ "PATH", sensorPath.string());
// hwmon *_input filename with number:
// temp1, temp2, temp3, ...
labelHead =
@@ -662,12 +652,8 @@
if (std::find(findLabels.begin(), findLabels.end(),
labelHead) == findLabels.end())
{
- if constexpr (debug)
- {
- lg2::error(
- "could not find {LABEL} in the Labels list",
- "LABEL", labelHead);
- }
+ lg2::debug("could not find {LABEL} in the Labels list",
+ "LABEL", labelHead);
continue;
}
}
@@ -680,11 +666,8 @@
labelHead = sensorNameStr.substr(0, findIIOHyphen);
}
- if constexpr (debug)
- {
- lg2::error("Sensor type: {NAME}, label: {LABEL}", "NAME",
- sensorNameSubStr, "LABEL", labelHead);
- }
+ lg2::debug("Sensor type: {NAME}, label: {LABEL}", "NAME",
+ sensorNameSubStr, "LABEL", labelHead);
if (!findLabels.empty())
{
@@ -692,12 +675,8 @@
if (std::find(findLabels.begin(), findLabels.end(),
labelHead) == findLabels.end())
{
- if constexpr (debug)
- {
- lg2::error(
- "could not find '{LABEL}' in the Labels list",
- "LABEL", labelHead);
- }
+ lg2::debug("could not find '{LABEL}' in the Labels list",
+ "LABEL", labelHead);
continue;
}
}
@@ -709,12 +688,9 @@
labelMatch.find(static_cast<std::string>(labelHeadView));
if (findProperty == labelMatch.end())
{
- if constexpr (debug)
- {
- lg2::error(
- "Could not find matching default property for '{LABEL}'",
- "LABEL", labelHead);
- }
+ lg2::debug(
+ "Could not find matching default property for '{LABEL}'",
+ "LABEL", labelHead);
continue;
}
@@ -877,13 +853,9 @@
psuNameFromIndex = psuNames[nameIndex];
- if constexpr (debug)
- {
- lg2::error(
- "'{LABEL}' paired with '{NAME}' at index '{INDEX}'",
- "LABEL", labelHead, "NAME", psuNameFromIndex, "INDEX",
- nameIndex);
- }
+ lg2::debug("'{LABEL}' paired with '{NAME}' at index '{INDEX}'",
+ "LABEL", labelHead, "NAME", psuNameFromIndex,
+ "INDEX", nameIndex);
}
if (devType == DevTypes::HWMON)
@@ -915,12 +887,9 @@
findScaleFactor->second);
}
- if constexpr (debug)
- {
- lg2::error(
- "Sensor scaling factor '{FACTOR}' string '{SCALE_FACTOR}'",
- "FACTOR", factor, "SCALE_FACTOR", strScaleFactor);
- }
+ lg2::debug(
+ "Sensor scaling factor '{FACTOR}' string '{SCALE_FACTOR}'",
+ "FACTOR", factor, "SCALE_FACTOR", strScaleFactor);
}
std::vector<thresholds::Threshold> sensorThresholds;
@@ -939,16 +908,12 @@
continue;
}
- if constexpr (debug)
- {
- lg2::error("Sensor properties - Name: {NAME}, Scale: {SCALE}, "
- "Min: {MIN}, Max: {MAX}, Offset: {OFFSET}",
- "NAME", psuProperty.labelTypeName, "SCALE",
- psuProperty.sensorScaleFactor, "MIN",
- psuProperty.minReading, "MAX",
- psuProperty.maxReading, "OFFSET",
- psuProperty.sensorOffset);
- }
+ lg2::debug("Sensor properties - Name: {NAME}, Scale: {SCALE}, "
+ "Min: {MIN}, Max: {MAX}, Offset: {OFFSET}",
+ "NAME", psuProperty.labelTypeName, "SCALE",
+ psuProperty.sensorScaleFactor, "MIN",
+ psuProperty.minReading, "MAX", psuProperty.maxReading,
+ "OFFSET", psuProperty.sensorOffset);
std::string sensorName = psuProperty.labelTypeName;
if (customizedName)
@@ -975,12 +940,9 @@
}
}
- if constexpr (debug)
- {
- lg2::error("Sensor name: {NAME}, path: {PATH}, type: {TYPE}",
- "NAME", sensorName, "PATH", sensorPathStr, "TYPE",
- sensorType);
- }
+ lg2::debug("Sensor name: {NAME}, path: {PATH}, type: {TYPE}",
+ "NAME", sensorName, "PATH", sensorPathStr, "TYPE",
+ sensorType);
// destruct existing one first if already created
auto& sensor = sensors[sensorName];
@@ -1004,11 +966,7 @@
pollRate, i2cDev);
sensors[sensorName]->setupRead();
++numCreated;
- if constexpr (debug)
- {
- lg2::error("Created '{NUM}' sensors so far", "NUM",
- numCreated);
- }
+ lg2::debug("Created '{NUM}' sensors so far", "NUM", numCreated);
}
}
@@ -1024,10 +982,7 @@
}
}
- if constexpr (debug)
- {
- lg2::error("Created total of '{NUM}' sensors", "NUM", numCreated);
- }
+ lg2::debug("Created total of '{NUM}' sensors", "NUM", numCreated);
}
static void getPresentCpus(
diff --git a/src/smbpbi/SmbpbiSensor.cpp b/src/smbpbi/SmbpbiSensor.cpp
index e0610fe..2e5c934 100644
--- a/src/smbpbi/SmbpbiSensor.cpp
+++ b/src/smbpbi/SmbpbiSensor.cpp
@@ -41,8 +41,6 @@
#include <sys/ioctl.h>
}
-constexpr const bool debug = false;
-
constexpr const char* configInterface =
"xyz.openbmc_project.Configuration.SmbpbiVirtualEeprom";
constexpr const char* sensorRootPath = "/xyz/openbmc_project/sensors/";
@@ -285,11 +283,8 @@
data = std::numeric_limits<double>::quiet_NaN();
return 0;
}
- if (debug)
- {
- lg2::error("offset: {OFFSET} reading: {READING}", "OFFSET", offset,
- "READING", reading);
- }
+ lg2::debug("offset: {OFFSET} reading: {READING}", "OFFSET", offset,
+ "READING", reading);
if (sensorType == "temperature")
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
@@ -356,10 +351,7 @@
if (ret >= 0)
{
- if constexpr (debug)
- {
- lg2::error("Value update to {TEMP}", "TEMP", temp);
- }
+ lg2::debug("Value update to {TEMP}", "TEMP", temp);
updateValue(temp);
}
else
@@ -432,24 +424,21 @@
double minVal = loadVariant<double>(entry.second, "MinValue");
double maxVal = loadVariant<double>(entry.second, "MaxValue");
- if constexpr (debug)
- {
- lg2::info("Configuration parsed for \n\t {CONF}\nwith\n"
- "\tName: {NAME}\n"
- "\tBus: {BUS}\n"
- "\tAddress:{ADDR}\n"
- "\tOffset: {OFF}\n"
- "\tType : {TYPE}\n"
- "\tValue Type : {VALUETYPE}\n"
- "\tPollrate: {RATE}\n"
- "\tMinValue: {MIN}\n"
- "\tMaxValue: {MAX}\n",
- "CONF", entry.first, "NAME", name, "BUS",
- static_cast<int>(busId), "ADDR",
- static_cast<int>(addr), "OFF", static_cast<int>(off),
- "UNITS", sensorUnits, "VALUETYPE", valueType, "RATE",
- rate, "MIN", minVal, "MAX", maxVal);
- }
+ lg2::debug(
+ "Configuration parsed for \n\t {CONF}\nwith\n"
+ "\tName: {NAME}\n"
+ "\tBus: {BUS}\n"
+ "\tAddress:{ADDR}\n"
+ "\tOffset: {OFF}\n"
+ "\tType : {TYPE}\n"
+ "\tValue Type : {VALUETYPE}\n"
+ "\tPollrate: {RATE}\n"
+ "\tMinValue: {MIN}\n"
+ "\tMaxValue: {MAX}\n",
+ "CONF", entry.first, "NAME", name, "BUS",
+ static_cast<int>(busId), "ADDR", static_cast<int>(addr), "OFF",
+ static_cast<int>(off), "UNITS", sensorUnits, "VALUETYPE",
+ valueType, "RATE", rate, "MIN", minVal, "MAX", maxVal);
auto& sensor = sensors[name];
sensor = nullptr;