Replace logging with std::format
std::format is a much more modern logging solution, and gives us a lot
more flexibility, and better compile times when doing logging.
Unfortunately, given its level of compile time checks, it needs to be a
method, instead of the stream style logging we had before. This
requires a pretty substantial change. Fortunately, this change can be
largely automated, via the script included in this commit under
scripts/replace_logs.py. This is to aid people in moving their
patchsets over to the new form in the short period where old patches
will be based on the old logging. The intention is that this script
eventually goes away.
The old style logging (stream based) looked like.
BMCWEB_LOG_DEBUG << "Foo " << foo;
The new equivalent of the above would be:
BMCWEB_LOG_DEBUG("Foo {}", foo);
In the course of doing this, this also cleans up several ignored linter
errors, including macro usage, and array to pointer deconstruction.
Note, This patchset does remove the timestamp from the log message. In
practice, this was duplicated between journald and bmcweb, and there's
no need for both to exist.
One design decision of note is the addition of logPtr. Because the
compiler can't disambiguate between const char* and const MyThing*, it's
necessary to add an explicit cast to void*. This is identical to how
fmt handled it.
Tested: compiled with logging meson_option enabled, and launched bmcweb
Saw the usual logging, similar to what was present before:
```
[Error include/webassets.hpp:60] Unable to find or open /usr/share/www/ static file hosting disabled
[Debug include/persistent_data.hpp:133] Restored Session Timeout: 1800
[Debug redfish-core/include/event_service_manager.hpp:671] Old eventService config not exist
[Info src/webserver_main.cpp:59] Starting webserver on port 18080
[Error redfish-core/include/event_service_manager.hpp:1301] inotify_add_watch failed for redfish log file.
[Info src/webserver_main.cpp:137] Start Hostname Monitor Service...
```
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I86a46aa2454be7fe80df608cb7e5573ca4029ec8
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index a1c4fb9..00d77c8 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -287,13 +287,13 @@
// NOLINTNEXTLINE
bmcweb::split(result, sseFilter, ' ');
- BMCWEB_LOG_DEBUG << "No of tokens in SEE query: " << result.size();
+ BMCWEB_LOG_DEBUG("No of tokens in SEE query: {}", result.size());
constexpr uint8_t divisor = 4;
constexpr uint8_t minTokenSize = 3;
if (result.size() % divisor != minTokenSize)
{
- BMCWEB_LOG_ERROR << "Invalid SSE filter specified.";
+ BMCWEB_LOG_ERROR("Invalid SSE filter specified.");
return false;
}
@@ -309,8 +309,8 @@
// SSE supports only "or" and "and" in query params.
if ((separator != "or") && (separator != "and"))
{
- BMCWEB_LOG_ERROR
- << "Invalid group operator in SSE query parameters";
+ BMCWEB_LOG_ERROR(
+ "Invalid group operator in SSE query parameters");
return false;
}
}
@@ -318,12 +318,12 @@
// SSE supports only "eq" as per spec.
if (op != "eq")
{
- BMCWEB_LOG_ERROR
- << "Invalid assignment operator in SSE query parameters";
+ BMCWEB_LOG_ERROR(
+ "Invalid assignment operator in SSE query parameters");
return false;
}
- BMCWEB_LOG_DEBUG << key << " : " << value;
+ BMCWEB_LOG_DEBUG("{} : {}", key, value);
if (key == "EventFormatType")
{
formatType = value;
@@ -342,8 +342,7 @@
}
else
{
- BMCWEB_LOG_ERROR << "Invalid property(" << key
- << ")in SSE filter query.";
+ BMCWEB_LOG_ERROR("Invalid property({})in SSE filter query.", key);
return false;
}
}
@@ -477,14 +476,14 @@
messageArgsView, timestamp,
customText, bmcLogEntry) != 0)
{
- BMCWEB_LOG_DEBUG << "Read eventLog entry failed";
+ BMCWEB_LOG_DEBUG("Read eventLog entry failed");
continue;
}
}
if (logEntryArray.empty())
{
- BMCWEB_LOG_DEBUG << "No log entries available to be transferred.";
+ BMCWEB_LOG_DEBUG("No log entries available to be transferred.");
return;
}
@@ -521,9 +520,9 @@
nlohmann::json msg;
if (!telemetry::fillReport(msg, reportId, var))
{
- BMCWEB_LOG_ERROR << "Failed to fill the MetricReport for DBus "
- "Report with id "
- << reportId;
+ BMCWEB_LOG_ERROR("Failed to fill the MetricReport for DBus "
+ "Report with id {}",
+ reportId);
return;
}
@@ -553,7 +552,7 @@
void setSubscriptionId(const std::string& id2)
{
- BMCWEB_LOG_DEBUG << "Subscription ID: " << id2;
+ BMCWEB_LOG_DEBUG("Subscription ID: {}", id2);
subId = id2;
}
@@ -582,8 +581,8 @@
// policy. 2XX is considered acceptable
static boost::system::error_code retryRespHandler(unsigned int respCode)
{
- BMCWEB_LOG_DEBUG
- << "Checking response code validity for SubscriptionEvent";
+ BMCWEB_LOG_DEBUG(
+ "Checking response code validity for SubscriptionEvent");
if ((respCode < 200) || (respCode >= 300))
{
return boost::system::errc::make_error_code(
@@ -661,8 +660,8 @@
if (!status)
{
- BMCWEB_LOG_ERROR
- << "Failed to validate and split destination url";
+ BMCWEB_LOG_ERROR(
+ "Failed to validate and split destination url");
continue;
}
std::shared_ptr<Subscription> subValue =
@@ -683,7 +682,7 @@
if (subValue->id.empty())
{
- BMCWEB_LOG_ERROR << "Failed to add subscription";
+ BMCWEB_LOG_ERROR("Failed to add subscription");
}
subscriptionsMap.insert(std::pair(subValue->id, subValue));
@@ -704,13 +703,13 @@
std::ifstream eventConfigFile(eventServiceFile);
if (!eventConfigFile.good())
{
- BMCWEB_LOG_DEBUG << "Old eventService config not exist";
+ BMCWEB_LOG_DEBUG("Old eventService config not exist");
return;
}
auto jsonData = nlohmann::json::parse(eventConfigFile, nullptr, false);
if (jsonData.is_discarded())
{
- BMCWEB_LOG_ERROR << "Old eventService config parse error.";
+ BMCWEB_LOG_ERROR("Old eventService config parse error.");
return;
}
@@ -732,8 +731,8 @@
true);
if (newSubscription == nullptr)
{
- BMCWEB_LOG_ERROR << "Problem reading subscription "
- "from old persistent store";
+ BMCWEB_LOG_ERROR("Problem reading subscription "
+ "from old persistent store");
continue;
}
@@ -765,9 +764,9 @@
if (retry <= 0)
{
- BMCWEB_LOG_ERROR
- << "Failed to generate random number from old "
- "persistent store";
+ BMCWEB_LOG_ERROR(
+ "Failed to generate random number from old "
+ "persistent store");
continue;
}
}
@@ -775,7 +774,7 @@
persistent_data::getConfig().writeData();
std::remove(eventServiceFile);
- BMCWEB_LOG_DEBUG << "Remove old eventservice config";
+ BMCWEB_LOG_DEBUG("Remove old eventservice config");
}
}
@@ -878,7 +877,7 @@
auto obj = subscriptionsMap.find(id);
if (obj == subscriptionsMap.end())
{
- BMCWEB_LOG_ERROR << "No subscription exist with ID:" << id;
+ BMCWEB_LOG_ERROR("No subscription exist with ID:{}", id);
return nullptr;
}
std::shared_ptr<Subscription> subValue = obj->second;
@@ -912,7 +911,7 @@
if (retry <= 0)
{
- BMCWEB_LOG_ERROR << "Failed to generate random number";
+ BMCWEB_LOG_ERROR("Failed to generate random number");
return "";
}
@@ -1024,7 +1023,7 @@
std::shared_ptr<Subscription> entry = it.second;
if (entry->destinationUrl == destUrl)
{
- BMCWEB_LOG_ERROR << "Destination exist already" << destUrl;
+ BMCWEB_LOG_ERROR("Destination exist already{}", destUrl);
return true;
}
}
@@ -1049,7 +1048,7 @@
{
if (!serviceEnabled || (noOfEventLogSubscribers == 0U))
{
- BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions.";
+ BMCWEB_LOG_DEBUG("EventService disabled or no Subscriptions.");
return;
}
nlohmann::json eventRecord = nlohmann::json::array();
@@ -1076,8 +1075,9 @@
{
if (resType == resource)
{
- BMCWEB_LOG_INFO << "ResourceType " << resource
- << " found in the subscribed list";
+ BMCWEB_LOG_INFO(
+ "ResourceType {} found in the subscribed list",
+ resource);
isSubscribed = true;
break;
}
@@ -1103,7 +1103,7 @@
}
else
{
- BMCWEB_LOG_INFO << "Not subscribed to this resource";
+ BMCWEB_LOG_INFO("Not subscribed to this resource");
}
}
}
@@ -1124,7 +1124,7 @@
std::ifstream logStream(redfishEventLogFile);
if (!logStream.good())
{
- BMCWEB_LOG_ERROR << " Redfish log file open failed \n";
+ BMCWEB_LOG_ERROR(" Redfish log file open failed ");
return;
}
std::string logEntry;
@@ -1132,8 +1132,6 @@
{
redfishLogFilePosition = logStream.tellg();
}
-
- BMCWEB_LOG_DEBUG << "Next Log Position : " << redfishLogFilePosition;
}
void readEventLogsFromFile()
@@ -1141,7 +1139,7 @@
std::ifstream logStream(redfishEventLogFile);
if (!logStream.good())
{
- BMCWEB_LOG_ERROR << " Redfish log file open failed";
+ BMCWEB_LOG_ERROR(" Redfish log file open failed");
return;
}
@@ -1177,7 +1175,7 @@
if (event_log::getEventLogParams(logEntry, timestamp, messageID,
messageArgs) != 0)
{
- BMCWEB_LOG_DEBUG << "Read eventLog entry params failed";
+ BMCWEB_LOG_DEBUG("Read eventLog entry params failed");
continue;
}
@@ -1196,14 +1194,14 @@
if (!serviceEnabled || noOfEventLogSubscribers == 0)
{
- BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions.";
+ BMCWEB_LOG_DEBUG("EventService disabled or no Subscriptions.");
return;
}
if (eventRecords.empty())
{
// No Records to send
- BMCWEB_LOG_DEBUG << "No log entries available to be transferred.";
+ BMCWEB_LOG_DEBUG("No log entries available to be transferred.");
return;
}
@@ -1231,7 +1229,7 @@
const std::size_t& bytesTransferred) {
if (ec)
{
- BMCWEB_LOG_ERROR << "Callback Error: " << ec.message();
+ BMCWEB_LOG_ERROR("Callback Error: {}", ec.message());
return;
}
std::size_t index = 0;
@@ -1256,16 +1254,16 @@
continue;
}
- BMCWEB_LOG_DEBUG
- << "Redfish log file created/deleted. event.name: "
- << fileName;
+ BMCWEB_LOG_DEBUG(
+ "Redfish log file created/deleted. event.name: {}",
+ fileName);
if (event.mask == IN_CREATE)
{
if (fileWatchDesc != -1)
{
- BMCWEB_LOG_DEBUG
- << "Remove and Add inotify watcher on "
- "redfish event log file";
+ BMCWEB_LOG_DEBUG(
+ "Remove and Add inotify watcher on "
+ "redfish event log file");
// Remove existing inotify watcher and add
// with new redfish event log file.
inotify_rm_watch(inotifyFd, fileWatchDesc);
@@ -1276,8 +1274,8 @@
inotifyFd, redfishEventLogFile, IN_MODIFY);
if (fileWatchDesc == -1)
{
- BMCWEB_LOG_ERROR << "inotify_add_watch failed for "
- "redfish log file.";
+ BMCWEB_LOG_ERROR("inotify_add_watch failed for "
+ "redfish log file.");
return;
}
@@ -1317,7 +1315,7 @@
inotifyFd = inotify_init1(IN_NONBLOCK);
if (inotifyFd == -1)
{
- BMCWEB_LOG_ERROR << "inotify_init1 failed.";
+ BMCWEB_LOG_ERROR("inotify_init1 failed.");
return -1;
}
@@ -1327,8 +1325,8 @@
IN_CREATE | IN_MOVED_TO | IN_DELETE);
if (dirWatchDesc == -1)
{
- BMCWEB_LOG_ERROR
- << "inotify_add_watch failed for event log directory.";
+ BMCWEB_LOG_ERROR(
+ "inotify_add_watch failed for event log directory.");
return -1;
}
@@ -1337,8 +1335,7 @@
IN_MODIFY);
if (fileWatchDesc == -1)
{
- BMCWEB_LOG_ERROR
- << "inotify_add_watch failed for redfish log file.";
+ BMCWEB_LOG_ERROR("inotify_add_watch failed for redfish log file.");
// Don't return error if file not exist.
// Watch on directory will handle create/delete of file.
}
@@ -1355,7 +1352,7 @@
{
if (msg.is_method_error())
{
- BMCWEB_LOG_ERROR << "TelemetryMonitor Signal error";
+ BMCWEB_LOG_ERROR("TelemetryMonitor Signal error");
return;
}
@@ -1363,7 +1360,7 @@
std::string id = path.filename();
if (id.empty())
{
- BMCWEB_LOG_ERROR << "Failed to get Id from path";
+ BMCWEB_LOG_ERROR("Failed to get Id from path");
return;
}
@@ -1377,7 +1374,7 @@
[](const auto& x) { return x.first == "Readings"; });
if (found == props.end())
{
- BMCWEB_LOG_INFO << "Failed to get Readings from Report properties";
+ BMCWEB_LOG_INFO("Failed to get Readings from Report properties");
return;
}
@@ -1385,7 +1382,7 @@
std::get_if<telemetry::TimestampReadings>(&found->second);
if (readings == nullptr)
{
- BMCWEB_LOG_INFO << "Failed to get Readings from Report properties";
+ BMCWEB_LOG_INFO("Failed to get Readings from Report properties");
return;
}
@@ -1404,7 +1401,7 @@
{
if (matchTelemetryMonitor)
{
- BMCWEB_LOG_DEBUG << "Metrics report signal - Unregister";
+ BMCWEB_LOG_DEBUG("Metrics report signal - Unregister");
matchTelemetryMonitor.reset();
matchTelemetryMonitor = nullptr;
}
@@ -1414,11 +1411,11 @@
{
if (!serviceEnabled || matchTelemetryMonitor)
{
- BMCWEB_LOG_DEBUG << "Not registering metric report signal.";
+ BMCWEB_LOG_DEBUG("Not registering metric report signal.");
return;
}
- BMCWEB_LOG_DEBUG << "Metrics report signal - Register";
+ BMCWEB_LOG_DEBUG("Metrics report signal - Register");
std::string matchStr = "type='signal',member='PropertiesChanged',"
"interface='org.freedesktop.DBus.Properties',"
"arg0=xyz.openbmc_project.Telemetry.Report";
diff --git a/redfish-core/include/gzfile.hpp b/redfish-core/include/gzfile.hpp
index 34bc151..3fa1e49 100644
--- a/redfish-core/include/gzfile.hpp
+++ b/redfish-core/include/gzfile.hpp
@@ -18,7 +18,7 @@
gzFile logStream = gzopen(filename.c_str(), "r");
if (logStream == nullptr)
{
- BMCWEB_LOG_ERROR << "Can't open gz file: " << filename << '\n';
+ BMCWEB_LOG_ERROR("Can't open gz file: {}", filename);
return false;
}
@@ -46,9 +46,9 @@
int errNum = 0;
const char* errMsg = gzerror(logStream, &errNum);
- BMCWEB_LOG_ERROR << "Error reading gz compressed data.\n"
- << "Error Message: " << errMsg << '\n'
- << "Error Number: " << errNum;
+ BMCWEB_LOG_ERROR(
+ "Error reading gz compressed data.\nError Message: {}\nError Number: {}",
+ errMsg, errNum);
}
bool readFile(gzFile logStream, uint64_t skip, uint64_t top,
@@ -71,7 +71,7 @@
bufferStr.resize(static_cast<size_t>(bytesRead));
if (!hostLogEntryParser(bufferStr, skip, top, logEntries, logCount))
{
- BMCWEB_LOG_ERROR << "Error occurs during parsing host log.\n";
+ BMCWEB_LOG_ERROR("Error occurs during parsing host log.");
return false;
}
} while (gzeof(logStream) != 1);
@@ -114,9 +114,9 @@
totalFilesSize += logEntry.size();
if (totalFilesSize > maxTotalFilesSize)
{
- BMCWEB_LOG_ERROR
- << "File size exceeds maximum allowed size of "
- << maxTotalFilesSize;
+ BMCWEB_LOG_ERROR(
+ "File size exceeds maximum allowed size of {}",
+ maxTotalFilesSize);
return false;
}
logEntries.push_back(logEntry);
@@ -145,9 +145,9 @@
totalFilesSize++;
if (totalFilesSize > maxTotalFilesSize)
{
- BMCWEB_LOG_ERROR
- << "File size exceeds maximum allowed size of "
- << maxTotalFilesSize;
+ BMCWEB_LOG_ERROR(
+ "File size exceeds maximum allowed size of {}",
+ maxTotalFilesSize);
return false;
}
logEntries.emplace_back("\n");
@@ -188,9 +188,9 @@
size_t tmpMessageSize = totalFilesSize + lastMessage.size();
if (tmpMessageSize > maxTotalFilesSize)
{
- BMCWEB_LOG_ERROR
- << "File size exceeds maximum allowed size of "
- << maxTotalFilesSize;
+ BMCWEB_LOG_ERROR(
+ "File size exceeds maximum allowed size of {}",
+ maxTotalFilesSize);
return false;
}
}
diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp
index bb2c2f3..8b42208 100644
--- a/redfish-core/include/privileges.hpp
+++ b/redfish-core/include/privileges.hpp
@@ -102,8 +102,8 @@
{
if (!setSinglePrivilege(privilege))
{
- BMCWEB_LOG_CRITICAL << "Unable to set privilege " << privilege
- << "in constructor";
+ BMCWEB_LOG_CRITICAL("Unable to set privilege {}in constructor",
+ privilege);
}
}
}
@@ -295,10 +295,10 @@
}
for (const auto& requiredPrivileges : operationPrivilegesRequired)
{
- BMCWEB_LOG_DEBUG << "Checking operation privileges...";
+ BMCWEB_LOG_DEBUG("Checking operation privileges...");
if (userPrivileges.isSupersetOf(requiredPrivileges))
{
- BMCWEB_LOG_DEBUG << "...success";
+ BMCWEB_LOG_DEBUG("...success");
return true;
}
}
diff --git a/redfish-core/include/query.hpp b/redfish-core/include/query.hpp
index c1ca38e..78de6ca 100644
--- a/redfish-core/include/query.hpp
+++ b/redfish-core/include/query.hpp
@@ -38,8 +38,8 @@
const crow::Response& resIn)
{
std::string computedEtag = resIn.computeEtag();
- BMCWEB_LOG_DEBUG << "User provided if-match etag " << ifMatchHeader
- << " computed etag " << computedEtag;
+ BMCWEB_LOG_DEBUG("User provided if-match etag {} computed etag {}",
+ ifMatchHeader, computedEtag);
if (computedEtag != ifMatchHeader)
{
messages::preconditionFailed(asyncResp->res);
@@ -47,7 +47,7 @@
}
// Restart the request without if-match
req.req.erase(boost::beast::http::field::if_match);
- BMCWEB_LOG_DEBUG << "Restarting request";
+ BMCWEB_LOG_DEBUG("Restarting request");
app.handle(req, asyncResp);
}
@@ -118,7 +118,7 @@
query_param::Query& delegated,
const query_param::QueryCapabilities& queryCapabilities)
{
- BMCWEB_LOG_DEBUG << "setup redfish route";
+ BMCWEB_LOG_DEBUG("setup redfish route");
// Section 7.4 of the redfish spec "Redfish Services shall process the
// [OData-Version header] in the following table as defined by the HTTP 1.1
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp
index 7cae89a..59a4eb9 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -83,8 +83,8 @@
uri.substr(serviceRootUri.size(), parseCount));
if (!parsedUrl)
{
- BMCWEB_LOG_ERROR << "Failed to get target URI from "
- << uri.substr(serviceRootUri.size());
+ BMCWEB_LOG_ERROR("Failed to get target URI from {}",
+ uri.substr(serviceRootUri.size()));
return false;
}
@@ -165,7 +165,7 @@
auto parsed = boost::urls::parse_relative_ref(strValue);
if (!parsed)
{
- BMCWEB_LOG_CRITICAL << "Couldn't parse URI from resource " << strValue;
+ BMCWEB_LOG_CRITICAL("Couldn't parse URI from resource {}", strValue);
return;
}
@@ -178,7 +178,7 @@
if (crow::utility::readUrlSegments(thisUrl, "redfish", "v1", "JsonSchemas",
crow::utility::OrMorePaths()))
{
- BMCWEB_LOG_DEBUG << "Skipping JsonSchemas URI prefix fixing";
+ BMCWEB_LOG_DEBUG("Skipping JsonSchemas URI prefix fixing");
return;
}
@@ -244,7 +244,7 @@
std::string* strValue = item.get_ptr<std::string*>();
if (strValue == nullptr)
{
- BMCWEB_LOG_CRITICAL << "Field wasn't a string????";
+ BMCWEB_LOG_CRITICAL("Field wasn't a string????");
return;
}
addPrefixToStringItem(*strValue, prefix);
@@ -288,7 +288,7 @@
nlohmann::json::array_t* array = json.get_ptr<nlohmann::json::array_t*>();
if (array == nullptr)
{
- BMCWEB_LOG_ERROR << "Field wasn't an array_t????";
+ BMCWEB_LOG_ERROR("Field wasn't an array_t????");
return;
}
@@ -298,7 +298,7 @@
std::string* strHeader = item.get_ptr<std::string*>();
if (strHeader == nullptr)
{
- BMCWEB_LOG_CRITICAL << "Field wasn't a string????";
+ BMCWEB_LOG_CRITICAL("Field wasn't a string????");
continue;
}
@@ -355,7 +355,7 @@
{
// Allow all response codes because we want to surface any satellite
// issue to the client
- BMCWEB_LOG_DEBUG << "Received " << respCode << " response from satellite";
+ BMCWEB_LOG_DEBUG("Received {} response from satellite", respCode);
return boost::system::errc::make_error_code(boost::system::errc::success);
}
@@ -382,13 +382,12 @@
{
if (ec)
{
- BMCWEB_LOG_ERROR << "Something went wrong while querying dbus!";
+ BMCWEB_LOG_ERROR("Something went wrong while querying dbus!");
return;
}
- BMCWEB_LOG_DEBUG << "There were "
- << std::to_string(satelliteInfo.size())
- << " satellite configs found at startup";
+ BMCWEB_LOG_DEBUG("There were {} satellite configs found at startup",
+ std::to_string(satelliteInfo.size()));
}
// Search D-Bus objects for satellite config objects and add their
@@ -404,14 +403,14 @@
if (interface.first ==
"xyz.openbmc_project.Configuration.SatelliteController")
{
- BMCWEB_LOG_DEBUG << "Found Satellite Controller at "
- << objectPath.first.str;
+ BMCWEB_LOG_DEBUG("Found Satellite Controller at {}",
+ objectPath.first.str);
if (!satelliteInfo.empty())
{
- BMCWEB_LOG_ERROR
- << "Redfish Aggregation only supports one satellite!";
- BMCWEB_LOG_DEBUG << "Clearing all satellite data";
+ BMCWEB_LOG_ERROR(
+ "Redfish Aggregation only supports one satellite!");
+ BMCWEB_LOG_DEBUG("Clearing all satellite data");
satelliteInfo.clear();
return;
}
@@ -442,7 +441,7 @@
std::get_if<std::string>(&prop.second);
if (propVal == nullptr)
{
- BMCWEB_LOG_ERROR << "Invalid Hostname value";
+ BMCWEB_LOG_ERROR("Invalid Hostname value");
return;
}
url.set_host(*propVal);
@@ -453,13 +452,13 @@
const uint64_t* propVal = std::get_if<uint64_t>(&prop.second);
if (propVal == nullptr)
{
- BMCWEB_LOG_ERROR << "Invalid Port value";
+ BMCWEB_LOG_ERROR("Invalid Port value");
return;
}
if (*propVal > std::numeric_limits<uint16_t>::max())
{
- BMCWEB_LOG_ERROR << "Port value out of range";
+ BMCWEB_LOG_ERROR("Port value out of range");
return;
}
url.set_port(std::to_string(static_cast<uint16_t>(*propVal)));
@@ -471,7 +470,7 @@
std::get_if<std::string>(&prop.second);
if (propVal == nullptr)
{
- BMCWEB_LOG_ERROR << "Invalid AuthType value";
+ BMCWEB_LOG_ERROR("Invalid AuthType value");
return;
}
@@ -479,9 +478,9 @@
// with the satellite BMC
if (*propVal != "None")
{
- BMCWEB_LOG_ERROR
- << "Unsupported AuthType value: " << *propVal
- << ", only \"none\" is supported";
+ BMCWEB_LOG_ERROR(
+ "Unsupported AuthType value: {}, only \"none\" is supported",
+ *propVal);
return;
}
url.set_scheme("http");
@@ -491,20 +490,19 @@
// Make sure all required config information was made available
if (url.host().empty())
{
- BMCWEB_LOG_ERROR << "Satellite config " << name << " missing Host";
+ BMCWEB_LOG_ERROR("Satellite config {} missing Host", name);
return;
}
if (!url.has_port())
{
- BMCWEB_LOG_ERROR << "Satellite config " << name << " missing Port";
+ BMCWEB_LOG_ERROR("Satellite config {} missing Port", name);
return;
}
if (!url.has_scheme())
{
- BMCWEB_LOG_ERROR << "Satellite config " << name
- << " missing AuthType";
+ BMCWEB_LOG_ERROR("Satellite config {} missing AuthType", name);
return;
}
@@ -519,9 +517,9 @@
resultString = "Updated existing satellite config ";
}
- BMCWEB_LOG_DEBUG << resultString << name << " at "
- << result.first->second.scheme() << "://"
- << result.first->second.encoded_host_and_port();
+ BMCWEB_LOG_DEBUG("{}{} at {}://{}", resultString, name,
+ result.first->second.scheme(),
+ result.first->second.encoded_host_and_port());
}
enum AggregationType
@@ -539,15 +537,15 @@
{
if (aggType == AggregationType::Collection)
{
- BMCWEB_LOG_DEBUG
- << "Only aggregate GET requests to top level collections";
+ BMCWEB_LOG_DEBUG(
+ "Only aggregate GET requests to top level collections");
return;
}
if (aggType == AggregationType::ContainsSubordinate)
{
- BMCWEB_LOG_DEBUG << "Only aggregate GET requests when uptree of"
- << " a top level collection";
+ BMCWEB_LOG_DEBUG(
+ "Only aggregate GET requests when uptree of a top level collection");
return;
}
}
@@ -557,7 +555,7 @@
auto localReq = std::make_shared<crow::Request>(thisReq.req, ec);
if (ec)
{
- BMCWEB_LOG_ERROR << "Failed to create copy of request";
+ BMCWEB_LOG_ERROR("Failed to create copy of request");
if (aggType == AggregationType::Resource)
{
messages::internalError(asyncResp->res);
@@ -582,8 +580,7 @@
targetPrefix += "_";
if (memberName.starts_with(targetPrefix))
{
- BMCWEB_LOG_DEBUG << "\"" << satellite.first
- << "\" is a known prefix";
+ BMCWEB_LOG_DEBUG("\"{}\" is a known prefix", satellite.first);
// Remove the known prefix from the request's URI and
// then forward to the associated satellite BMC
@@ -634,14 +631,14 @@
}
const crow::Request& thisReq = *sharedReq;
- BMCWEB_LOG_DEBUG << "Aggregation is enabled, begin processing of "
- << thisReq.target();
+ BMCWEB_LOG_DEBUG("Aggregation is enabled, begin processing of {}",
+ thisReq.target());
// We previously determined the request is for a collection. No need to
// check again
if (aggType == AggregationType::Collection)
{
- BMCWEB_LOG_DEBUG << "Aggregating a collection";
+ BMCWEB_LOG_DEBUG("Aggregating a collection");
// We need to use a specific response handler and send the
// request to all known satellites
getInstance().forwardCollectionRequests(thisReq, asyncResp,
@@ -653,8 +650,8 @@
// collection. No need to check again
if (aggType == AggregationType::ContainsSubordinate)
{
- BMCWEB_LOG_DEBUG
- << "Aggregating what may have a subordinate collection";
+ BMCWEB_LOG_DEBUG(
+ "Aggregating what may have a subordinate collection");
// We need to use a specific response handler and send the
// request to all known satellites
getInstance().forwardContainsSubordinateRequests(thisReq, asyncResp,
@@ -703,8 +700,7 @@
{
// Realistically this shouldn't get called since we perform an
// earlier check to make sure the prefix exists
- BMCWEB_LOG_ERROR << "Unrecognized satellite prefix \"" << prefix
- << "\"";
+ BMCWEB_LOG_ERROR("Unrecognized satellite prefix \"{}\"", prefix);
return;
}
@@ -714,8 +710,8 @@
if (pos == std::string::npos)
{
// If this fails then something went wrong
- BMCWEB_LOG_ERROR << "Error removing prefix \"" << prefix
- << "_\" from request URI";
+ BMCWEB_LOG_ERROR("Error removing prefix \"{}_\" from request URI",
+ prefix);
messages::internalError(asyncResp->res);
return;
}
@@ -803,7 +799,7 @@
const std::unordered_map<std::string, boost::urls::url>&)>
handler)
{
- BMCWEB_LOG_DEBUG << "Gathering satellite configs";
+ BMCWEB_LOG_DEBUG("Gathering satellite configs");
sdbusplus::message::object_path path("/xyz/openbmc_project/inventory");
dbus::utility::getManagedObjects(
"xyz.openbmc_project.EntityManager", path,
@@ -813,8 +809,8 @@
std::unordered_map<std::string, boost::urls::url> satelliteInfo;
if (ec)
{
- BMCWEB_LOG_ERROR << "DBUS response error " << ec.value() << ", "
- << ec.message();
+ BMCWEB_LOG_ERROR("DBUS response error {}, {}", ec.value(),
+ ec.message());
handler(ec, satelliteInfo);
return;
}
@@ -826,14 +822,14 @@
if (!satelliteInfo.empty())
{
- BMCWEB_LOG_DEBUG << "Redfish Aggregation enabled with "
- << std::to_string(satelliteInfo.size())
- << " satellite BMCs";
+ BMCWEB_LOG_DEBUG(
+ "Redfish Aggregation enabled with {} satellite BMCs",
+ std::to_string(satelliteInfo.size()));
}
else
{
- BMCWEB_LOG_DEBUG
- << "No satellite BMCs detected. Redfish Aggregation not enabled";
+ BMCWEB_LOG_DEBUG(
+ "No satellite BMCs detected. Redfish Aggregation not enabled");
}
handler(ec, satelliteInfo);
});
@@ -866,21 +862,21 @@
false);
if (jsonVal.is_discarded())
{
- BMCWEB_LOG_ERROR << "Error parsing satellite response as JSON";
+ BMCWEB_LOG_ERROR("Error parsing satellite response as JSON");
messages::operationFailed(asyncResp->res);
return;
}
- BMCWEB_LOG_DEBUG << "Successfully parsed satellite response";
+ BMCWEB_LOG_DEBUG("Successfully parsed satellite response");
addPrefixes(jsonVal, prefix);
- BMCWEB_LOG_DEBUG << "Added prefix to parsed satellite response";
+ BMCWEB_LOG_DEBUG("Added prefix to parsed satellite response");
asyncResp->res.result(resp.result());
asyncResp->res.jsonValue = std::move(jsonVal);
- BMCWEB_LOG_DEBUG << "Finished writing asyncResp";
+ BMCWEB_LOG_DEBUG("Finished writing asyncResp");
}
else
{
@@ -908,9 +904,9 @@
if (resp.resultInt() != 200)
{
- BMCWEB_LOG_DEBUG
- << "Collection resource does not exist in satellite BMC \""
- << prefix << "\"";
+ BMCWEB_LOG_DEBUG(
+ "Collection resource does not exist in satellite BMC \"{}\"",
+ prefix);
// Return the error if we haven't had any successes
if (asyncResp->res.resultInt() != 200)
{
@@ -930,7 +926,7 @@
false);
if (jsonVal.is_discarded())
{
- BMCWEB_LOG_ERROR << "Error parsing satellite response as JSON";
+ BMCWEB_LOG_ERROR("Error parsing satellite response as JSON");
// Notify the user if doing so won't overwrite a valid response
if (asyncResp->res.resultInt() != 200)
@@ -940,13 +936,13 @@
return;
}
- BMCWEB_LOG_DEBUG << "Successfully parsed satellite response";
+ BMCWEB_LOG_DEBUG("Successfully parsed satellite response");
// Now we need to add the prefix to the URIs contained in the
// response.
addPrefixes(jsonVal, prefix);
- BMCWEB_LOG_DEBUG << "Added prefix to parsed satellite response";
+ BMCWEB_LOG_DEBUG("Added prefix to parsed satellite response");
// If this resource collection does not exist on the aggregating bmc
// and has not already been added from processing the response from
@@ -959,18 +955,18 @@
if ((!jsonVal.contains("Members")) &&
(!jsonVal["Members"].is_array()))
{
- BMCWEB_LOG_DEBUG
- << "Skipping aggregating unsupported resource";
+ BMCWEB_LOG_DEBUG(
+ "Skipping aggregating unsupported resource");
return;
}
- BMCWEB_LOG_DEBUG
- << "Collection does not exist, overwriting asyncResp";
+ BMCWEB_LOG_DEBUG(
+ "Collection does not exist, overwriting asyncResp");
asyncResp->res.result(resp.result());
asyncResp->res.jsonValue = std::move(jsonVal);
asyncResp->res.addHeader("Content-Type", "application/json");
- BMCWEB_LOG_DEBUG << "Finished overwriting asyncResp";
+ BMCWEB_LOG_DEBUG("Finished overwriting asyncResp");
}
else
{
@@ -980,13 +976,14 @@
(!asyncResp->res.jsonValue["Members"].is_array()))
{
- BMCWEB_LOG_DEBUG
- << "Skipping aggregating unsupported resource";
+ BMCWEB_LOG_DEBUG(
+ "Skipping aggregating unsupported resource");
return;
}
- BMCWEB_LOG_DEBUG << "Adding aggregated resources from \""
- << prefix << "\" to collection";
+ BMCWEB_LOG_DEBUG(
+ "Adding aggregated resources from \"{}\" to collection",
+ prefix);
// TODO: This is a potential race condition with multiple
// satellites and the aggregating bmc attempting to write to
@@ -1010,8 +1007,8 @@
}
else
{
- BMCWEB_LOG_ERROR << "Received unparsable response from \"" << prefix
- << "\"";
+ BMCWEB_LOG_ERROR("Received unparsable response from \"{}\"",
+ prefix);
// We received a response that was not a json.
// Notify the user only if we did not receive any valid responses
// and if the resource collection does not already exist on the
@@ -1041,9 +1038,9 @@
if (resp.resultInt() != 200)
{
- BMCWEB_LOG_DEBUG
- << "Resource uptree from Collection does not exist in "
- << "satellite BMC \"" << prefix << "\"";
+ BMCWEB_LOG_DEBUG(
+ "Resource uptree from Collection does not exist in satellite BMC \"{}\"",
+ prefix);
// Return the error if we haven't had any successes
if (asyncResp->res.resultInt() != 200)
{
@@ -1064,7 +1061,7 @@
false);
if (jsonVal.is_discarded())
{
- BMCWEB_LOG_ERROR << "Error parsing satellite response as JSON";
+ BMCWEB_LOG_ERROR("Error parsing satellite response as JSON");
// Notify the user if doing so won't overwrite a valid response
if (asyncResp->res.resultInt() != 200)
@@ -1074,7 +1071,7 @@
return;
}
- BMCWEB_LOG_DEBUG << "Successfully parsed satellite response";
+ BMCWEB_LOG_DEBUG("Successfully parsed satellite response");
// Parse response and add properties missing from the AsyncResp
// Valid properties will be of the form <property>.@odata.id and
@@ -1085,7 +1082,7 @@
jsonVal.get_ptr<nlohmann::json::object_t*>();
if (object == nullptr)
{
- BMCWEB_LOG_ERROR << "Parsed JSON was not an object?";
+ BMCWEB_LOG_ERROR("Parsed JSON was not an object?");
return;
}
@@ -1100,7 +1097,7 @@
prop.second["@odata.id"].get_ptr<std::string*>();
if (strValue == nullptr)
{
- BMCWEB_LOG_CRITICAL << "Field wasn't a string????";
+ BMCWEB_LOG_CRITICAL("Field wasn't a string????");
continue;
}
if (!searchCollectionsArray(*strValue, SearchType::CollOrCon))
@@ -1112,8 +1109,8 @@
if (!asyncResp->res.jsonValue.contains(prop.first))
{
// Only add the property if it did not already exist
- BMCWEB_LOG_DEBUG << "Adding link for " << *strValue
- << " from BMC " << prefix;
+ BMCWEB_LOG_DEBUG("Adding link for {} from BMC {}",
+ *strValue, prefix);
asyncResp->res.jsonValue[prop.first]["@odata.id"] =
*strValue;
continue;
@@ -1157,8 +1154,8 @@
}
else
{
- BMCWEB_LOG_ERROR << "Received unparsable response from \"" << prefix
- << "\"";
+ BMCWEB_LOG_ERROR("Received unparsable response from \"{}\"",
+ prefix);
// We received as response that was not a json
// Notify the user only if we did not receive any valid responses,
// and if the resource does not already exist on the aggregating BMC
@@ -1225,7 +1222,7 @@
// being a local resource describing the satellite
if (collectionItem.starts_with("5B247A_"))
{
- BMCWEB_LOG_DEBUG << "Need to forward a request";
+ BMCWEB_LOG_DEBUG("Need to forward a request");
// Extract the prefix from the request's URI, retrieve the
// associated satellite config information, and then forward
@@ -1271,7 +1268,7 @@
return Result::LocalHandle;
}
- BMCWEB_LOG_DEBUG << "Aggregation not required for " << url.buffer();
+ BMCWEB_LOG_DEBUG("Aggregation not required for {}", url.buffer());
return Result::LocalHandle;
}
};
diff --git a/redfish-core/include/snmp_trap_event_clients.hpp b/redfish-core/include/snmp_trap_event_clients.hpp
index 08ff81b..de7bf9d 100644
--- a/redfish-core/include/snmp_trap_event_clients.hpp
+++ b/redfish-core/include/snmp_trap_event_clients.hpp
@@ -28,7 +28,7 @@
{
if (ec)
{
- BMCWEB_LOG_ERROR << "D-Bus response error on GetSubTree " << ec;
+ BMCWEB_LOG_ERROR("D-Bus response error on GetSubTree {}", ec);
messages::internalError(asyncResp->res);
return;
}
@@ -95,8 +95,8 @@
dbus::utility::ManagedObjectType& resp) {
if (ec)
{
- BMCWEB_LOG_ERROR << "D-Bus response error on GetManagedObjects "
- << ec;
+ BMCWEB_LOG_ERROR("D-Bus response error on GetManagedObjects {}",
+ ec);
messages::internalError(asyncResp->res);
return;
}
@@ -107,7 +107,7 @@
const std::string snmpId = path.filename();
if (snmpId.empty())
{
- BMCWEB_LOG_ERROR << "The SNMP client ID is wrong";
+ BMCWEB_LOG_ERROR("The SNMP client ID is wrong");
messages::internalError(asyncResp->res);
return;
}
diff --git a/redfish-core/include/utils/chassis_utils.hpp b/redfish-core/include/utils/chassis_utils.hpp
index 9c7c7db..c8c203d 100644
--- a/redfish-core/include/utils/chassis_utils.hpp
+++ b/redfish-core/include/utils/chassis_utils.hpp
@@ -21,7 +21,7 @@
void getValidChassisPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& chassisId, Callback&& callback)
{
- BMCWEB_LOG_DEBUG << "checkChassisId enter";
+ BMCWEB_LOG_DEBUG("checkChassisId enter");
constexpr std::array<std::string_view, 2> interfaces = {
"xyz.openbmc_project.Inventory.Item.Board",
"xyz.openbmc_project.Inventory.Item.Chassis"};
@@ -33,11 +33,11 @@
chassisId](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
chassisPaths) mutable {
- BMCWEB_LOG_DEBUG << "getValidChassisPath respHandler enter";
+ BMCWEB_LOG_DEBUG("getValidChassisPath respHandler enter");
if (ec)
{
- BMCWEB_LOG_ERROR << "getValidChassisPath respHandler DBUS error: "
- << ec;
+ BMCWEB_LOG_ERROR("getValidChassisPath respHandler DBUS error: {}",
+ ec);
messages::internalError(asyncResp->res);
return;
}
@@ -49,7 +49,7 @@
std::string chassisName = path.filename();
if (chassisName.empty())
{
- BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis;
+ BMCWEB_LOG_ERROR("Failed to find '/' in {}", chassis);
continue;
}
if (chassisName == chassisId)
@@ -60,7 +60,7 @@
}
callback(chassisPath);
});
- BMCWEB_LOG_DEBUG << "checkChassisId exit";
+ BMCWEB_LOG_DEBUG("checkChassisId exit");
}
} // namespace chassis_utils
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index 500749c..862be90 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -37,8 +37,7 @@
std::span<const std::string_view> interfaces,
const char* subtree = "/xyz/openbmc_project/inventory")
{
- BMCWEB_LOG_DEBUG << "Get collection members for: "
- << collectionPath.buffer();
+ BMCWEB_LOG_DEBUG("Get collection members for: {}", collectionPath.buffer());
dbus::utility::getSubTreePaths(
subtree, 0, interfaces,
[collectionPath, asyncResp{std::move(asyncResp)}](
@@ -53,7 +52,7 @@
if (ec)
{
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec.value();
+ BMCWEB_LOG_DEBUG("DBUS response error {}", ec.value());
messages::internalError(asyncResp->res);
return;
}
diff --git a/redfish-core/include/utils/dbus_utils.hpp b/redfish-core/include/utils/dbus_utils.hpp
index 7e895fe..298a56b 100644
--- a/redfish-core/include/utils/dbus_utils.hpp
+++ b/redfish-core/include/utils/dbus_utils.hpp
@@ -14,11 +14,10 @@
void operator()(const sdbusplus::UnpackErrorReason reason,
const std::string& property) const noexcept
{
- BMCWEB_LOG_ERROR
- << "DBUS property error in property: " << property << ", reason: "
- << static_cast<
- std::underlying_type_t<sdbusplus::UnpackErrorReason>>(
- reason);
+ BMCWEB_LOG_ERROR(
+ "DBUS property error in property: {}, reason: {}", property,
+ static_cast<std::underlying_type_t<sdbusplus::UnpackErrorReason>>(
+ reason));
}
};
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index 642ca80..3d3ae8d 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -101,21 +101,21 @@
{
if (from > std::numeric_limits<ToType>::max())
{
- BMCWEB_LOG_DEBUG << "Value for key " << key
- << " was greater than max: " << __PRETTY_FUNCTION__;
+ BMCWEB_LOG_DEBUG("Value for key {} was greater than max: {}", key,
+ __PRETTY_FUNCTION__);
return false;
}
if (from < std::numeric_limits<ToType>::lowest())
{
- BMCWEB_LOG_DEBUG << "Value for key " << key
- << " was less than min: " << __PRETTY_FUNCTION__;
+ BMCWEB_LOG_DEBUG("Value for key {} was less than min: {}", key,
+ __PRETTY_FUNCTION__);
return false;
}
if constexpr (std::is_floating_point_v<ToType>)
{
if (std::isnan(from))
{
- BMCWEB_LOG_DEBUG << "Value for key " << key << " was NAN";
+ BMCWEB_LOG_DEBUG("Value for key {} was NAN", key);
return false;
}
}
@@ -193,9 +193,8 @@
JsonType jsonPtr = jsonValue.get_ptr<JsonType>();
if (jsonPtr == nullptr)
{
- BMCWEB_LOG_DEBUG
- << "Value for key " << key
- << " was incorrect type: " << jsonValue.type_name();
+ BMCWEB_LOG_DEBUG("Value for key {} was incorrect type: {}", key,
+ jsonValue.type_name());
return UnpackErrorCode::invalidType;
}
value = std::move(*jsonPtr);
@@ -392,7 +391,7 @@
jsonRequest.get_ptr<nlohmann::json::object_t*>();
if (obj == nullptr)
{
- BMCWEB_LOG_DEBUG << "Json value is not an object";
+ BMCWEB_LOG_DEBUG("Json value is not an object");
messages::unrecognizedRequestBody(res);
return false;
}
@@ -521,14 +520,14 @@
nlohmann::json jsonRequest;
if (!json_util::processJsonFromRequest(res, req, jsonRequest))
{
- BMCWEB_LOG_DEBUG << "Json value not readable";
+ BMCWEB_LOG_DEBUG("Json value not readable");
return std::nullopt;
}
nlohmann::json::object_t* object =
jsonRequest.get_ptr<nlohmann::json::object_t*>();
if (object == nullptr || object->empty())
{
- BMCWEB_LOG_DEBUG << "Json value is empty";
+ BMCWEB_LOG_DEBUG("Json value is empty");
messages::emptyJSON(res);
return std::nullopt;
}
@@ -568,7 +567,7 @@
nlohmann::json jsonRequest;
if (!json_util::processJsonFromRequest(res, req, jsonRequest))
{
- BMCWEB_LOG_DEBUG << "Json value not readable";
+ BMCWEB_LOG_DEBUG("Json value not readable");
return false;
}
return readJson(jsonRequest, res, key, std::forward<UnpackTypes&&>(in)...);
diff --git a/redfish-core/include/utils/pcie_util.hpp b/redfish-core/include/utils/pcie_util.hpp
index 4db6e03..a889f93 100644
--- a/redfish-core/include/utils/pcie_util.hpp
+++ b/redfish-core/include/utils/pcie_util.hpp
@@ -46,8 +46,7 @@
pcieDevicePaths) {
if (ec)
{
- BMCWEB_LOG_DEBUG << "no PCIe device paths found ec: "
- << ec.message();
+ BMCWEB_LOG_DEBUG("no PCIe device paths found ec: {}", ec.message());
// Not an error, system just doesn't have PCIe info
return;
}
diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp
index 4ba521b..696e323 100644
--- a/redfish-core/include/utils/query_param.hpp
+++ b/redfish-core/include/utils/query_param.hpp
@@ -462,7 +462,7 @@
inline bool processOnly(crow::App& app, crow::Response& res,
std::function<void(crow::Response&)>& completionHandler)
{
- BMCWEB_LOG_DEBUG << "Processing only query param";
+ BMCWEB_LOG_DEBUG("Processing only query param");
auto itMembers = res.jsonValue.find("Members");
if (itMembers == res.jsonValue.end())
{
@@ -473,8 +473,9 @@
auto itMemBegin = itMembers->begin();
if (itMemBegin == itMembers->end() || itMembers->size() != 1)
{
- BMCWEB_LOG_DEBUG << "Members contains " << itMembers->size()
- << " element, returning full collection.";
+ BMCWEB_LOG_DEBUG(
+ "Members contains {} element, returning full collection.",
+ itMembers->size());
completionHandler(res);
return false;
}
@@ -482,7 +483,7 @@
auto itUrl = itMemBegin->find("@odata.id");
if (itUrl == itMemBegin->end())
{
- BMCWEB_LOG_DEBUG << "No found odata.id";
+ BMCWEB_LOG_DEBUG("No found odata.id");
messages::internalError(res);
completionHandler(res);
return false;
@@ -490,7 +491,7 @@
const std::string* url = itUrl->get_ptr<const std::string*>();
if (url == nullptr)
{
- BMCWEB_LOG_DEBUG << "@odata.id wasn't a string????";
+ BMCWEB_LOG_DEBUG("@odata.id wasn't a string????");
messages::internalError(res);
completionHandler(res);
return false;
@@ -507,7 +508,8 @@
}
auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
- BMCWEB_LOG_DEBUG << "setting completion handler on " << &asyncResp->res;
+ BMCWEB_LOG_DEBUG("setting completion handler on {}",
+ logPtr(&asyncResp->res));
asyncResp->res.setCompleteRequestHandler(std::move(completionHandler));
asyncResp->res.setIsAliveHelper(res.releaseIsAliveHelper());
app.handle(newReq, asyncResp);
@@ -579,7 +581,7 @@
for (auto& element : array)
{
nlohmann::json::json_pointer newPtr = jsonPtr / index;
- BMCWEB_LOG_DEBUG << "Traversing response at " << newPtr.to_string();
+ BMCWEB_LOG_DEBUG("Traversing response at {}", newPtr.to_string());
findNavigationReferencesRecursive(eType, element, newPtr, depth,
skipDepth, inLinks, out);
index++;
@@ -600,8 +602,7 @@
obj.begin()->second.get_ptr<const std::string*>();
if (uri != nullptr)
{
- BMCWEB_LOG_DEBUG << "Found " << *uri << " at "
- << jsonPtr.to_string();
+ BMCWEB_LOG_DEBUG("Found {} at {}", *uri, jsonPtr.to_string());
if (skipDepth == 0)
{
out.push_back({jsonPtr, *uri});
@@ -658,7 +659,7 @@
continue;
}
nlohmann::json::json_pointer newPtr = jsonPtr / element.first;
- BMCWEB_LOG_DEBUG << "Traversing response at " << newPtr;
+ BMCWEB_LOG_DEBUG("Traversing response at {}", newPtr);
findNavigationReferencesRecursive(eType, element.second, newPtr,
newDepth, skipDepth, localInLinks,
@@ -827,7 +828,7 @@
void placeResult(const nlohmann::json::json_pointer& locationToPlace,
crow::Response& res)
{
- BMCWEB_LOG_DEBUG << "placeResult for " << locationToPlace;
+ BMCWEB_LOG_DEBUG("placeResult for {}", locationToPlace);
propogateError(finalRes->res, res);
if (!res.jsonValue.is_object() || res.jsonValue.empty())
{
@@ -844,7 +845,7 @@
std::vector<ExpandNode> nodes = findNavigationReferences(
query.expandType, query.expandLevel, delegated.expandLevel,
finalRes->res.jsonValue);
- BMCWEB_LOG_DEBUG << nodes.size() << " nodes to traverse";
+ BMCWEB_LOG_DEBUG("{} nodes to traverse", nodes.size());
const std::optional<std::string> queryStr = formatQueryForExpand(query);
if (!queryStr)
{
@@ -854,7 +855,7 @@
for (const ExpandNode& node : nodes)
{
const std::string subQuery = node.uri + *queryStr;
- BMCWEB_LOG_DEBUG << "URL of subquery: " << subQuery;
+ BMCWEB_LOG_DEBUG("URL of subquery: {}", subQuery);
std::error_code ec;
crow::Request newReq({boost::beast::http::verb::get, subQuery, 11},
ec);
@@ -865,8 +866,8 @@
}
auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
- BMCWEB_LOG_DEBUG << "setting completion handler on "
- << &asyncResp->res;
+ BMCWEB_LOG_DEBUG("setting completion handler on {}",
+ logPtr(&asyncResp->res));
addAwaitingResponse(asyncResp, node.location);
app.handle(newReq, asyncResp);
@@ -902,7 +903,7 @@
return;
}
- BMCWEB_LOG_DEBUG << "Handling top/skip";
+ BMCWEB_LOG_DEBUG("Handling top/skip");
nlohmann::json::object_t::iterator members = obj->find("Members");
if (members == obj->end())
{
@@ -946,12 +947,12 @@
currRoot.get_ptr<nlohmann::json::object_t*>();
if (object != nullptr)
{
- BMCWEB_LOG_DEBUG << "Current JSON is an object";
+ BMCWEB_LOG_DEBUG("Current JSON is an object");
auto it = currRoot.begin();
while (it != currRoot.end())
{
auto nextIt = std::next(it);
- BMCWEB_LOG_DEBUG << "key=" << it.key();
+ BMCWEB_LOG_DEBUG("key={}", it.key());
const SelectTrieNode* nextNode = currNode.find(it.key());
// Per the Redfish spec section 7.3.3, the service shall select
// certain properties as if $select was omitted. This applies to
@@ -969,12 +970,12 @@
}
if (nextNode != nullptr)
{
- BMCWEB_LOG_DEBUG << "Recursively select: " << it.key();
+ BMCWEB_LOG_DEBUG("Recursively select: {}", it.key());
recursiveSelect(*it, *nextNode);
it = nextIt;
continue;
}
- BMCWEB_LOG_DEBUG << it.key() << " is getting removed!";
+ BMCWEB_LOG_DEBUG("{} is getting removed!", it.key());
it = currRoot.erase(it);
}
}
@@ -982,7 +983,7 @@
currRoot.get_ptr<nlohmann::json::array_t*>();
if (array != nullptr)
{
- BMCWEB_LOG_DEBUG << "Current JSON is an array";
+ BMCWEB_LOG_DEBUG("Current JSON is an array");
// Array index is omitted, so reuse the same Trie node
for (nlohmann::json& nextRoot : *array)
{
@@ -1000,7 +1001,7 @@
inline void processSelect(crow::Response& intermediateResponse,
const SelectTrieNode& trieRoot)
{
- BMCWEB_LOG_DEBUG << "Process $select quary parameter";
+ BMCWEB_LOG_DEBUG("Process $select quary parameter");
recursiveSelect(intermediateResponse.jsonValue, trieRoot);
}
@@ -1011,11 +1012,11 @@
{
if (!completionHandler)
{
- BMCWEB_LOG_DEBUG << "Function was invalid?";
+ BMCWEB_LOG_DEBUG("Function was invalid?");
return;
}
- BMCWEB_LOG_DEBUG << "Processing query params";
+ BMCWEB_LOG_DEBUG("Processing query params");
// If the request failed, there's no reason to even try to run query
// params.
if (intermediateResponse.resultInt() < 200 ||
@@ -1037,7 +1038,7 @@
if (query.expandType != ExpandType::None)
{
- BMCWEB_LOG_DEBUG << "Executing expand query";
+ BMCWEB_LOG_DEBUG("Executing expand query");
auto asyncResp = std::make_shared<bmcweb::AsyncResp>(
std::move(intermediateResponse));
diff --git a/redfish-core/include/utils/sw_utils.hpp b/redfish-core/include/utils/sw_utils.hpp
index 176586f..cffc637 100644
--- a/redfish-core/include/utils/sw_utils.hpp
+++ b/redfish-core/include/utils/sw_utils.hpp
@@ -54,11 +54,11 @@
populateLinkToImages](
const boost::system::error_code& ec,
const dbus::utility::MapperEndPoints& functionalSw) {
- BMCWEB_LOG_DEBUG << "populateSoftwareInformation enter";
+ BMCWEB_LOG_DEBUG("populateSoftwareInformation enter");
if (ec)
{
- BMCWEB_LOG_ERROR << "error_code = " << ec;
- BMCWEB_LOG_ERROR << "error msg = " << ec.message();
+ BMCWEB_LOG_ERROR("error_code = {}", ec);
+ BMCWEB_LOG_ERROR("error msg = {}", ec.message());
messages::internalError(asyncResp->res);
return;
}
@@ -67,7 +67,7 @@
{
// Could keep going and try to populate SoftwareImages but
// something is seriously wrong, so just fail
- BMCWEB_LOG_ERROR << "Zero functional software in system";
+ BMCWEB_LOG_ERROR("Zero functional software in system");
messages::internalError(asyncResp->res);
return;
}
@@ -98,13 +98,13 @@
const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec2)
{
- BMCWEB_LOG_ERROR << "error_code = " << ec2;
- BMCWEB_LOG_ERROR << "error msg = " << ec2.message();
+ BMCWEB_LOG_ERROR("error_code = {}", ec2);
+ BMCWEB_LOG_ERROR("error msg = {}", ec2.message());
messages::internalError(asyncResp->res);
return;
}
- BMCWEB_LOG_DEBUG << "Found " << subtree.size() << " images";
+ BMCWEB_LOG_DEBUG("Found {} images", subtree.size());
for (const std::pair<std::string,
std::vector<std::pair<
@@ -116,7 +116,7 @@
if (swId.empty())
{
messages::internalError(asyncResp->res);
- BMCWEB_LOG_ERROR << "Invalid software ID";
+ BMCWEB_LOG_ERROR("Invalid software ID");
return;
}
@@ -142,8 +142,8 @@
propertiesList) {
if (ec3)
{
- BMCWEB_LOG_ERROR << "error_code = " << ec3;
- BMCWEB_LOG_ERROR << "error msg = " << ec3.message();
+ BMCWEB_LOG_ERROR("error_code = {}", ec3);
+ BMCWEB_LOG_ERROR("error msg = {}", ec3.message());
// Have seen the code update app delete the D-Bus
// object, during code update, between the call to
// mapper and here. Just leave these properties off if
@@ -185,9 +185,9 @@
return;
}
- BMCWEB_LOG_DEBUG << "Image ID: " << swId;
- BMCWEB_LOG_DEBUG << "Running image: " << runningImage;
- BMCWEB_LOG_DEBUG << "Image purpose: " << *swInvPurpose;
+ BMCWEB_LOG_DEBUG("Image ID: {}", swId);
+ BMCWEB_LOG_DEBUG("Running image: {}", runningImage);
+ BMCWEB_LOG_DEBUG("Image purpose: {}", *swInvPurpose);
if (populateLinkToImages)
{
@@ -253,7 +253,7 @@
{
return resource::State::StandbySpare;
}
- BMCWEB_LOG_DEBUG << "Default sw state " << swState << " to Disabled";
+ BMCWEB_LOG_DEBUG("Default sw state {} to Disabled", swState);
return resource::State::Disabled;
}
@@ -277,7 +277,7 @@
{
return "OK";
}
- BMCWEB_LOG_DEBUG << "Sw state " << swState << " to Warning";
+ BMCWEB_LOG_DEBUG("Sw state {} to Warning", swState);
return "Warning";
}
@@ -297,7 +297,7 @@
const std::shared_ptr<std::string>& swId,
const std::string& dbusSvc)
{
- BMCWEB_LOG_DEBUG << "getSwStatus: swId " << *swId << " svc " << dbusSvc;
+ BMCWEB_LOG_DEBUG("getSwStatus: swId {} svc {}", *swId, dbusSvc);
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, dbusSvc,
@@ -331,7 +331,7 @@
return;
}
- BMCWEB_LOG_DEBUG << "getSwStatus: Activation " << *swInvActivation;
+ BMCWEB_LOG_DEBUG("getSwStatus: Activation {}", *swInvActivation);
asyncResp->res.jsonValue["Status"]["State"] =
getRedfishSwState(*swInvActivation);
asyncResp->res.jsonValue["Status"]["Health"] =
@@ -359,8 +359,8 @@
const dbus::utility::MapperEndPoints& objPaths) {
if (ec)
{
- BMCWEB_LOG_DEBUG << " error_code = " << ec
- << " error msg = " << ec.message();
+ BMCWEB_LOG_DEBUG(" error_code = {} error msg = {}", ec,
+ ec.message());
// System can exist with no updateable software,
// so don't throw error here.
return;
diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp
index 58ab1c9..33e31f0 100644
--- a/redfish-core/include/utils/telemetry_utils.hpp
+++ b/redfish-core/include/utils/telemetry_utils.hpp
@@ -71,9 +71,9 @@
if (!parsed)
{
- BMCWEB_LOG_ERROR << "Failed to get chassis and sensor Node "
- "from "
- << uri;
+ BMCWEB_LOG_ERROR("Failed to get chassis and sensor Node "
+ "from {}",
+ uri);
return std::make_optional<IncorrectMetricUri>({uri, uriIdx});
}
@@ -101,9 +101,9 @@
continue;
}
- BMCWEB_LOG_ERROR << "Failed to get chassis and sensor Node "
- "from "
- << uri;
+ BMCWEB_LOG_ERROR("Failed to get chassis and sensor Node "
+ "from {}",
+ uri);
return std::make_optional<IncorrectMetricUri>({uri, uriIdx});
}
return std::nullopt;
diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
index 17c9111..314ea85 100644
--- a/redfish-core/include/utils/time_utils.hpp
+++ b/redfish-core/include/utils/time_utils.hpp
@@ -93,14 +93,13 @@
auto [ptr, ec] = std::from_chars(v.begin(), v.end(), ticks);
if (ec != std::errc())
{
- BMCWEB_LOG_ERROR << "Failed to convert string \"" << v
- << "\" to decimal";
+ BMCWEB_LOG_ERROR("Failed to convert string \"{}\" to decimal", v);
return std::nullopt;
}
size_t charactersRead = static_cast<size_t>(ptr - v.data());
if (ptr >= v.end())
{
- BMCWEB_LOG_ERROR << "Missing postfix";
+ BMCWEB_LOG_ERROR("Missing postfix");
return std::nullopt;
}
if (*ptr == 'D')
@@ -147,8 +146,7 @@
}
else if (stage > ProcessingStage::Milliseconds)
{
- BMCWEB_LOG_ERROR
- << "Got unexpected information at end of parse";
+ BMCWEB_LOG_ERROR("Got unexpected information at end of parse");
return std::nullopt;
}
else
@@ -170,7 +168,7 @@
}
else
{
- BMCWEB_LOG_ERROR << "Unknown postfix " << *ptr;
+ BMCWEB_LOG_ERROR("Unknown postfix {}", *ptr);
return std::nullopt;
}