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/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(