prefer std::format over fmt
Switch to std::format to remove the dependency on fmt.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Id3a1295ba8a90fb756cfc500892dcc5b3235e27b
diff --git a/occ_command.cpp b/occ_command.cpp
index 2ebacb0..e2ec8a7 100644
--- a/occ_command.cpp
+++ b/occ_command.cpp
@@ -4,7 +4,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <fmt/core.h>
#include <unistd.h>
#include <org/open_power/OCC/Device/error.hpp>
@@ -13,6 +12,7 @@
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
#include <memory>
#include <string>
@@ -39,14 +39,14 @@
{
if (i % 16 == 0)
{
- s += fmt::format("{:04X}: ", i);
+ s += std::format("{:04X}: ", i);
}
else if (i % 4 == 0)
{
s += " ";
}
- s += fmt::format("{:02X}", data.at(i));
+ s += std::format("{:02X}", data.at(i));
if ((i % 16 == 15) || (i == (dump_length - 1)))
{
@@ -66,7 +66,7 @@
std::placeholders::_1))
{
log<level::DEBUG>(
- fmt::format("OccCommand::OccCommand(path={}, devicePath={}", this->path,
+ std::format("OccCommand::OccCommand(path={}, devicePath={}", this->path,
devicePath)
.c_str());
}
@@ -76,14 +76,14 @@
using namespace sdbusplus::org::open_power::OCC::Device::Error;
log<level::DEBUG>(
- fmt::format("OccCommand::openDevice: calling open {}", devicePath)
+ std::format("OccCommand::openDevice: calling open {}", devicePath)
.c_str());
fd = open(devicePath.c_str(), O_RDWR | O_NONBLOCK);
if (fd < 0)
{
const int openErrno = errno;
log<level::ERR>(
- fmt::format(
+ std::format(
"OccCommand::openDevice: open failed (errno={}, path={})",
openErrno, devicePath)
.c_str());
@@ -126,7 +126,7 @@
const uint8_t cmd_type = command[0];
#ifdef TRACE_PACKETS
log<level::INFO>(
- fmt::format("OCC{}: Sending 0x{:02X} command (length={}, {})",
+ std::format("OCC{}: Sending 0x{:02X} command (length={}, {})",
occInstance, cmd_type, command.size(), devicePath)
.c_str());
dump_hex(command);
@@ -142,7 +142,7 @@
if ((rc < 0) || (rc != (int)command.size()))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"OccCommand::send: write(OCC{}, command:0x{:02X}) failed with errno={} (retries={})",
occInstance, cmd_type, writeErrno, retries)
.c_str());
@@ -181,7 +181,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"OccCommand::send: read(OCC{}, command:0x{:02X}) failed with errno={} (rspSize={}, retries={})",
occInstance, cmd_type, readErrno, response.size(),
retries)
@@ -200,7 +200,7 @@
{
#ifdef TRACE_PACKETS
log<level::INFO>(
- fmt::format(
+ std::format(
"OCC{}: Received 0x{:02X} response (length={} w/checksum)",
occInstance, cmd_type, response.size())
.c_str());
@@ -223,7 +223,7 @@
if (calcChecksum != rspChecksum)
{
log<level::ERR>(
- fmt::format("OCC{}: Checksum Mismatch: response "
+ std::format("OCC{}: Checksum Mismatch: response "
"0x{:04X}, calculated 0x{:04X}",
occInstance, rspChecksum, calcChecksum)
.c_str());
@@ -245,7 +245,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"OccCommand::send: Response command mismatch "
"(sent: "
"0x{:02X}, rsp: 0x{:02X}, rsp seq#: 0x{:02X}",
@@ -258,7 +258,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"OccCommand::send: Invalid OCC{} response length: {}",
occInstance, response.size())
.c_str());
diff --git a/occ_command.hpp b/occ_command.hpp
index a8c5dd4..58d351a 100644
--- a/occ_command.hpp
+++ b/occ_command.hpp
@@ -3,13 +3,13 @@
#include "occ_errors.hpp"
#include "utils.hpp"
-#include <fmt/format.h>
-
#include <org/open_power/OCC/PassThrough/server.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
+#include <format>
#include <string>
+#include <utility>
namespace open_power
{
@@ -62,7 +62,7 @@
static inline auto format_as(SysPwrMode spm)
{
- return fmt::underlying(spm);
+ return std::to_underlying(spm);
}
// Only some of the SysPwrModes are currently supported and allowed to be set
@@ -98,7 +98,7 @@
static inline auto format_as(CmdStatus cs)
{
- return fmt::underlying(cs);
+ return std::to_underlying(cs);
}
/** @brief Trace block of data in hex with log<level:INFO>
diff --git a/occ_dbus.cpp b/occ_dbus.cpp
index 811f1ab..fb2ff27 100644
--- a/occ_dbus.cpp
+++ b/occ_dbus.cpp
@@ -2,10 +2,9 @@
#include "utils.hpp"
-#include <fmt/core.h>
-
#include <phosphor-logging/log.hpp>
+#include <format>
#include <iostream>
namespace open_power
@@ -215,7 +214,7 @@
paths.end())
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Could not find a chassis out of {} chassis objects",
paths.size())
.c_str());
@@ -227,7 +226,7 @@
catch (const std::exception& e)
{
log<level::ERR>(
- fmt::format("Error looking up chassis objects: {}", e.what())
+ std::format("Error looking up chassis objects: {}", e.what())
.c_str());
abort();
}
diff --git a/occ_device.cpp b/occ_device.cpp
index c83b1ff..ded5db9 100644
--- a/occ_device.cpp
+++ b/occ_device.cpp
@@ -25,7 +25,7 @@
}
catch (const std::exception& e)
{
- log<level::ERR>(fmt::format("Failed to set {} active: {}",
+ log<level::ERR>(std::format("Failed to set {} active: {}",
devPath.c_str(), e.what())
.c_str());
}
@@ -152,7 +152,7 @@
catch (const fs::filesystem_error& e)
{
log<level::ERR>(
- fmt::format("getFilenameByRegex: Failed to get filename: {}",
+ std::format("getFilenameByRegex: Failed to get filename: {}",
e.what())
.c_str());
}
diff --git a/occ_errors.cpp b/occ_errors.cpp
index 63c1881..5c9c48f 100644
--- a/occ_errors.cpp
+++ b/occ_errors.cpp
@@ -2,7 +2,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <fmt/core.h>
#include <sys/ioctl.h>
#include <unistd.h>
@@ -11,6 +10,8 @@
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+
+#include <format>
namespace open_power
{
namespace occ
@@ -31,7 +32,7 @@
if (fd < 0)
{
log<level::ERR>(
- fmt::format("Error::openFile: open failed (errno={})", open_errno)
+ std::format("Error::openFile: open failed (errno={})", open_errno)
.c_str());
elog<OpenFailure>(phosphor::logging::org::open_power::OCC::Device::
OpenFailure::CALLOUT_ERRNO(open_errno),
diff --git a/occ_ffdc.cpp b/occ_ffdc.cpp
index 973a554..131913b 100644
--- a/occ_ffdc.cpp
+++ b/occ_ffdc.cpp
@@ -4,7 +4,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <fmt/core.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
@@ -17,6 +16,8 @@
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/Logging/Create/server.hpp>
+#include <format>
+
namespace open_power
{
namespace occ
@@ -43,7 +44,7 @@
pelFFDCInfo;
log<level::INFO>(
- fmt::format("Creating PEL for OCC{} with SBE FFDC: {} - SRC6: 0x{:08X}",
+ std::format("Creating PEL for OCC{} with SBE FFDC: {} - SRC6: 0x{:08X}",
src6 >> 16, path, src6)
.c_str());
@@ -92,7 +93,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("Failed to create PEL: {}", e.what()).c_str());
+ std::format("Failed to create PEL: {}", e.what()).c_str());
}
return plid;
@@ -118,7 +119,7 @@
additionalData.emplace("OCC", std::to_string(instance));
log<level::INFO>(
- fmt::format("Creating OCC Reset PEL for OCC{}: {}", instance, path)
+ std::format("Creating OCC Reset PEL for OCC{}: {}", instance, path)
.c_str());
auto& bus = utils::getBus();
@@ -150,7 +151,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("Failed to create OCC Reset PEL: {}", e.what())
+ std::format("Failed to create OCC Reset PEL: {}", e.what())
.c_str());
}
}
@@ -239,7 +240,7 @@
if (journalFile && journalFile->fd() != -1)
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"addJournalEntries: Added up to {} journal entries for {}",
lines, executable)
.c_str());
@@ -248,7 +249,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"addJournalEntries: Failed to add journal entries for {}",
executable)
.c_str());
@@ -275,7 +276,7 @@
{
auto e = errno;
log<level::ERR>(
- fmt::format(
+ std::format(
"makeJsonFFDCFile: Failed call to write JSON FFDC file, errno={}",
e)
.c_str());
@@ -285,7 +286,7 @@
{
auto e = errno;
log<level::ERR>(
- fmt::format("makeJsonFFDCFile: Failed called to mkostemp, errno={}",
+ std::format("makeJsonFFDCFile: Failed called to mkostemp, errno={}",
e)
.c_str());
}
@@ -429,7 +430,7 @@
{
auto e = errno;
log<level::ERR>(
- fmt::format("FFDCFile: Could not open FFDC file {}. errno {}",
+ std::format("FFDCFile: Could not open FFDC file {}. errno {}",
_name.string(), e)
.c_str());
}
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 70adeca..fa93dad 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -89,7 +89,7 @@
prevOCCSearch = occs;
log<level::INFO>(
- fmt::format(
+ std::format(
"Manager::findAndCreateObjects(): Waiting for OCCs (currently {})",
occs.size())
.c_str());
@@ -104,7 +104,7 @@
std::sort(occs.begin(), occs.end());
log<level::INFO>(
- fmt::format(
+ std::format(
"Manager::findAndCreateObjects(): Creating {} OCC Status Objects",
occs.size())
.c_str());
@@ -151,7 +151,7 @@
else
{
log<level::INFO>(
- fmt::format(
+ std::format(
"Manager::findAndCreateObjects(): Waiting for {} to complete...",
HOST_ON_FILE)
.c_str());
@@ -189,7 +189,7 @@
{
queuedActiveState.erase(match);
log<level::INFO>(
- fmt::format(
+ std::format(
"checkAllActiveSensors(): OCC{} is ACTIVE (queued)",
instance)
.c_str());
@@ -201,7 +201,7 @@
if (!tracedSensorWait)
{
log<level::INFO>(
- fmt::format(
+ std::format(
"checkAllActiveSensors(): Waiting on OCC{} Active sensor",
instance)
.c_str());
@@ -320,7 +320,7 @@
if (statusObjects.back()->isMasterOcc())
{
log<level::INFO>(
- fmt::format("Manager::createObjects(): OCC{} is the master",
+ std::format("Manager::createObjects(): OCC{} is the master",
statusObjects.back()->getOccInstanceID())
.c_str());
_pollTimer->setEnabled(false);
@@ -373,7 +373,7 @@
if (!_pollTimer->isEnabled())
{
log<level::INFO>(
- fmt::format("Manager: OCCs will be polled every {} seconds",
+ std::format("Manager: OCCs will be polled every {} seconds",
pollInterval)
.c_str());
@@ -391,7 +391,7 @@
else
{
log<level::ERR>(
- fmt::format("OCC{} disabled, but currently no active OCCs",
+ std::format("OCC{} disabled, but currently no active OCCs",
instance)
.c_str());
}
@@ -471,7 +471,7 @@
if (obj != statusObjects.end() && (*obj)->occActive())
{
log<level::INFO>(
- fmt::format("SBE timeout, requesting HRESET (OCC{})", instance)
+ std::format("SBE timeout, requesting HRESET (OCC{})", instance)
.c_str());
setSBEState(instance, SBE_STATE_NOT_USABLE);
@@ -493,7 +493,7 @@
if (!hostRunning && (status == true))
{
log<level::WARNING>(
- fmt::format(
+ std::format(
"updateOCCActive: Host is not running yet (OCC{} active={}), clearing sensor received",
instance, status)
.c_str());
@@ -509,7 +509,7 @@
}
else
{
- log<level::INFO>(fmt::format("updateOCCActive: OCC{} active={}",
+ log<level::INFO>(std::format("updateOCCActive: OCC{} active={}",
instance, status)
.c_str());
(*obj)->setPldmSensorReceived(true);
@@ -521,7 +521,7 @@
if (hostRunning)
{
log<level::WARNING>(
- fmt::format(
+ std::format(
"updateOCCActive: No status object to update for OCC{} (active={})",
instance, status)
.c_str());
@@ -531,7 +531,7 @@
if (status == true)
{
log<level::WARNING>(
- fmt::format(
+ std::format(
"updateOCCActive: No status objects and Host is not running yet (OCC{} active={})",
instance, status)
.c_str());
@@ -573,7 +573,7 @@
if (success)
{
log<level::INFO>(
- fmt::format("HRESET succeeded (OCC{})", instance).c_str());
+ std::format("HRESET succeeded (OCC{})", instance).c_str());
setSBEState(instance, SBE_STATE_BOOTED);
@@ -585,7 +585,7 @@
if (sbeCanDump(instance))
{
log<level::INFO>(
- fmt::format("HRESET failed (OCC{}), triggering SBE dump", instance)
+ std::format("HRESET failed (OCC{}), triggering SBE dump", instance)
.c_str());
auto& bus = utils::getBus();
@@ -753,7 +753,7 @@
{
// No OCCs running, so poll timer will not be restarted
log<level::INFO>(
- fmt::format(
+ std::format(
"Manager::pollerTimerExpired: poll timer will not be restarted")
.c_str());
}
@@ -785,7 +785,7 @@
catch (const std::system_error& e)
{
log<level::DEBUG>(
- fmt::format("readTempSensors: Failed reading {}, errno = {}",
+ std::format("readTempSensors: Failed reading {}, errno = {}",
file.path().string(), e.code().value())
.c_str());
continue;
@@ -803,7 +803,7 @@
catch (const std::system_error& e)
{
log<level::DEBUG>(
- fmt::format("readTempSensors: Failed reading {}, errno = {}",
+ std::format("readTempSensors: Failed reading {}, errno = {}",
filePathString + fruTypeSuffix, e.code().value())
.c_str());
continue;
@@ -843,7 +843,7 @@
if (iter == dimmTempSensorName.end())
{
log<level::ERR>(
- fmt::format(
+ std::format(
"readTempSensors: Fru type error! fruTypeValue = {}) ",
fruTypeValue)
.c_str());
@@ -898,7 +898,7 @@
catch (const std::system_error& e)
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"readTempSensors: Failed reading {}, errno = {}",
filePathString + maxSuffix, e.code().value())
.c_str());
@@ -913,7 +913,7 @@
catch (const std::system_error& e)
{
log<level::DEBUG>(
- fmt::format("readTempSensors: Failed reading {}, errno = {}",
+ std::format("readTempSensors: Failed reading {}, errno = {}",
filePathString + faultSuffix, e.code().value())
.c_str());
continue;
@@ -935,7 +935,7 @@
catch (const std::system_error& e)
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"readTempSensors: Failed reading {}, errno = {}",
filePathString + inputSuffix, e.code().value())
.c_str());
@@ -1049,7 +1049,7 @@
catch (const std::system_error& e)
{
log<level::DEBUG>(
- fmt::format("readPowerSensors: Failed reading {}, errno = {}",
+ std::format("readPowerSensors: Failed reading {}, errno = {}",
file.path().string(), e.code().value())
.c_str());
continue;
@@ -1083,7 +1083,7 @@
catch (const std::system_error& e)
{
log<level::DEBUG>(
- fmt::format("readPowerSensors: Failed reading {}, errno = {}",
+ std::format("readPowerSensors: Failed reading {}, errno = {}",
filePathString + inputSuffix, e.code().value())
.c_str());
continue;
@@ -1164,7 +1164,7 @@
if (!tracedError[id])
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Manager::getSensorValues: OCC{} sensor path missing: {}",
id, sensorPath.c_str())
.c_str());
@@ -1198,7 +1198,7 @@
// Round to nearest meter
altitude = uint16_t(sensorVal + 0.5);
}
- log<level::DEBUG>(fmt::format("readAltitude: sensor={} ({}m)",
+ log<level::DEBUG>(std::format("readAltitude: sensor={} ({}m)",
sensorVal, altitude)
.c_str());
traceAltitudeErr = true;
@@ -1209,7 +1209,7 @@
{
traceAltitudeErr = false;
log<level::DEBUG>(
- fmt::format("Invalid altitude value: {}", sensorVal)
+ std::format("Invalid altitude value: {}", sensorVal)
.c_str());
}
}
@@ -1220,7 +1220,7 @@
{
traceAltitudeErr = false;
log<level::INFO>(
- fmt::format("Unable to read Altitude: {}", e.what()).c_str());
+ std::format("Unable to read Altitude: {}", e.what()).c_str());
}
altitude = 0xFFFF; // not available
}
@@ -1263,7 +1263,7 @@
if (truncatedTemp != ambient)
{
log<level::DEBUG>(
- fmt::format("ambientCallback: Ambient change from {} to {}C",
+ std::format("ambientCallback: Ambient change from {} to {}C",
ambient, currentTemp)
.c_str());
@@ -1275,7 +1275,7 @@
}
log<level::DEBUG>(
- fmt::format("ambientCallback: Ambient: {}C, altitude: {}m", ambient,
+ std::format("ambientCallback: Ambient: {}C, altitude: {}m", ambient,
altitude)
.c_str());
#ifdef POWER10
@@ -1314,7 +1314,7 @@
{
// Not all OCCs went active
log<level::WARNING>(
- fmt::format(
+ std::format(
"occsNotAllRunning: Active OCC count ({}) does not match expected count ({})",
activeCount, statusObjects.size())
.c_str());
@@ -1343,7 +1343,7 @@
{
queuedActiveState.erase(match);
log<level::INFO>(
- fmt::format(
+ std::format(
"validateOccMaster: OCC{} is ACTIVE (queued)",
instance)
.c_str());
@@ -1356,7 +1356,7 @@
if (obj->occActive())
{
log<level::INFO>(
- fmt::format(
+ std::format(
"validateOccMaster: OCC{} is ACTIVE after reading sensor",
instance)
.c_str());
@@ -1366,7 +1366,7 @@
else
{
log<level::WARNING>(
- fmt::format(
+ std::format(
"validateOccMaster: HOST is not running (OCC{})",
instance)
.c_str());
@@ -1386,7 +1386,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"validateOccMaster: Multiple OCC masters! ({} and {})",
masterInstance, instance)
.c_str());
@@ -1399,7 +1399,7 @@
if (masterInstance < 0)
{
log<level::ERR>(
- fmt::format("validateOccMaster: Master OCC not found! (of {} OCCs)",
+ std::format("validateOccMaster: Master OCC not found! (of {} OCCs)",
statusObjects.size())
.c_str());
// request reset
@@ -1409,7 +1409,7 @@
else
{
log<level::INFO>(
- fmt::format("validateOccMaster: OCC{} is master of {} OCCs",
+ std::format("validateOccMaster: OCC{} is master of {} OCCs",
masterInstance, activeCount)
.c_str());
#ifdef POWER10
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp
index 6834398..77cd064 100644
--- a/occ_pass_through.cpp
+++ b/occ_pass_through.cpp
@@ -4,7 +4,6 @@
#include <errno.h>
#include <fcntl.h>
-#include <fmt/core.h>
#include <unistd.h>
#include <org/open_power/OCC/Device/error.hpp>
@@ -13,6 +12,7 @@
#include <phosphor-logging/log.hpp>
#include <algorithm>
+#include <format>
#include <memory>
#include <string>
@@ -77,7 +77,7 @@
if (!occActive)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PassThrough::send() - OCC{} not active, command not sent",
occInstance)
.c_str());
@@ -85,7 +85,7 @@
}
log<level::INFO>(
- fmt::format("PassThrough::send() Sending 0x{:02X} command to OCC{}",
+ std::format("PassThrough::send() Sending 0x{:02X} command to OCC{}",
command.front(), occInstance)
.c_str());
CmdStatus status = occCmd.send(command, response);
@@ -94,7 +94,7 @@
if (response.size() >= 5)
{
log<level::DEBUG>(
- fmt::format("PassThrough::send() response had {} bytes",
+ std::format("PassThrough::send() response had {} bytes",
response.size())
.c_str());
}
@@ -107,7 +107,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PassThrough::send(): OCC command failed with status {}",
uint32_t(status))
.c_str());
@@ -125,7 +125,7 @@
(!VALID_OEM_POWER_MODE_SETTING(newMode)))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PassThrough::setMode() Unsupported mode {} requested (0x{:04X})",
newMode, modeData)
.c_str());
@@ -136,7 +136,7 @@
(modeData == 0))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PassThrough::setMode() Mode {} requires non-zero frequency point.",
newMode)
.c_str());
@@ -150,13 +150,13 @@
}
log<level::INFO>(
- fmt::format("PassThrough::setMode() Setting Power Mode {} (data: {})",
+ std::format("PassThrough::setMode() Setting Power Mode {} (data: {})",
newMode, modeData)
.c_str());
return pmode->setMode(newMode, modeData);
#else
log<level::DEBUG>(
- fmt::format(
+ std::format(
"PassThrough::setMode() No support to setting Power Mode {} (data: {})",
mode, modeData)
.c_str());
diff --git a/occ_pass_through.hpp b/occ_pass_through.hpp
index f11695c..3cc462b 100644
--- a/occ_pass_through.hpp
+++ b/occ_pass_through.hpp
@@ -4,13 +4,12 @@
#include "powermode.hpp"
#include "utils.hpp"
-#include <fmt/core.h>
-
#include <org/open_power/OCC/PassThrough/server.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
+#include <format>
#include <string>
namespace open_power
diff --git a/occ_presence.cpp b/occ_presence.cpp
index a8a5115..73ccf66 100644
--- a/occ_presence.cpp
+++ b/occ_presence.cpp
@@ -46,7 +46,7 @@
auto occsPresent = std::stoi(data, nullptr, 0);
if (manager.getNumOCCs() != occsPresent)
{
- log<level::ERR>(fmt::format("OCC presence mismatch - BMC: {}, OCC: {}",
+ log<level::ERR>(std::format("OCC presence mismatch - BMC: {}, OCC: {}",
manager.getNumOCCs(), occsPresent)
.c_str());
if (callBack)
diff --git a/occ_status.cpp b/occ_status.cpp
index b89e469..078447c 100644
--- a/occ_status.cpp
+++ b/occ_status.cpp
@@ -5,11 +5,10 @@
#include "powermode.hpp"
#include "utils.hpp"
-#include <fmt/core.h>
-
#include <phosphor-logging/log.hpp>
#include <filesystem>
+#include <format>
namespace open_power
{
@@ -26,7 +25,7 @@
{
if (value != this->occActive())
{
- log<level::INFO>(fmt::format("Status::occActive OCC{} changed to {}",
+ log<level::INFO>(std::format("Status::occActive OCC{} changed to {}",
instance, value)
.c_str());
if (value)
@@ -148,7 +147,7 @@
void Status::resetOCC()
{
log<level::INFO>(
- fmt::format(">>Status::resetOCC() - requesting reset for OCC{}",
+ std::format(">>Status::resetOCC() - requesting reset for OCC{}",
instance)
.c_str());
#ifdef PLDM
@@ -221,7 +220,7 @@
if (status != CmdStatus::SUCCESS)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Status::occsWentActive: OCC mode change failed with status {}",
status)
.c_str());
@@ -234,7 +233,7 @@
if (status != CmdStatus::SUCCESS)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Status::occsWentActive: Sending Idle Power Save Config data failed with status {}",
status)
.c_str());
@@ -260,7 +259,7 @@
// Get latest readings from manager
manager.getAmbientData(ambientValid, ambientTemp, altitude);
log<level::DEBUG>(
- fmt::format("sendAmbient: valid: {}, Ambient: {}C, altitude: {}m",
+ std::format("sendAmbient: valid: {}, Ambient: {}C, altitude: {}m",
ambientValid, ambientTemp, altitude)
.c_str());
}
@@ -278,7 +277,7 @@
cmd.push_back(0x00); // Reserved (3 bytes)
cmd.push_back(0x00);
cmd.push_back(0x00);
- log<level::DEBUG>(fmt::format("sendAmbient: SEND_AMBIENT "
+ log<level::DEBUG>(std::format("sendAmbient: SEND_AMBIENT "
"command to OCC{} ({} bytes)",
instance, cmd.size())
.c_str());
@@ -290,7 +289,7 @@
if (RspStatus::SUCCESS != RspStatus(rsp[2]))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"sendAmbient: SEND_AMBIENT failed with rspStatus 0x{:02X}",
rsp[2])
.c_str());
@@ -301,7 +300,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"sendAmbient: INVALID SEND_AMBIENT response length:{}",
rsp.size())
.c_str());
@@ -312,7 +311,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"sendAmbient: SEND_AMBIENT FAILED! with status 0x{:02X}",
status)
.c_str());
@@ -333,7 +332,7 @@
if (this->occActive())
{
log<level::INFO>(
- fmt::format(
+ std::format(
"safeStateDelayExpired: OCC{} is in SAFE state, requesting reset",
instance)
.c_str());
@@ -354,7 +353,7 @@
if (!hwmonPath.empty())
{
log<level::ERR>(
- fmt::format("Status::getHwmonPath(): path no longer exists: {}",
+ std::format("Status::getHwmonPath(): path no longer exists: {}",
hwmonPath.c_str())
.c_str());
hwmonPath.clear();
@@ -381,7 +380,7 @@
if (!tracedFail[instance])
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Status::getHwmonPath(): Found multiple ({}) hwmon paths!",
numDirs)
.c_str());
@@ -394,7 +393,7 @@
if (!tracedFail[instance])
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Status::getHwmonPath(): error accessing {}: {}",
prefixPath.c_str(), e.what())
.c_str());
@@ -431,7 +430,7 @@
{
// Trace OCC state changes
log<level::INFO>(
- fmt::format(
+ std::format(
"Status::readOccState: OCC{} state 0x{:02X} (lastState: 0x{:02X})",
instance, state, lastState)
.c_str());
@@ -454,7 +453,7 @@
if (status != CmdStatus::SUCCESS)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"readOccState: Sending Ambient failed with status {}",
status)
.c_str());
@@ -505,7 +504,7 @@
{
// If not able to read, OCC may be offline
log<level::ERR>(
- fmt::format("Status::readOccState: open failed (errno={})",
+ std::format("Status::readOccState: open failed (errno={})",
openErrno)
.c_str());
}
@@ -515,7 +514,7 @@
if (state != lastState)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Status::readOccState: OCC{} Invalid state 0x{:02X} (last state: 0x{:02X})",
instance, state, lastState)
.c_str());
@@ -598,7 +597,7 @@
if (newThrottleCause == THROTTLED_NONE)
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"updateThrottle: OCC{} no longer throttled (prior reason: {})",
instance, throttleCause)
.c_str());
@@ -609,7 +608,7 @@
else
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"updateThrottle: OCC{} is throttled with reason {} (prior reason: {})",
instance, newThrottleCause, throttleCause)
.c_str());
@@ -643,7 +642,7 @@
{
std::string managingPath = path + "/power_managing";
log<level::DEBUG>(
- fmt::format("readProcAssociation: getting endpoints for {} ({})",
+ std::format("readProcAssociation: getting endpoints for {} ({})",
managingPath, path)
.c_str());
try
@@ -656,14 +655,14 @@
{
procPath = result[0];
log<level::INFO>(
- fmt::format("readProcAssociation: OCC{} has proc={}", instance,
+ std::format("readProcAssociation: OCC{} has proc={}", instance,
procPath.c_str())
.c_str());
}
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"readProcAssociation: No processor associated with OCC{} / {}",
instance, path)
.c_str());
@@ -672,7 +671,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"readProcAssociation: Unable to get proc assocated with {} - {}",
path, e.what())
.c_str());
diff --git a/pldm.cpp b/pldm.cpp
index 3c71eb9..fe38879 100644
--- a/pldm.cpp
+++ b/pldm.cpp
@@ -2,7 +2,6 @@
#include "file.hpp"
-#include <fmt/core.h>
#include <libpldm/entity.h>
#include <libpldm/platform.h>
#include <libpldm/state_set.h>
@@ -16,6 +15,7 @@
#include <sdeventplus/source/time.hpp>
#include <algorithm>
+#include <format>
namespace pldm
{
@@ -51,7 +51,7 @@
if (!tracedError)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"fetchSensorInfo: Failed to find stateSetID:{} PDR: {}",
stateSetId, e.what())
.c_str());
@@ -64,7 +64,7 @@
if (!tracedError)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"fetchSensorInfo: state sensor PDRs ({}) not present",
stateSetId)
.c_str());
@@ -77,7 +77,7 @@
if (tracedError)
{
log<level::INFO>(
- fmt::format("fetchSensorInfo: found {} PDRs", pdrs.size()).c_str());
+ std::format("fetchSensorInfo: found {} PDRs", pdrs.size()).c_str());
tracedError = false;
}
@@ -165,7 +165,7 @@
PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE))
{
log<level::INFO>(
- fmt::format("PLDM: OCC{} is RUNNING", instance).c_str());
+ std::format("PLDM: OCC{} is RUNNING", instance).c_str());
isRunning = true;
}
else if (eventState ==
@@ -173,7 +173,7 @@
PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STOPPED))
{
log<level::INFO>(
- fmt::format("PLDM: OCC{} has now STOPPED", instance)
+ std::format("PLDM: OCC{} has now STOPPED", instance)
.c_str());
}
else if (eventState ==
@@ -181,7 +181,7 @@
PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_DORMANT))
{
log<level::INFO>(
- fmt::format(
+ std::format(
"PLDM: OCC{} has now STOPPED and system is in SAFE MODE",
instance)
.c_str());
@@ -192,7 +192,7 @@
else
{
log<level::INFO>(
- fmt::format("PLDM: Unexpected PLDM state {} for OCC{}",
+ std::format("PLDM: Unexpected PLDM state {} for OCC{}",
eventState, instance)
.c_str());
}
@@ -218,7 +218,7 @@
if (eventState == static_cast<EventState>(SBE_HRESET_NOT_READY))
{
log<level::INFO>(
- fmt::format("pldm: HRESET is NOT READY (OCC{})",
+ std::format("pldm: HRESET is NOT READY (OCC{})",
instance)
.c_str());
}
@@ -260,13 +260,13 @@
if (!sensorToOCCInstance.empty())
{
log<level::INFO>(
- fmt::format("clearData: Clearing sensorToOCCInstance ({} entries)",
+ std::format("clearData: Clearing sensorToOCCInstance ({} entries)",
sensorToOCCInstance.size())
.c_str());
for (auto entry : sensorToOCCInstance)
{
log<level::INFO>(
- fmt::format("clearData: OCC{} / sensorID: 0x{:04X}",
+ std::format("clearData: OCC{} / sensorID: 0x{:04X}",
entry.second, entry.first)
.c_str());
callBack(entry.second, false);
@@ -276,7 +276,7 @@
if (!occInstanceToEffecter.empty())
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"clearData: Clearing occInstanceToEffecter ({} entries)",
occInstanceToEffecter.size())
.c_str());
@@ -285,7 +285,7 @@
if (!sensorToSBEInstance.empty())
{
log<level::DEBUG>(
- fmt::format("clearData: Clearing sensorToSBEInstance ({} entries)",
+ std::format("clearData: Clearing sensorToSBEInstance ({} entries)",
sensorToSBEInstance.size())
.c_str());
sensorToSBEInstance.clear();
@@ -293,7 +293,7 @@
if (!sbeInstanceToEffecter.empty())
{
log<level::DEBUG>(
- fmt::format(
+ std::format(
"clearData: Clearing sbeInstanceToEffecter ({} entries)",
sbeInstanceToEffecter.size())
.c_str());
@@ -433,7 +433,7 @@
if (effecterEntry == occInstanceToEffecter.end())
{
log<level::ERR>(
- fmt::format(
+ std::format(
"pldm: Failed to find a matching effecter for OCC instance {}",
occInstanceId)
.c_str());
@@ -459,7 +459,7 @@
else
{
log<level::ERR>(
- fmt::format("resetOCC: HOST is not running (OCC{})", occInstanceId)
+ std::format("resetOCC: HOST is not running (OCC{})", occInstanceId)
.c_str());
clearData();
}
@@ -503,7 +503,7 @@
}
else
{
- log<level::ERR>(fmt::format("sendHRESET: HOST is not running (OCC{})",
+ log<level::ERR>(std::format("sendHRESET: HOST is not running (OCC{})",
sbeInstanceId)
.c_str());
clearData();
@@ -526,14 +526,14 @@
uint8_t newInstanceId;
reply.read(newInstanceId);
mctpInstance = newInstanceId;
- log<level::INFO>(fmt::format("pldm: got new InstanceId: {}",
+ log<level::INFO>(std::format("pldm: got new InstanceId: {}",
mctpInstance.value())
.c_str());
}
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("pldm: GetInstanceId failed: {}", e.what())
+ std::format("pldm: GetInstanceId failed: {}", e.what())
.c_str());
return false;
}
@@ -557,7 +557,7 @@
if (pldmFd == PLDM_REQUESTER_OPEN_FAIL)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"sendPldm: Failed to connect to MCTP socket, errno={}/{}",
openErrno, strerror(openErrno))
.c_str());
@@ -572,7 +572,7 @@
// Send PLDM request
log<level::INFO>(
- fmt::format(
+ std::format(
"sendPldm: calling pldm_send(OCC{}, instance:{}, {} bytes)",
instance, mctpInstance.value(), request.size())
.c_str());
@@ -585,7 +585,7 @@
if (pldmRc != PLDM_REQUESTER_SUCCESS)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"sendPldm: pldm_send failed with rc={} and errno={}/{}",
static_cast<
std::underlying_type_t<pldm_requester_error_codes>>(
@@ -605,7 +605,7 @@
else // not expecting the response
{
log<level::INFO>(
- fmt::format(
+ std::format(
"sendPldm: calling pldm_send(mctpID:{}, fd:{}, {} bytes) for OCC{}",
mctpEid, pldmFd, request.size(), instance)
.c_str());
@@ -614,7 +614,7 @@
if (rc)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"sendPldm: pldm_send(mctpID:{}, fd:{}, {} bytes) failed with rc={} and errno={}/{}",
mctpEid, pldmFd, request.size(),
static_cast<
@@ -640,7 +640,7 @@
if (rc < 0)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"registerPldmRspCallback: sd_event_add_io: Error({})={} : fd={}",
rc, strerror(-rc), pldmFd)
.c_str());
@@ -658,7 +658,7 @@
if (!pldmResponseReceived)
{
log<level::WARNING>(
- fmt::format(
+ std::format(
"pldmRspExpired: timerCallback - timeout waiting for pldm response for OCC{}",
pldmResponseOcc)
.c_str());
@@ -689,7 +689,7 @@
if (!(revents & EPOLLIN))
{
log<level::INFO>(
- fmt::format("pldmRspCallback - revents={:08X}", revents).c_str());
+ std::format("pldmRspCallback - revents={:08X}", revents).c_str());
return -1;
}
@@ -706,7 +706,7 @@
size_t responseMsgSize{};
log<level::INFO>(
- fmt::format("pldmRspCallback: calling pldm_recv() instance:{}",
+ std::format("pldmRspCallback: calling pldm_recv() instance:{}",
pldmIface->mctpInstance.value())
.c_str());
auto rc = pldm_recv(mctpEid, fd, pldmIface->mctpInstance.value(),
@@ -715,7 +715,7 @@
if (rc)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"pldmRspCallback: pldm_recv failed with rc={}, errno={}/{}",
static_cast<std::underlying_type_t<pldm_requester_error_codes>>(
rc),
@@ -726,7 +726,7 @@
// We got the response for the PLDM request msg that was sent
log<level::INFO>(
- fmt::format("pldmRspCallback: pldm_recv() rsp was {} bytes",
+ std::format("pldmRspCallback: pldm_recv() rsp was {} bytes",
responseMsgSize)
.c_str());
@@ -747,7 +747,7 @@
if (response->payload[0] != PLDM_SUCCESS)
{
log<level::ERR>(
- fmt::format("pldmRspCallback: payload[0] was not success: {}",
+ std::format("pldmRspCallback: payload[0] was not success: {}",
response->payload[0])
.c_str());
pldmIface->pldmClose();
@@ -763,7 +763,7 @@
if ((msgRc != PLDM_SUCCESS) || (compCode != PLDM_SUCCESS))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"pldmRspCallback: decode_get_state_sensor_readings failed with rc={} and compCode={}",
msgRc, compCode)
.c_str());
@@ -780,14 +780,14 @@
if (occSensorState == PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE)
{
log<level::INFO>(
- fmt::format("pldmRspCallback: OCC{} is RUNNING", instance).c_str());
+ std::format("pldmRspCallback: OCC{} is RUNNING", instance).c_str());
pldmIface->callBack(instance, true);
}
else if (occSensorState ==
PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_DORMANT)
{
log<level::INFO>(
- fmt::format(
+ std::format(
"pldmRspCallback: OCC{} has now STOPPED and system is in SAFE MODE",
instance)
.c_str());
@@ -800,7 +800,7 @@
else
{
log<level::INFO>(
- fmt::format(
+ std::format(
"pldmRspCallback: OCC{} is not running (sensor state:{})",
instance, occSensorState)
.c_str());
@@ -811,7 +811,7 @@
memcpy(&pldmResponse[0], reinterpret_cast<std::uint8_t*>(response),
rspLength);
log<level::ERR>(
- fmt::format(
+ std::format(
"pldmRspCallback: Bad State - PLDM response ({} bytes) for OCC{}:",
rspLength, instance)
.c_str());
@@ -844,7 +844,7 @@
if (msgRc != PLDM_SUCCESS)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"encodeGetStateSensorRequest: Failed to encode sensorId:0x{:08X} for OCC{} (rc={})",
sensorId, instance, msgRc)
.c_str());
@@ -861,7 +861,7 @@
if (!tracedOnce)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"checkActiveSensor: already waiting on OCC{} (fd={})",
pldmResponseOcc, pldmFd)
.c_str());
@@ -886,7 +886,7 @@
// Query the OCC Active Sensor state for this instance
// SensorID sID = entry->first;
log<level::INFO>(
- fmt::format("checkActiveSensor: OCC{} / sensorID: 0x{:04X}",
+ std::format("checkActiveSensor: OCC{} / sensorID: 0x{:04X}",
instance, entry->first)
.c_str());
@@ -903,7 +903,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"checkActiveSensor: Unable to find PLDM sensor for OCC{}",
instance)
.c_str());
diff --git a/powercap.cpp b/powercap.cpp
index edfae9c..be9f90e 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -1,12 +1,11 @@
#include "occ_status.hpp"
-#include <fmt/core.h>
-
#include <phosphor-logging/log.hpp>
#include <powercap.hpp>
#include <cassert>
#include <filesystem>
+#include <format>
namespace open_power
{
@@ -52,7 +51,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"updatePcapBounds: unable to find pcap_min_soft file: {} (errno={})",
pcapBasePathname.c_str(), errno)
.c_str());
@@ -69,7 +68,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"updatePcapBounds: unable to find cap_min file: {} (errno={})",
pcapBasePathname.c_str(), errno)
.c_str());
@@ -86,7 +85,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"updatePcapBounds: unable to find cap_max file: {} (errno={})",
pcapBasePathname.c_str(), errno)
.c_str());
@@ -108,7 +107,7 @@
{
// User power cap is enabled, but does not match dbus
log<level::ERR>(
- fmt::format(
+ std::format(
"updatePcapBounds: user powercap mismatch (hwmon:{}W, bdus:{}W) - using dbus",
hwmonUserCap, dbusUserCap)
.c_str());
@@ -125,7 +124,7 @@
newCap = capSoftMin;
}
log<level::ERR>(
- fmt::format(
+ std::format(
"updatePcapBounds: user powercap {}W is outside bounds "
"(soft min:{}, min:{}, max:{})",
dbusUserCap, capSoftMin, capHardMin, capMax)
@@ -133,7 +132,7 @@
try
{
log<level::INFO>(
- fmt::format(
+ std::format(
"updatePcapBounds: Updating user powercap from {} to {}W",
hwmonUserCap, newCap)
.c_str());
@@ -145,7 +144,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"updatePcapBounds: Failed to update user powercap due to ",
e.what())
.c_str());
@@ -228,7 +227,7 @@
}
else
{
- log<level::ERR>(fmt::format("Power Cap base filename not found: {}",
+ log<level::ERR>(std::format("Power Cap base filename not found: {}",
pcapBasePathname.c_str())
.c_str());
}
@@ -252,7 +251,7 @@
if (fileName.empty())
{
log<level::ERR>(
- fmt::format("Could not find a power cap file to write to: {})",
+ std::format("Could not find a power cap file to write to: {})",
pcapBasePathname.c_str())
.c_str());
return;
@@ -266,7 +265,7 @@
std::ofstream file(fileName, std::ios::out);
if (file)
{
- log<level::INFO>(fmt::format("Writing {}uW to {}", pcapString.c_str(),
+ log<level::INFO>(std::format("Writing {}uW to {}", pcapString.c_str(),
fileName.c_str())
.c_str());
file << pcapString;
@@ -274,7 +273,7 @@
}
else
{
- log<level::ERR>(fmt::format("Failed writing {}uW to {} (errno={})",
+ log<level::ERR>(std::format("Failed writing {}uW to {} (errno={})",
microWatts, fileName.c_str(), errno)
.c_str());
}
@@ -292,7 +291,7 @@
if (userCapName.empty())
{
log<level::ERR>(
- fmt::format(
+ std::format(
"readUserCapHwmon: Could not find a power cap file to read: {})",
pcapBasePathname.c_str())
.c_str());
@@ -312,7 +311,7 @@
else
{
log<level::ERR>(
- fmt::format("readUserCapHwmon: Failed reading {} (errno={})",
+ std::format("readUserCapHwmon: Failed reading {} (errno={})",
userCapName.c_str(), errno)
.c_str());
}
@@ -354,7 +353,7 @@
{
// Ignore other properties
log<level::DEBUG>(
- fmt::format(
+ std::format(
"pcapChanged: Unknown power cap property changed {} to {}",
prop.c_str(), std::get<uint32_t>(value))
.c_str());
@@ -367,7 +366,7 @@
if (((pcap > 0) && (pcap < capSoftMin)) || ((pcap == 0) && (pcapEnabled)))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"pcapChanged: Power cap of {}W is lower than allowed (soft min:{}, min:{}) - using soft min",
pcap, capSoftMin, capHardMin)
.c_str());
@@ -377,7 +376,7 @@
else if (pcap > capMax)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"pcapChanged: Power cap of {}W is higher than allowed (max:{}) - using max",
pcap, capSoftMin, capHardMin)
.c_str());
@@ -388,7 +387,7 @@
if (changeFound)
{
log<level::INFO>(
- fmt::format(
+ std::format(
"Power Cap Property Change (cap={}W (input), enabled={})", pcap,
pcapEnabled ? 'y' : 'n')
.c_str());
@@ -416,7 +415,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"updateDbusPcapLimits: Failed to set SOFT PCAP to {}W due to {}",
softMin, e.what())
.c_str());
@@ -431,7 +430,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"updateDbusPcapLimits: Failed to set HARD PCAP to {}W due to {}",
hardMin, e.what())
.c_str());
@@ -445,7 +444,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"updateDbusPcapLimits: Failed to set MAX PCAP to {}W due to {}",
max, e.what())
.c_str());
@@ -471,7 +470,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("readDbusPcapLimits: Failed to get SOFT PCAP due to {}",
+ std::format("readDbusPcapLimits: Failed to get SOFT PCAP due to {}",
e.what())
.c_str());
softMin = 0;
@@ -487,7 +486,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("readDbusPcapLimits: Failed to get HARD PCAP due to {}",
+ std::format("readDbusPcapLimits: Failed to get HARD PCAP due to {}",
e.what())
.c_str());
hardMin = 0;
@@ -502,7 +501,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("readDbusPcapLimits: Failed to get MAX PCAP due to {}",
+ std::format("readDbusPcapLimits: Failed to get MAX PCAP due to {}",
e.what())
.c_str());
max = INT_MAX;
diff --git a/powermode.cpp b/powermode.cpp
index 342188e..88422bf 100644
--- a/powermode.cpp
+++ b/powermode.cpp
@@ -1,9 +1,10 @@
#include "powermode.hpp"
#include <fcntl.h>
-#include <fmt/core.h>
#include <sys/ioctl.h>
+#include <format>
+
#ifdef POWERVM_CHECK
#include <com/ibm/Host/Target/server.hpp>
#endif
@@ -41,7 +42,7 @@
if (masterOccPath != path)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::setMasterOcc: Master changed (was OCC{}, {})",
occInstance, masterOccPath)
.c_str());
@@ -53,7 +54,7 @@
}
path = masterOccPath;
occInstance = path.back() - '0';
- log<level::DEBUG>(fmt::format("PowerMode::setMasterOcc(OCC{}, {})",
+ log<level::DEBUG>(std::format("PowerMode::setMasterOcc(OCC{}, {})",
occInstance, path.c_str())
.c_str());
if (!occCmd)
@@ -101,7 +102,7 @@
persistedData.updateMode(newMode, 0);
log<level::INFO>(
- fmt::format("DBus Power Mode Changed: {}", propVal).c_str());
+ std::format("DBus Power Mode Changed: {}", propVal).c_str());
// Send mode change to OCC
sendModeChange();
@@ -121,7 +122,7 @@
bool PowerMode::powerModeLockStatus()
{
bool status = persistedData.getModeLock(); // read persistent data
- log<level::INFO>(fmt::format("PowerMode::powerModeLockStatus: {}",
+ log<level::INFO>(std::format("PowerMode::powerModeLockStatus: {}",
status ? "locked" : "unlocked")
.c_str());
return status;
@@ -191,7 +192,7 @@
if (mode != Mode::PowerMode::OEM)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"convertStringToMode: Invalid Power Mode specified: {}",
i_modeString)
.c_str());
@@ -229,7 +230,7 @@
}
log<level::DEBUG>(
- fmt::format("isPowerVM returning {}", powerVmTarget).c_str());
+ std::format("isPowerVM returning {}", powerVmTarget).c_str());
#endif
return powerVmTarget;
@@ -248,7 +249,7 @@
return false;
}
log<level::INFO>(
- fmt::format("PowerMode::initPersistentData: Using default mode: {}",
+ std::format("PowerMode::initPersistentData: Using default mode: {}",
currentMode)
.c_str());
@@ -295,7 +296,7 @@
!VALID_OEM_POWER_MODE_SETTING(newMode))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::updateDbusMode - Requested power mode not supported: {}",
newMode)
.c_str());
@@ -373,7 +374,7 @@
cmd.push_back(oemModeData & 0xFF); //
cmd.push_back(0x00); // reserved
log<level::INFO>(
- fmt::format(
+ std::format(
"PowerMode::sendModeChange: SET_MODE({},{}) command to OCC{} ({} bytes)",
newMode, oemModeData, occInstance, cmd.size())
.c_str());
@@ -385,7 +386,7 @@
if (RspStatus::SUCCESS != RspStatus(rsp[2]))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::sendModeChange: SET MODE failed with status 0x{:02X}",
rsp[2])
.c_str());
@@ -404,7 +405,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::sendModeChange: SET_MODE FAILED with status={}",
status)
.c_str());
@@ -413,7 +414,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::sendModeChange: Unable to set power mode to {}",
newMode)
.c_str());
@@ -443,7 +444,7 @@
{
ipsEnabled = std::get<bool>(ipsEntry->second);
log<level::INFO>(
- fmt::format("Idle Power Saver change: Enabled={}", ipsEnabled)
+ std::format("Idle Power Saver change: Enabled={}", ipsEnabled)
.c_str());
parmsChanged = true;
}
@@ -452,7 +453,7 @@
{
enterUtil = std::get<uint8_t>(ipsEntry->second);
log<level::INFO>(
- fmt::format("Idle Power Saver change: Enter Util={}%", enterUtil)
+ std::format("Idle Power Saver change: Enter Util={}%", enterUtil)
.c_str());
parmsChanged = true;
}
@@ -463,7 +464,7 @@
enterTime =
std::chrono::duration_cast<std::chrono::seconds>(ms).count();
log<level::INFO>(
- fmt::format("Idle Power Saver change: Enter Time={}sec", enterTime)
+ std::format("Idle Power Saver change: Enter Time={}sec", enterTime)
.c_str());
parmsChanged = true;
}
@@ -472,7 +473,7 @@
{
exitUtil = std::get<uint8_t>(ipsEntry->second);
log<level::INFO>(
- fmt::format("Idle Power Saver change: Exit Util={}%", exitUtil)
+ std::format("Idle Power Saver change: Exit Util={}%", exitUtil)
.c_str());
parmsChanged = true;
}
@@ -482,7 +483,7 @@
std::chrono::milliseconds ms(std::get<uint64_t>(ipsEntry->second));
exitTime = std::chrono::duration_cast<std::chrono::seconds>(ms).count();
log<level::INFO>(
- fmt::format("Idle Power Saver change: Exit Time={}sec", exitTime)
+ std::format("Idle Power Saver change: Exit Time={}sec", exitTime)
.c_str());
parmsChanged = true;
}
@@ -544,7 +545,7 @@
if (enterUtil > exitUtil)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"ERROR: Idle Power Saver Enter Utilization ({}%) is > Exit Utilization ({}%) - using Exit for both",
enterUtil, exitUtil)
.c_str());
@@ -595,7 +596,7 @@
getIPSParms(ipsEnabled, enterUtil, enterTime, exitUtil, exitTime);
log<level::INFO>(
- fmt::format(
+ std::format(
"Idle Power Saver Parameters: enabled:{}, enter:{}%/{}s, exit:{}%/{}s",
ipsEnabled, enterUtil, enterTime, exitUtil, exitTime)
.c_str());
@@ -614,7 +615,7 @@
cmd.push_back(exitTime >> 8); // Exit Delay Time
cmd.push_back(exitTime & 0xFF); //
cmd.push_back(exitUtil); // Exit Utilization
- log<level::INFO>(fmt::format("PowerMode::sendIpsData: SET_CFG_DATA[IPS] "
+ log<level::INFO>(std::format("PowerMode::sendIpsData: SET_CFG_DATA[IPS] "
"command to OCC{} ({} bytes)",
occInstance, cmd.size())
.c_str());
@@ -626,7 +627,7 @@
if (RspStatus::SUCCESS != RspStatus(rsp[2]))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::sendIpsData: SET_CFG_DATA[IPS] failed with status 0x{:02X}",
rsp[2])
.c_str());
@@ -645,7 +646,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::sendIpsData: SET_CFG_DATA[IPS] with status={}",
status)
.c_str());
@@ -660,7 +661,7 @@
if (modeData.modeInitialized)
{
log<level::INFO>(
- fmt::format(
+ std::format(
"OccPersistData: Mode: 0x{:02X}, OEM Mode Data: {} (0x{:04X} Locked{})",
modeData.mode, modeData.oemModeData, modeData.oemModeData,
modeData.modeLocked)
@@ -669,7 +670,7 @@
if (modeData.ipsInitialized)
{
log<level::INFO>(
- fmt::format(
+ std::format(
"OccPersistData: IPS enabled:{}, enter:{}%/{}s, exit:{}%/{}s",
modeData.ipsEnabled, modeData.ipsEnterUtil,
modeData.ipsEnterTime, modeData.ipsExitUtil,
@@ -690,7 +691,7 @@
}
log<level::DEBUG>(
- fmt::format(
+ std::format(
"OccPersistData::save: Writing Power Mode persisted data to {}",
opath.c_str())
.c_str());
@@ -716,7 +717,7 @@
}
log<level::DEBUG>(
- fmt::format(
+ std::format(
"OccPersistData::load: Reading Power Mode persisted data from {}",
ipath.c_str())
.c_str());
@@ -730,7 +731,7 @@
{
auto error = errno;
log<level::ERR>(
- fmt::format("OccPersistData::load: failed to read {}, errno={}",
+ std::format("OccPersistData::load: failed to read {}, errno={}",
ipath.c_str(), error)
.c_str());
modeData.modeInitialized = false;
@@ -751,7 +752,7 @@
if ((!persistedData.modeAvailable()) || (!persistedData.ipsAvailable()))
{
log<level::INFO>(
- fmt::format(
+ std::format(
"Default PowerModeProperties are now available (persistent modeAvail={}, ipsAvail={})",
persistedData.modeAvailable() ? 'y' : 'n',
persistedData.modeAvailable() ? 'y' : 'n')
@@ -787,7 +788,7 @@
if (!VALID_POWER_MODE_SETTING(defaultMode))
{
log<level::ERR>(
- fmt::format(
+ std::format(
"PowerMode::getDefaultMode: Invalid default power mode found: {}",
defaultMode)
.c_str());
@@ -799,7 +800,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format("Unable to read Default Power Mode: {}", e.what())
+ std::format("Unable to read Default Power Mode: {}", e.what())
.c_str());
return false;
}
@@ -839,7 +840,7 @@
catch (const sdbusplus::exception_t& e)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"Unable to read Default Idle Power Saver parameters so it will be disabled: {}",
e.what())
.c_str());
@@ -904,7 +905,7 @@
if (enterUtil > exitUtil)
{
log<level::ERR>(
- fmt::format(
+ std::format(
"ERROR: Default Idle Power Saver Enter Utilization ({}%) is > Exit Utilization ({}%) - using Exit for both",
enterUtil, exitUtil)
.c_str());
@@ -929,7 +930,7 @@
return false;
}
log<level::INFO>(
- fmt::format(
+ std::format(
"PowerMode::useDefaultIPSParms: Using default IPS parms: Enabled: {}, EnterUtil: {}%, EnterTime: {}s, ExitUtil: {}%, ExitTime: {}s",
ipsEnabled, enterUtil, enterTime, exitUtil, exitTime)
.c_str());
@@ -952,7 +953,7 @@
const int open_errno = errno;
if (fd < 0)
{
- log<level::ERR>(fmt::format("openIpsFile Error({})={} : File={}",
+ log<level::ERR>(std::format("openIpsFile Error({})={} : File={}",
open_errno, strerror(open_errno),
ipsStatusFile.c_str())
.c_str());
@@ -1020,7 +1021,7 @@
ipsStatusCallBack, this);
if (r < 0)
{
- log<level::ERR>(fmt::format("sd_event_add_io: Error({})={} : File={}",
+ log<level::ERR>(std::format("sd_event_add_io: Error({})={} : File={}",
r, strerror(-r), ipsStatusFile.c_str())
.c_str());
@@ -1081,7 +1082,7 @@
removeIpsWatch();
log<level::ERR>(
- fmt::format("IPS state Read Error({})={} : File={} : len={}",
+ std::format("IPS state Read Error({})={} : File={} : len={}",
readErrno, strerror(readErrno),
ipsStatusFile.c_str(), len)
.c_str());
@@ -1117,7 +1118,7 @@
// If the Retry did not get to "watching = true" we already have an
// error log, just post trace.
- log<level::ERR>(fmt::format("Retry on File seek Error({})={} : File={}",
+ log<level::ERR>(std::format("Retry on File seek Error({})={} : File={}",
open_errno, strerror(open_errno),
ipsStatusFile.c_str())
.c_str());
@@ -1150,7 +1151,7 @@
void PowerMode::updateDbusSafeMode(const bool safeModeReq)
{
log<level::DEBUG>(
- fmt::format("PowerMode:updateDbusSafeMode: Update dbus state ({})",
+ std::format("PowerMode:updateDbusSafeMode: Update dbus state ({})",
safeModeReq)
.c_str());
diff --git a/utils.cpp b/utils.cpp
index 97e33dd..4b85604 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -1,6 +1,5 @@
#include "utils.hpp"
-#include <fmt/core.h>
#include <systemd/sd-event.h>
#include <unistd.h>
@@ -10,6 +9,7 @@
#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
#include <xyz/openbmc_project/State/Host/server.hpp>
+#include <format>
#include <string>
namespace open_power
{
@@ -107,7 +107,7 @@
if (reply.is_method_error())
{
log<level::ERR>(
- fmt::format("util::setProperty: Failed to set property {}",
+ std::format("util::setProperty: Failed to set property {}",
propertyName)
.c_str());
}
@@ -116,7 +116,7 @@
{
auto error = errno;
log<level::ERR>(
- fmt::format("setProperty: failed to Set {}, errno={}, what={}",
+ std::format("setProperty: failed to Set {}, errno={}, what={}",
propertyName.c_str(), error, e.what())
.c_str());
}
@@ -161,7 +161,7 @@
if (rspObjects.empty())
{
log<level::ERR>(
- fmt::format(
+ std::format(
"util::getServiceUsingSubTree: Failed getSubTree({},0,{})",
path.c_str(), interface)
.c_str());
@@ -176,7 +176,7 @@
else
{
log<level::ERR>(
- fmt::format(
+ std::format(
"getServiceUsingSubTree: service not found for interface {} (path={})",
interface, path.c_str())
.c_str());
@@ -215,7 +215,7 @@
}
catch (const sdbusplus::exception_t& e)
{
- log<level::ERR>(fmt::format("D-Bus call exception, OBJPATH({}), "
+ log<level::ERR>(std::format("D-Bus call exception, OBJPATH({}), "
"INTERFACE({}), PROPERTY({}) EXCEPTION({})",
objPath, intf, state, e.what())
.c_str());
@@ -224,7 +224,7 @@
catch (const std::bad_variant_access& e)
{
log<level::ERR>(
- fmt::format("Exception raised while read host state({}) property "
+ std::format("Exception raised while read host state({}) property "
"value, OBJPATH({}), INTERFACE({}), EXCEPTION({})",
state, objPath, intf, e.what())
.c_str());