summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2023-07-18 03:06:25 +0300
committerEd Tanous <ed@tanous.net>2023-07-20 01:38:41 +0300
commit62598e31d0988d589506d5091bd38f72d61faf5e (patch)
treee3e548632da934083c21cc1262f8b9d8f255f2a9 /include
parent609ba4c9ffb9c6b83861ff557108c89007ca369a (diff)
downloadbmcweb-62598e31d0988d589506d5091bd38f72d61faf5e.tar.xz
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
Diffstat (limited to 'include')
-rw-r--r--include/async_resolve.hpp19
-rw-r--r--include/authentication.hpp25
-rw-r--r--include/dbus_monitor.hpp240
-rw-r--r--include/dbus_privileges.hpp20
-rw-r--r--include/dbus_utility.hpp2
-rw-r--r--include/event_service_store.hpp14
-rw-r--r--include/google/google_service_root.hpp8
-rw-r--r--include/hostname_monitor.hpp31
-rw-r--r--include/ibm/locks.hpp94
-rw-r--r--include/ibm/management_console_rest.hpp139
-rw-r--r--include/ibm/utils.hpp8
-rw-r--r--include/image_upload.hpp10
-rw-r--r--include/kvm_websocket.hpp59
-rw-r--r--include/login_routes.hpp15
-rw-r--r--include/nbd_proxy.hpp45
-rw-r--r--include/obmc_console.hpp61
-rw-r--r--include/openbmc_dbus_rest.hpp213
-rw-r--r--include/persistent_data.hpp39
-rw-r--r--include/sessions.hpp15
-rw-r--r--include/ssl_key_handler.hpp53
-rw-r--r--include/vm_websocket.hpp23
-rw-r--r--include/webassets.hpp15
22 files changed, 567 insertions, 581 deletions
diff --git a/include/async_resolve.hpp b/include/async_resolve.hpp
index 2bf511299d..3f31e1383f 100644
--- a/include/async_resolve.hpp
+++ b/include/async_resolve.hpp
@@ -20,14 +20,14 @@ inline bool endpointFromResolveTuple(const std::vector<uint8_t>& ipAddress,
{
if (ipAddress.size() == 4) // ipv4 address
{
- BMCWEB_LOG_DEBUG << "ipv4 address";
+ BMCWEB_LOG_DEBUG("ipv4 address");
boost::asio::ip::address_v4 ipv4Addr(
{ipAddress[0], ipAddress[1], ipAddress[2], ipAddress[3]});
endpoint.address(ipv4Addr);
}
else if (ipAddress.size() == 16) // ipv6 address
{
- BMCWEB_LOG_DEBUG << "ipv6 address";
+ BMCWEB_LOG_DEBUG("ipv6 address");
boost::asio::ip::address_v6 ipv6Addr(
{ipAddress[0], ipAddress[1], ipAddress[2], ipAddress[3],
ipAddress[4], ipAddress[5], ipAddress[6], ipAddress[7],
@@ -37,7 +37,7 @@ inline bool endpointFromResolveTuple(const std::vector<uint8_t>& ipAddress,
}
else
{
- BMCWEB_LOG_ERROR << "Resolve failed to fetch the IP address";
+ BMCWEB_LOG_ERROR("Resolve failed to fetch the IP address");
return false;
}
return true;
@@ -66,14 +66,14 @@ class Resolver
void async_resolve(const std::string& host, std::string_view port,
ResolveHandler&& handler)
{
- BMCWEB_LOG_DEBUG << "Trying to resolve: " << host << ":" << port;
+ BMCWEB_LOG_DEBUG("Trying to resolve: {}:{}", host, port);
uint16_t portNum = 0;
auto it = std::from_chars(&*port.begin(), &*port.end(), portNum);
if (it.ec != std::errc())
{
- BMCWEB_LOG_ERROR << "Failed to get the Port";
+ BMCWEB_LOG_ERROR("Failed to get the Port");
handler(std::make_error_code(std::errc::invalid_argument),
results_type{});
@@ -90,12 +90,12 @@ class Resolver
results_type endpointList;
if (ec)
{
- BMCWEB_LOG_ERROR << "Resolve failed: " << ec.message();
+ BMCWEB_LOG_ERROR("Resolve failed: {}", ec.message());
handler(ec, endpointList);
return;
}
- BMCWEB_LOG_DEBUG << "ResolveHostname returned: " << hostName << ":"
- << flagNum;
+ BMCWEB_LOG_DEBUG("ResolveHostname returned: {}:{}", hostName,
+ flagNum);
// Extract the IP address from the response
for (const std::tuple<int32_t, int32_t, std::vector<uint8_t>>&
resolveList : resp)
@@ -109,7 +109,8 @@ class Resolver
boost::system::errc::address_not_available);
handler(ecErr, endpointList);
}
- BMCWEB_LOG_DEBUG << "resolved endpoint is : " << endpoint;
+ BMCWEB_LOG_DEBUG("resolved endpoint is : {}",
+ endpoint.address().to_string());
endpointList.push_back(endpoint);
}
// All the resolved data is filled in the endpointList
diff --git a/include/authentication.hpp b/include/authentication.hpp
index 9e3405be63..f3246c0fcf 100644
--- a/include/authentication.hpp
+++ b/include/authentication.hpp
@@ -38,7 +38,7 @@ static std::shared_ptr<persistent_data::UserSession>
performBasicAuth(const boost::asio::ip::address& clientIp,
std::string_view authHeader)
{
- BMCWEB_LOG_DEBUG << "[AuthMiddleware] Basic authentication";
+ BMCWEB_LOG_DEBUG("[AuthMiddleware] Basic authentication");
if (!authHeader.starts_with("Basic "))
{
@@ -66,9 +66,9 @@ static std::shared_ptr<persistent_data::UserSession>
}
std::string pass = authData.substr(separator);
- BMCWEB_LOG_DEBUG << "[AuthMiddleware] Authenticating user: " << user;
- BMCWEB_LOG_DEBUG << "[AuthMiddleware] User IPAddress: "
- << clientIp.to_string();
+ BMCWEB_LOG_DEBUG("[AuthMiddleware] Authenticating user: {}", user);
+ BMCWEB_LOG_DEBUG("[AuthMiddleware] User IPAddress: {}",
+ clientIp.to_string());
int pamrc = pamAuthenticateUser(user, pass);
bool isConfigureSelfOnly = pamrc == PAM_NEW_AUTHTOK_REQD;
@@ -93,7 +93,7 @@ static std::shared_ptr<persistent_data::UserSession>
static std::shared_ptr<persistent_data::UserSession>
performTokenAuth(std::string_view authHeader)
{
- BMCWEB_LOG_DEBUG << "[AuthMiddleware] Token authentication";
+ BMCWEB_LOG_DEBUG("[AuthMiddleware] Token authentication");
if (!authHeader.starts_with("Token "))
{
return nullptr;
@@ -109,7 +109,7 @@ static std::shared_ptr<persistent_data::UserSession>
static std::shared_ptr<persistent_data::UserSession>
performXtokenAuth(const boost::beast::http::header<true>& reqHeader)
{
- BMCWEB_LOG_DEBUG << "[AuthMiddleware] X-Auth-Token authentication";
+ BMCWEB_LOG_DEBUG("[AuthMiddleware] X-Auth-Token authentication");
std::string_view token = reqHeader["X-Auth-Token"];
if (token.empty())
@@ -127,7 +127,7 @@ static std::shared_ptr<persistent_data::UserSession>
performCookieAuth(boost::beast::http::verb method [[maybe_unused]],
const boost::beast::http::header<true>& reqHeader)
{
- BMCWEB_LOG_DEBUG << "[AuthMiddleware] Cookie authentication";
+ BMCWEB_LOG_DEBUG("[AuthMiddleware] Cookie authentication");
std::string_view cookieValue = reqHeader["Cookie"];
if (cookieValue.empty())
@@ -195,8 +195,8 @@ static std::shared_ptr<persistent_data::UserSession>
// set cookie only if this is req from the browser.
if (reqHeader["User-Agent"].empty())
{
- BMCWEB_LOG_DEBUG << " TLS session: " << sp->uniqueId
- << " will be used for this request.";
+ BMCWEB_LOG_DEBUG(" TLS session: {} will be used for this request.",
+ sp->uniqueId);
return sp;
}
// TODO: change this to not switch to cookie auth
@@ -208,8 +208,9 @@ static std::shared_ptr<persistent_data::UserSession>
"; SameSite=Strict; Secure; HttpOnly");
res.addHeader(boost::beast::http::field::set_cookie,
"IsAuthenticated=true; Secure");
- BMCWEB_LOG_DEBUG << " TLS session: " << sp->uniqueId
- << " with cookie will be used for this request.";
+ BMCWEB_LOG_DEBUG(
+ " TLS session: {} with cookie will be used for this request.",
+ sp->uniqueId);
return sp;
}
return nullptr;
@@ -284,7 +285,7 @@ static std::shared_ptr<persistent_data::UserSession>
}
#endif
std::string_view authHeader = reqHeader["Authorization"];
- BMCWEB_LOG_DEBUG << "authHeader=" << authHeader;
+ BMCWEB_LOG_DEBUG("authHeader={}", authHeader);
if (sessionOut == nullptr && authMethodsConfig.sessionToken)
{
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 4ecc4367d9..26827172a4 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -36,7 +36,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
{
if (retError == nullptr || (sd_bus_error_is_set(retError) != 0))
{
- BMCWEB_LOG_ERROR << "Got sdbus error on match";
+ BMCWEB_LOG_ERROR("Got sdbus error on match");
return 0;
}
crow::websocket::Connection* connection =
@@ -44,7 +44,8 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
auto thisSession = sessions.find(connection);
if (thisSession == sessions.end())
{
- BMCWEB_LOG_ERROR << "Couldn't find dbus connection " << connection;
+ BMCWEB_LOG_ERROR("Couldn't find dbus connection {}",
+ logPtr(connection));
return 0;
}
sdbusplus::message_t message(m);
@@ -57,12 +58,12 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
int r = openbmc_mapper::convertDBusToJSON("sa{sv}as", message, data);
if (r < 0)
{
- BMCWEB_LOG_ERROR << "convertDBusToJSON failed with " << r;
+ BMCWEB_LOG_ERROR("convertDBusToJSON failed with {}", r);
return 0;
}
if (!data.is_array())
{
- BMCWEB_LOG_ERROR << "No data in PropertiesChanged signal";
+ BMCWEB_LOG_ERROR("No data in PropertiesChanged signal");
return 0;
}
@@ -76,13 +77,13 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
int r = openbmc_mapper::convertDBusToJSON("oa{sa{sv}}", message, data);
if (r < 0)
{
- BMCWEB_LOG_ERROR << "convertDBusToJSON failed with " << r;
+ BMCWEB_LOG_ERROR("convertDBusToJSON failed with {}", r);
return 0;
}
if (!data.is_array())
{
- BMCWEB_LOG_ERROR << "No data in InterfacesAdded signal";
+ BMCWEB_LOG_ERROR("No data in InterfacesAdded signal");
return 0;
}
@@ -98,8 +99,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata,
}
else
{
- BMCWEB_LOG_CRITICAL << "message " << message.get_member()
- << " was unexpected";
+ BMCWEB_LOG_CRITICAL("message {} was unexpected", message.get_member());
return 0;
}
@@ -114,140 +114,140 @@ inline void requestRoutes(App& app)
.privileges({{"Login"}})
.websocket()
.onopen([&](crow::websocket::Connection& conn) {
- BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
+ BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn));
sessions.try_emplace(&conn);
})
.onclose([&](crow::websocket::Connection& conn, const std::string&) {
sessions.erase(&conn);
})
- .onmessage(
- [&](crow::websocket::Connection& conn, const std::string& data,
- bool) {
- const auto sessionPair = sessions.find(&conn);
- if (sessionPair == sessions.end())
- {
- conn.close("Internal error");
- }
- DbusWebsocketSession& thisSession = sessionPair->second;
- BMCWEB_LOG_DEBUG << "Connection " << &conn << " received " << data;
- nlohmann::json j = nlohmann::json::parse(data, nullptr, false);
- if (j.is_discarded())
- {
- BMCWEB_LOG_ERROR << "Unable to parse json data for monitor";
- conn.close("Unable to parse json request");
- return;
- }
- nlohmann::json::iterator interfaces = j.find("interfaces");
- if (interfaces != j.end())
- {
- thisSession.interfaces.reserve(interfaces->size());
- for (auto& interface : *interfaces)
+ .onmessage([&](crow::websocket::Connection& conn,
+ const std::string& data, bool) {
+ const auto sessionPair = sessions.find(&conn);
+ if (sessionPair == sessions.end())
+ {
+ conn.close("Internal error");
+ }
+ DbusWebsocketSession& thisSession = sessionPair->second;
+ BMCWEB_LOG_DEBUG("Connection {} received {}", logPtr(&conn), data);
+ nlohmann::json j = nlohmann::json::parse(data, nullptr, false);
+ if (j.is_discarded())
+ {
+ BMCWEB_LOG_ERROR("Unable to parse json data for monitor");
+ conn.close("Unable to parse json request");
+ return;
+ }
+ nlohmann::json::iterator interfaces = j.find("interfaces");
+ if (interfaces != j.end())
{
- const std::string* str =
- interface.get_ptr<const std::string*>();
- if (str != nullptr)
+ thisSession.interfaces.reserve(interfaces->size());
+ for (auto& interface : *interfaces)
{
- thisSession.interfaces.insert(*str);
+ const std::string* str =
+ interface.get_ptr<const std::string*>();
+ if (str != nullptr)
+ {
+ thisSession.interfaces.insert(*str);
+ }
}
}
- }
-
- nlohmann::json::iterator paths = j.find("paths");
- if (paths == j.end())
- {
- BMCWEB_LOG_ERROR << "Unable to find paths in json data";
- conn.close("Unable to find paths in json data");
- return;
- }
- size_t interfaceCount = thisSession.interfaces.size();
- if (interfaceCount == 0)
- {
- interfaceCount = 1;
- }
- // Reserve our matches upfront. For each path there is 1 for
- // interfacesAdded, and InterfaceCount number for
- // PropertiesChanged
- thisSession.matches.reserve(thisSession.matches.size() +
- paths->size() * (1U + interfaceCount));
-
- // These regexes derived on the rules here:
- // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names
- static std::regex validPath("^/([A-Za-z0-9_]+/?)*$");
- static std::regex validInterface(
- "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$");
-
- for (const auto& thisPath : *paths)
- {
- const std::string* thisPathString =
- thisPath.get_ptr<const std::string*>();
- if (thisPathString == nullptr)
+ nlohmann::json::iterator paths = j.find("paths");
+ if (paths == j.end())
{
- BMCWEB_LOG_ERROR << "subscribe path isn't a string?";
- conn.close();
+ BMCWEB_LOG_ERROR("Unable to find paths in json data");
+ conn.close("Unable to find paths in json data");
return;
}
- if (!std::regex_match(*thisPathString, validPath))
+
+ size_t interfaceCount = thisSession.interfaces.size();
+ if (interfaceCount == 0)
{
- BMCWEB_LOG_ERROR << "Invalid path name " << *thisPathString;
- conn.close();
- return;
+ interfaceCount = 1;
}
- std::string propertiesMatchString =
- ("type='signal',"
- "interface='org.freedesktop.DBus.Properties',"
- "path_namespace='" +
- *thisPathString +
- "',"
- "member='PropertiesChanged'");
- // If interfaces weren't specified, add a single match for all
- // interfaces
- if (thisSession.interfaces.empty())
+ // Reserve our matches upfront. For each path there is 1 for
+ // interfacesAdded, and InterfaceCount number for
+ // PropertiesChanged
+ thisSession.matches.reserve(thisSession.matches.size() +
+ paths->size() * (1U + interfaceCount));
+
+ // These regexes derived on the rules here:
+ // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names
+ static std::regex validPath("^/([A-Za-z0-9_]+/?)*$");
+ static std::regex validInterface(
+ "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$");
+
+ for (const auto& thisPath : *paths)
{
- BMCWEB_LOG_DEBUG << "Creating match " << propertiesMatchString;
+ const std::string* thisPathString =
+ thisPath.get_ptr<const std::string*>();
+ if (thisPathString == nullptr)
+ {
+ BMCWEB_LOG_ERROR("subscribe path isn't a string?");
+ conn.close();
+ return;
+ }
+ if (!std::regex_match(*thisPathString, validPath))
+ {
+ BMCWEB_LOG_ERROR("Invalid path name {}", *thisPathString);
+ conn.close();
+ return;
+ }
+ std::string propertiesMatchString =
+ ("type='signal',"
+ "interface='org.freedesktop.DBus.Properties',"
+ "path_namespace='" +
+ *thisPathString +
+ "',"
+ "member='PropertiesChanged'");
+ // If interfaces weren't specified, add a single match for all
+ // interfaces
+ if (thisSession.interfaces.empty())
+ {
+ BMCWEB_LOG_DEBUG("Creating match {}",
+ propertiesMatchString);
- thisSession.matches.emplace_back(
- std::make_unique<sdbusplus::bus::match_t>(
- *crow::connections::systemBus, propertiesMatchString,
- onPropertyUpdate, &conn));
- }
- else
- {
- // If interfaces were specified, add a match for each
- // interface
- for (const std::string& interface : thisSession.interfaces)
+ thisSession.matches.emplace_back(
+ std::make_unique<sdbusplus::bus::match_t>(
+ *crow::connections::systemBus,
+ propertiesMatchString, onPropertyUpdate, &conn));
+ }
+ else
{
- if (!std::regex_match(interface, validInterface))
+ // If interfaces were specified, add a match for each
+ // interface
+ for (const std::string& interface : thisSession.interfaces)
{
- BMCWEB_LOG_ERROR << "Invalid interface name "
- << interface;
- conn.close();
- return;
+ if (!std::regex_match(interface, validInterface))
+ {
+ BMCWEB_LOG_ERROR("Invalid interface name {}",
+ interface);
+ conn.close();
+ return;
+ }
+ std::string ifaceMatchString = propertiesMatchString;
+ ifaceMatchString += ",arg0='";
+ ifaceMatchString += interface;
+ ifaceMatchString += "'";
+ BMCWEB_LOG_DEBUG("Creating match {}", ifaceMatchString);
+ thisSession.matches.emplace_back(
+ std::make_unique<sdbusplus::bus::match_t>(
+ *crow::connections::systemBus, ifaceMatchString,
+ onPropertyUpdate, &conn));
}
- std::string ifaceMatchString = propertiesMatchString;
- ifaceMatchString += ",arg0='";
- ifaceMatchString += interface;
- ifaceMatchString += "'";
- BMCWEB_LOG_DEBUG << "Creating match " << ifaceMatchString;
- thisSession.matches.emplace_back(
- std::make_unique<sdbusplus::bus::match_t>(
- *crow::connections::systemBus, ifaceMatchString,
- onPropertyUpdate, &conn));
}
+ std::string objectManagerMatchString =
+ ("type='signal',"
+ "interface='org.freedesktop.DBus.ObjectManager',"
+ "path_namespace='" +
+ *thisPathString +
+ "',"
+ "member='InterfacesAdded'");
+ BMCWEB_LOG_DEBUG("Creating match {}", objectManagerMatchString);
+ thisSession.matches.emplace_back(
+ std::make_unique<sdbusplus::bus::match_t>(
+ *crow::connections::systemBus, objectManagerMatchString,
+ onPropertyUpdate, &conn));
}
- std::string objectManagerMatchString =
- ("type='signal',"
- "interface='org.freedesktop.DBus.ObjectManager',"
- "path_namespace='" +
- *thisPathString +
- "',"
- "member='InterfacesAdded'");
- BMCWEB_LOG_DEBUG << "Creating match " << objectManagerMatchString;
- thisSession.matches.emplace_back(
- std::make_unique<sdbusplus::bus::match_t>(
- *crow::connections::systemBus, objectManagerMatchString,
- onPropertyUpdate, &conn));
- }
});
}
} // namespace dbus_monitor
diff --git a/include/dbus_privileges.hpp b/include/dbus_privileges.hpp
index 377a41cbee..65b4042492 100644
--- a/include/dbus_privileges.hpp
+++ b/include/dbus_privileges.hpp
@@ -34,7 +34,7 @@ inline bool
if (!success)
{
- BMCWEB_LOG_ERROR << "Failed to unpack user properties.";
+ BMCWEB_LOG_ERROR("Failed to unpack user properties.");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return false;
@@ -43,13 +43,13 @@ inline bool
if (userRolePtr != nullptr)
{
req.session->userRole = *userRolePtr;
- BMCWEB_LOG_DEBUG << "userName = " << req.session->username
- << " userRole = " << *userRolePtr;
+ BMCWEB_LOG_DEBUG("userName = {} userRole = {}", req.session->username,
+ *userRolePtr);
}
if (remoteUser == nullptr)
{
- BMCWEB_LOG_ERROR << "RemoteUser property missing or wrong type";
+ BMCWEB_LOG_ERROR("RemoteUser property missing or wrong type");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return false;
@@ -59,8 +59,8 @@ inline bool
{
if (!*remoteUser)
{
- BMCWEB_LOG_ERROR << "UserPasswordExpired property is expected for"
- " local user but is missing or wrong type";
+ BMCWEB_LOG_ERROR("UserPasswordExpired property is expected for"
+ " local user but is missing or wrong type");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return false;
@@ -103,7 +103,7 @@ inline bool
// Remove all privileges except ConfigureSelf
userPrivileges =
userPrivileges.intersection(redfish::Privileges{"ConfigureSelf"});
- BMCWEB_LOG_DEBUG << "Operation limited to ConfigureSelf";
+ BMCWEB_LOG_DEBUG("Operation limited to ConfigureSelf");
}
if (!rule.checkPrivileges(userPrivileges))
@@ -132,7 +132,7 @@ void afterGetUserInfo(Request& req,
{
if (ec)
{
- BMCWEB_LOG_ERROR << "GetUserInfo failed...";
+ BMCWEB_LOG_ERROR("GetUserInfo failed...");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return;
@@ -140,7 +140,7 @@ void afterGetUserInfo(Request& req,
if (!populateUserInfo(req, asyncResp, userInfoMap))
{
- BMCWEB_LOG_ERROR << "Failed to populate user information";
+ BMCWEB_LOG_ERROR("Failed to populate user information");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return;
@@ -149,7 +149,7 @@ void afterGetUserInfo(Request& req,
if (!isUserPrivileged(req, asyncResp, rule))
{
// User is not privileged
- BMCWEB_LOG_ERROR << "Insufficient Privilege";
+ BMCWEB_LOG_ERROR("Insufficient Privilege");
asyncResp->res.result(boost::beast::http::status::forbidden);
return;
}
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index f8e53f44af..948b8f0965 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -111,7 +111,7 @@ inline void logError(const boost::system::error_code& ec)
{
if (ec)
{
- BMCWEB_LOG_ERROR << "DBus error: " << ec << ", cannot call method";
+ BMCWEB_LOG_ERROR("DBus error: {}, cannot call method", ec);
}
}
diff --git a/include/event_service_store.hpp b/include/event_service_store.hpp
index dcc99f102c..61f1ac7b0f 100644
--- a/include/event_service_store.hpp
+++ b/include/event_service_store.hpp
@@ -151,8 +151,8 @@ struct UserSubscription
val.value().get_ptr<const std::string*>();
if (value == nullptr)
{
- BMCWEB_LOG_ERROR << "Failed to parse value for key"
- << val.key();
+ BMCWEB_LOG_ERROR("Failed to parse value for key{}",
+ val.key());
continue;
}
subvalue->httpHeaders.set(val.key(), *value);
@@ -174,9 +174,9 @@ struct UserSubscription
}
else
{
- BMCWEB_LOG_ERROR
- << "Got unexpected property reading persistent file: "
- << element.key();
+ BMCWEB_LOG_ERROR(
+ "Got unexpected property reading persistent file: {}",
+ element.key());
continue;
}
}
@@ -187,8 +187,8 @@ struct UserSubscription
subvalue->eventFormatType.empty() ||
subvalue->subscriptionType.empty())
{
- BMCWEB_LOG_ERROR << "Subscription missing required field "
- "information, refusing to restore";
+ BMCWEB_LOG_ERROR("Subscription missing required field "
+ "information, refusing to restore");
return nullptr;
}
diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp
index f39b45f572..bb51490e9d 100644
--- a/include/google/google_service_root.hpp
+++ b/include/google/google_service_root.hpp
@@ -153,8 +153,8 @@ inline void
{
if (ec)
{
- BMCWEB_LOG_ERROR << "RootOfTrust.Actions.SendCommand failed: "
- << ec.message();
+ BMCWEB_LOG_ERROR("RootOfTrust.Actions.SendCommand failed: {}",
+ ec.message());
redfish::messages::internalError(asyncResp->res);
return;
}
@@ -171,7 +171,7 @@ inline void
std::vector<uint8_t> bytes = hexStringToBytes(command);
if (bytes.empty())
{
- BMCWEB_LOG_DEBUG << "Invalid command: " << command;
+ BMCWEB_LOG_DEBUG("Invalid command: {}", command);
redfish::messages::actionParameterValueTypeError(command, "Command",
"SendCommand");
return;
@@ -195,7 +195,7 @@ inline void handleRoTSendCommandPost(
if (!redfish::json_util::readJsonAction(request, asyncResp->res, "Command",
command))
{
- BMCWEB_LOG_DEBUG << "Missing property Command.";
+ BMCWEB_LOG_DEBUG("Missing property Command.");
redfish::messages::actionParameterMissing(asyncResp->res, "SendCommand",
"Command");
return;
diff --git a/include/hostname_monitor.hpp b/include/hostname_monitor.hpp
index fd49b02cf4..f1a0d3d2c1 100644
--- a/include/hostname_monitor.hpp
+++ b/include/hostname_monitor.hpp
@@ -22,12 +22,12 @@ inline void installCertificate(const std::filesystem::path& certPath)
[certPath](const boost::system::error_code& ec) {
if (ec)
{
- BMCWEB_LOG_ERROR << "Replace Certificate Fail..";
+ BMCWEB_LOG_ERROR("Replace Certificate Fail..");
return;
}
- BMCWEB_LOG_INFO << "Replace HTTPs Certificate Success, "
- "remove temporary certificate file..";
+ BMCWEB_LOG_INFO("Replace HTTPs Certificate Success, "
+ "remove temporary certificate file..");
remove(certPath.c_str());
},
"xyz.openbmc_project.Certs.Manager.Server.Https",
@@ -40,7 +40,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
{
if (retError == nullptr || (sd_bus_error_is_set(retError) != 0))
{
- BMCWEB_LOG_ERROR << "Got sdbus error on match";
+ BMCWEB_LOG_ERROR("Got sdbus error on match");
return 0;
}
@@ -62,13 +62,13 @@ inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
return 0;
}
- BMCWEB_LOG_DEBUG << "Read hostname from signal: " << *hostname;
+ BMCWEB_LOG_DEBUG("Read hostname from signal: {}", *hostname);
const std::string certFile = "/etc/ssl/certs/https/server.pem";
X509* cert = ensuressl::loadCert(certFile);
if (cert == nullptr)
{
- BMCWEB_LOG_ERROR << "Failed to read cert";
+ BMCWEB_LOG_ERROR("Failed to read cert");
return 0;
}
@@ -80,7 +80,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
cnBuffer.size());
if (cnLength == -1)
{
- BMCWEB_LOG_ERROR << "Failed to read NID_commonName";
+ BMCWEB_LOG_ERROR("Failed to read NID_commonName");
X509_free(cert);
return 0;
}
@@ -90,16 +90,16 @@ inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
EVP_PKEY* pPubKey = X509_get_pubkey(cert);
if (pPubKey == nullptr)
{
- BMCWEB_LOG_ERROR << "Failed to get public key";
+ BMCWEB_LOG_ERROR("Failed to get public key");
X509_free(cert);
return 0;
}
int isSelfSigned = X509_verify(cert, pPubKey);
EVP_PKEY_free(pPubKey);
- BMCWEB_LOG_DEBUG << "Current HTTPs Certificate Subject CN: " << cnValue
- << ", New HostName: " << *hostname
- << ", isSelfSigned: " << isSelfSigned;
+ BMCWEB_LOG_DEBUG(
+ "Current HTTPs Certificate Subject CN: {}, New HostName: {}, isSelfSigned: {}",
+ cnValue, *hostname, isSelfSigned);
ASN1_IA5STRING* asn1 = static_cast<ASN1_IA5STRING*>(
X509_get_ext_d2i(cert, NID_netscape_comment, nullptr, nullptr));
@@ -108,13 +108,14 @@ inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
std::string_view comment(reinterpret_cast<const char*>(asn1->data),
static_cast<size_t>(asn1->length));
- BMCWEB_LOG_DEBUG << "x509Comment: " << comment;
+ BMCWEB_LOG_DEBUG("x509Comment: {}", comment);
if (ensuressl::x509Comment == comment && isSelfSigned == 1 &&
cnValue != *hostname)
{
- BMCWEB_LOG_INFO << "Ready to generate new HTTPs "
- << "certificate with subject cn: " << *hostname;
+ BMCWEB_LOG_INFO(
+ "Ready to generate new HTTPs certificate with subject cn: {}",
+ *hostname);
ensuressl::generateSslCertificate("/tmp/hostname_cert.tmp",
*hostname);
@@ -128,7 +129,7 @@ inline int onPropertyUpdate(sd_bus_message* m, void* /* userdata */,
inline void registerHostnameSignal()
{
- BMCWEB_LOG_INFO << "Register HostName PropertiesChanged Signal";
+ BMCWEB_LOG_INFO("Register HostName PropertiesChanged Signal");
std::string propertiesMatchString =
("type='signal',"
"interface='org.freedesktop.DBus.Properties',"
diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp
index b61f9a5e47..2208aaffed 100644
--- a/include/ibm/locks.hpp
+++ b/include/ibm/locks.hpp
@@ -200,7 +200,7 @@ inline RcGetLockList Lock::getLockList(const ListOfSessionIds& listSessionId)
// given
if (std::get<0>(it->second[0]) == i)
{
- BMCWEB_LOG_DEBUG << "Session id is found in the locktable";
+ BMCWEB_LOG_DEBUG("Session id is found in the locktable");
// Push the whole lock record into a vector for returning
// the json
@@ -225,7 +225,7 @@ inline RcReleaseLockApi Lock::releaseLock(const ListOfTransactionIds& p,
if (!status)
{
// Validation of rids failed
- BMCWEB_LOG_ERROR << "releaseLock: Contains invalid request id";
+ BMCWEB_LOG_ERROR("releaseLock: Contains invalid request id");
return std::make_pair(false, status);
}
// Validation passed, check if all the locks are owned by the
@@ -247,8 +247,8 @@ inline RcAcquireLock Lock::acquireLock(const LockRequests& lockRequestStructure)
bool status = isValidLockRequest(lockRecord);
if (!status)
{
- BMCWEB_LOG_DEBUG << "Not a Valid record";
- BMCWEB_LOG_DEBUG << "Bad json in request";
+ BMCWEB_LOG_DEBUG("Not a Valid record");
+ BMCWEB_LOG_DEBUG("Bad json in request");
return std::make_pair(true, std::make_pair(status, 0));
}
}
@@ -259,16 +259,16 @@ inline RcAcquireLock Lock::acquireLock(const LockRequests& lockRequestStructure)
if (status)
{
- BMCWEB_LOG_DEBUG << "There is a conflict within itself";
+ BMCWEB_LOG_DEBUG("There is a conflict within itself");
return std::make_pair(true, std::make_pair(status, 1));
}
- BMCWEB_LOG_DEBUG << "The request is not conflicting within itself";
+ BMCWEB_LOG_DEBUG("The request is not conflicting within itself");
// Need to check for conflict with the locktable entries.
auto conflict = isConflictWithTable(multiRequest);
- BMCWEB_LOG_DEBUG << "Done with checking conflict with the locktable";
+ BMCWEB_LOG_DEBUG("Done with checking conflict with the locktable");
return std::make_pair(false, conflict);
}
@@ -285,10 +285,10 @@ inline void Lock::releaseLock(const std::string& sessionId)
// given
if (std::get<0>(it->second[0]) == sessionId)
{
- BMCWEB_LOG_DEBUG << "Remove the lock from the locktable "
- "having sessionID="
- << sessionId;
- BMCWEB_LOG_DEBUG << "TransactionID =" << it->first;
+ BMCWEB_LOG_DEBUG("Remove the lock from the locktable "
+ "having sessionID={}",
+ sessionId);
+ BMCWEB_LOG_DEBUG("TransactionID ={}", it->first);
it = lockTable.erase(it);
}
else
@@ -315,23 +315,23 @@ inline RcRelaseLock Lock::isItMyLock(const ListOfTransactionIds& refRids,
(expectedSessionId == ids.second))
{
// It is owned by the currently request hmc
- BMCWEB_LOG_DEBUG << "Lock is owned by the current hmc";
+ BMCWEB_LOG_DEBUG("Lock is owned by the current hmc");
// remove the lock
if (lockTable.erase(id) != 0U)
{
- BMCWEB_LOG_DEBUG << "Removing the locks with transaction ID : "
- << id;
+ BMCWEB_LOG_DEBUG("Removing the locks with transaction ID : {}",
+ id);
}
else
{
- BMCWEB_LOG_ERROR << "Removing the locks from the lock table "
- "failed, transaction ID: "
- << id;
+ BMCWEB_LOG_ERROR("Removing the locks from the lock table "
+ "failed, transaction ID: {}",
+ id);
}
}
else
{
- BMCWEB_LOG_DEBUG << "Lock is not owned by the current hmc";
+ BMCWEB_LOG_DEBUG("Lock is not owned by the current hmc");
return std::make_pair(false, std::make_pair(id, lockTable[id][0]));
}
}
@@ -346,13 +346,13 @@ inline bool Lock::validateRids(const ListOfTransactionIds& refRids)
if (search != lockTable.end())
{
- BMCWEB_LOG_DEBUG << "Valid Transaction id";
+ BMCWEB_LOG_DEBUG("Valid Transaction id");
// continue for the next rid
}
else
{
- BMCWEB_LOG_ERROR << "validateRids: At least 1 inValid Request id: "
- << id;
+ BMCWEB_LOG_ERROR("validateRids: At least 1 inValid Request id: {}",
+ id);
return false;
}
}
@@ -366,21 +366,21 @@ inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord)
if (!((boost::equals(std::get<2>(refLockRecord), "Read") ||
(boost::equals(std::get<2>(refLockRecord), "Write")))))
{
- BMCWEB_LOG_DEBUG << "Validation of LockType Failed";
- BMCWEB_LOG_DEBUG << "Locktype : " << std::get<2>(refLockRecord);
+ BMCWEB_LOG_DEBUG("Validation of LockType Failed");
+ BMCWEB_LOG_DEBUG("Locktype : {}", std::get<2>(refLockRecord));
return false;
}
- BMCWEB_LOG_DEBUG << static_cast<int>(std::get<4>(refLockRecord).size());
+ BMCWEB_LOG_DEBUG("{}", static_cast<int>(std::get<4>(refLockRecord).size()));
// validate the number of segments
// Allowed No of segments are between 2 and 6
if ((static_cast<int>(std::get<4>(refLockRecord).size()) > 6) ||
(static_cast<int>(std::get<4>(refLockRecord).size()) < 2))
{
- BMCWEB_LOG_DEBUG << "Validation of Number of Segments Failed";
- BMCWEB_LOG_DEBUG << "Number of Segments provied : "
- << std::get<4>(refLockRecord).size();
+ BMCWEB_LOG_DEBUG("Validation of Number of Segments Failed");
+ BMCWEB_LOG_DEBUG("Number of Segments provied : {}",
+ std::get<4>(refLockRecord).size());
return false;
}
@@ -396,8 +396,8 @@ inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord)
(boost::equals(p.first, "LockAll")) ||
(boost::equals(p.first, "DontLock")))))
{
- BMCWEB_LOG_DEBUG << "Validation of lock flags failed";
- BMCWEB_LOG_DEBUG << p.first;
+ BMCWEB_LOG_DEBUG("Validation of lock flags failed");
+ BMCWEB_LOG_DEBUG("{}", p.first);
return false;
}
@@ -406,8 +406,8 @@ inline bool Lock::isValidLockRequest(const LockRequest& refLockRecord)
if (p.second < 1 || p.second > 4)
{
- BMCWEB_LOG_DEBUG << "Validation of Segment Length Failed";
- BMCWEB_LOG_DEBUG << p.second;
+ BMCWEB_LOG_DEBUG("Validation of Segment Length Failed");
+ BMCWEB_LOG_DEBUG("{}", p.second);
return false;
}
@@ -430,16 +430,16 @@ inline Rc Lock::isConflictWithTable(const LockRequests& refLockRequestStructure)
if (lockTable.empty())
{
uint32_t thisTransactionId = generateTransactionId();
- BMCWEB_LOG_DEBUG << thisTransactionId;
+ BMCWEB_LOG_DEBUG("{}", thisTransactionId);
// Lock table is empty, so we are safe to add the lockrecords
// as there will be no conflict
- BMCWEB_LOG_DEBUG << "Lock table is empty, so adding the lockrecords";
+ BMCWEB_LOG_DEBUG("Lock table is empty, so adding the lockrecords");
lockTable.emplace(thisTransactionId, refLockRequestStructure);
return std::make_pair(false, thisTransactionId);
}
- BMCWEB_LOG_DEBUG
- << "Lock table is not empty, check for conflict with lock table";
+ BMCWEB_LOG_DEBUG(
+ "Lock table is not empty, check for conflict with lock table");
// Lock table is not empty, compare the lockrequest entries with
// the entries in the lock table
@@ -464,7 +464,7 @@ inline Rc Lock::isConflictWithTable(const LockRequests& refLockRequestStructure)
// Lock table is empty, so we are safe to add the lockrecords
// as there will be no conflict
- BMCWEB_LOG_DEBUG << " Adding elements into lock table";
+ BMCWEB_LOG_DEBUG(" Adding elements into lock table");
transactionId = generateTransactionId();
lockTable.emplace(std::make_pair(transactionId, refLockRequestStructure));
@@ -478,14 +478,14 @@ inline bool Lock::isConflictRequest(const LockRequests& refLockRequestStructure)
if (refLockRequestStructure.size() == 1)
{
- BMCWEB_LOG_DEBUG << "Only single lock request, so there is no conflict";
+ BMCWEB_LOG_DEBUG("Only single lock request, so there is no conflict");
// This means , we have only one lock request in the current
// request , so no conflict within the request
return false;
}
- BMCWEB_LOG_DEBUG
- << "There are multiple lock requests coming in a single request";
+ BMCWEB_LOG_DEBUG(
+ "There are multiple lock requests coming in a single request");
// There are multiple requests a part of one request
@@ -537,7 +537,7 @@ inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1,
if (boost::equals(std::get<2>(refLockRecord1), "Read") &&
boost::equals(std::get<2>(refLockRecord2), "Read"))
{
- BMCWEB_LOG_DEBUG << "Both are read locks, no conflict";
+ BMCWEB_LOG_DEBUG("Both are read locks, no conflict");
return false;
}
@@ -549,9 +549,9 @@ inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1,
if (boost::equals(p.first, "LockAll") ||
boost::equals(std::get<4>(refLockRecord2)[i].first, "LockAll"))
{
- BMCWEB_LOG_DEBUG
- << "Either of the Comparing locks are trying to lock all "
- "resources under the current resource level";
+ BMCWEB_LOG_DEBUG(
+ "Either of the Comparing locks are trying to lock all "
+ "resources under the current resource level");
return true;
}
@@ -569,10 +569,10 @@ inline bool Lock::isConflictRecord(const LockRequest& refLockRecord1,
// So no conflict
if (p.second != std::get<4>(refLockRecord2)[i].second)
{
- BMCWEB_LOG_DEBUG << "Segment lengths are not same";
- BMCWEB_LOG_DEBUG << "Segment 1 length : " << p.second;
- BMCWEB_LOG_DEBUG << "Segment 2 length : "
- << std::get<4>(refLockRecord2)[i].second;
+ BMCWEB_LOG_DEBUG("Segment lengths are not same");
+ BMCWEB_LOG_DEBUG("Segment 1 length : {}", p.second);
+ BMCWEB_LOG_DEBUG("Segment 2 length : {}",
+ std::get<4>(refLockRecord2)[i].second);
return false;
}
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index 579d46c431..b87cb1ee19 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -55,11 +55,11 @@ inline void handleFilePut(const crow::Request& req,
asyncResp->res.jsonValue["Description"] = contentNotAcceptableMsg;
return;
}
- BMCWEB_LOG_DEBUG
- << "File upload in application/octet-stream format. Continue..";
+ BMCWEB_LOG_DEBUG(
+ "File upload in application/octet-stream format. Continue..");
- BMCWEB_LOG_DEBUG
- << "handleIbmPut: Request to create/update the save-area file";
+ BMCWEB_LOG_DEBUG(
+ "handleIbmPut: Request to create/update the save-area file");
std::string_view path =
"/var/lib/bmcweb/ibm-management-console/configfiles";
if (!crow::ibm_utils::createDirectory(path))
@@ -80,9 +80,9 @@ inline void handleFilePut(const crow::Request& req,
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] = internalServerError;
- BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to prepare save-area "
- "directory iterator. ec : "
- << ec;
+ BMCWEB_LOG_DEBUG("handleIbmPut: Failed to prepare save-area "
+ "directory iterator. ec : {}",
+ ec.message());
return;
}
std::uintmax_t saveAreaDirSize = 0;
@@ -95,9 +95,9 @@ inline void handleFilePut(const crow::Request& req,
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] = internalServerError;
- BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find save-area "
- "directory . ec : "
- << ec;
+ BMCWEB_LOG_DEBUG("handleIbmPut: Failed to find save-area "
+ "directory . ec : {}",
+ ec.message());
return;
}
std::uintmax_t fileSize = std::filesystem::file_size(it, ec);
@@ -106,19 +106,19 @@ inline void handleFilePut(const crow::Request& req,
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] = internalServerError;
- BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find save-area "
- "file size inside the directory . ec : "
- << ec;
+ BMCWEB_LOG_DEBUG("handleIbmPut: Failed to find save-area "
+ "file size inside the directory . ec : {}",
+ ec.message());
return;
}
saveAreaDirSize += fileSize;
}
}
- BMCWEB_LOG_DEBUG << "saveAreaDirSize: " << saveAreaDirSize;
+ BMCWEB_LOG_DEBUG("saveAreaDirSize: {}", saveAreaDirSize);
// Get the file size getting uploaded
const std::string& data = req.body();
- BMCWEB_LOG_DEBUG << "data length: " << data.length();
+ BMCWEB_LOG_DEBUG("data length: {}", data.length());
if (data.length() < minSaveareaFileSize)
{
@@ -137,7 +137,7 @@ inline void handleFilePut(const crow::Request& req,
// Form the file path
loc /= fileID;
- BMCWEB_LOG_DEBUG << "Writing to the file: " << loc.string();
+ BMCWEB_LOG_DEBUG("Writing to the file: {}", loc.string());
// Check if the same file exists in the directory
bool fileExists = std::filesystem::exists(loc, ec);
@@ -146,8 +146,8 @@ inline void handleFilePut(const crow::Request& req,
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] = internalServerError;
- BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find if file exists. ec : "
- << ec;
+ BMCWEB_LOG_DEBUG("handleIbmPut: Failed to find if file exists. ec : {}",
+ ec.message());
return;
}
@@ -161,8 +161,8 @@ inline void handleFilePut(const crow::Request& req,
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] = internalServerError;
- BMCWEB_LOG_DEBUG << "handleIbmPut: Failed to find file size. ec : "
- << ec;
+ BMCWEB_LOG_DEBUG("handleIbmPut: Failed to find file size. ec : {}",
+ ec.message());
return;
}
// Calculate the difference in the file size.
@@ -175,7 +175,7 @@ inline void handleFilePut(const crow::Request& req,
{
newSizeToWrite = data.length() - currentFileSize;
}
- BMCWEB_LOG_DEBUG << "newSizeToWrite: " << newSizeToWrite;
+ BMCWEB_LOG_DEBUG("newSizeToWrite: {}", newSizeToWrite);
}
else
{
@@ -184,7 +184,7 @@ inline void handleFilePut(const crow::Request& req,
}
// Calculate the total dir size before writing the new file
- BMCWEB_LOG_DEBUG << "total new size: " << saveAreaDirSize + newSizeToWrite;
+ BMCWEB_LOG_DEBUG("total new size: {}", saveAreaDirSize + newSizeToWrite);
if ((saveAreaDirSize + newSizeToWrite) > maxSaveareaDirSize)
{
@@ -204,7 +204,7 @@ inline void handleFilePut(const crow::Request& req,
if (file.fail())
{
- BMCWEB_LOG_DEBUG << "Error while opening the file for writing";
+ BMCWEB_LOG_DEBUG("Error while opening the file for writing");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] =
@@ -217,12 +217,12 @@ inline void handleFilePut(const crow::Request& req,
// Push an event
if (fileExists)
{
- BMCWEB_LOG_DEBUG << "config file is updated";
+ BMCWEB_LOG_DEBUG("config file is updated");
asyncResp->res.jsonValue["Description"] = "File Updated";
}
else
{
- BMCWEB_LOG_DEBUG << "config file is created";
+ BMCWEB_LOG_DEBUG("config file is created");
asyncResp->res.jsonValue["Description"] = "File Created";
}
}
@@ -271,9 +271,9 @@ inline void
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] = internalServerError;
- BMCWEB_LOG_DEBUG << "deleteConfigFiles: Failed to delete the "
- "config files directory. ec : "
- << ec;
+ BMCWEB_LOG_DEBUG("deleteConfigFiles: Failed to delete the "
+ "config files directory. ec : {}",
+ ec.message());
}
}
}
@@ -297,12 +297,12 @@ inline void
inline void handleFileGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& fileID)
{
- BMCWEB_LOG_DEBUG << "HandleGet on SaveArea files on path: " << fileID;
+ BMCWEB_LOG_DEBUG("HandleGet on SaveArea files on path: {}", fileID);
std::filesystem::path loc(
"/var/lib/bmcweb/ibm-management-console/configfiles/" + fileID);
if (!std::filesystem::exists(loc) || !std::filesystem::is_regular_file(loc))
{
- BMCWEB_LOG_WARNING << loc.string() << " Not found";
+ BMCWEB_LOG_WARNING("{} Not found", loc.string());
asyncResp->res.result(boost::beast::http::status::not_found);
asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg;
return;
@@ -311,7 +311,7 @@ inline void handleFileGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
std::ifstream readfile(loc.string());
if (!readfile)
{
- BMCWEB_LOG_WARNING << loc.string() << " Not found";
+ BMCWEB_LOG_WARNING("{} Not found", loc.string());
asyncResp->res.result(boost::beast::http::status::not_found);
asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg;
return;
@@ -333,18 +333,18 @@ inline void
{
std::string filePath("/var/lib/bmcweb/ibm-management-console/configfiles/" +
fileID);
- BMCWEB_LOG_DEBUG << "Removing the file : " << filePath << "\n";
+ BMCWEB_LOG_DEBUG("Removing the file : {}", filePath);
std::ifstream fileOpen(filePath.c_str());
if (static_cast<bool>(fileOpen))
{
if (remove(filePath.c_str()) == 0)
{
- BMCWEB_LOG_DEBUG << "File removed!\n";
+ BMCWEB_LOG_DEBUG("File removed!");
asyncResp->res.jsonValue["Description"] = "File Deleted";
}
else
{
- BMCWEB_LOG_ERROR << "File not removed!\n";
+ BMCWEB_LOG_ERROR("File not removed!");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
asyncResp->res.jsonValue["Description"] = internalServerError;
@@ -352,7 +352,7 @@ inline void
}
else
{
- BMCWEB_LOG_WARNING << "File not found!\n";
+ BMCWEB_LOG_WARNING("File not found!");
asyncResp->res.result(boost::beast::http::status::not_found);
asyncResp->res.jsonValue["Description"] = resourceNotFoundMsg;
}
@@ -367,13 +367,13 @@ inline void
if (!redfish::json_util::readJsonPatch(req, asyncResp->res, "Message",
broadcastMsg))
{
- BMCWEB_LOG_DEBUG << "Not a Valid JSON";
+ BMCWEB_LOG_DEBUG("Not a Valid JSON");
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
if (broadcastMsg.size() > maxBroadcastMsgSize)
{
- BMCWEB_LOG_ERROR << "Message size exceeds maximum allowed size[1KB]";
+ BMCWEB_LOG_ERROR("Message size exceeds maximum allowed size[1KB]");
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
@@ -418,14 +418,14 @@ inline void
lockType, "ResourceID", resourceId,
"SegmentFlags", segmentFlags))
{
- BMCWEB_LOG_DEBUG << "Not a Valid JSON";
+ BMCWEB_LOG_DEBUG("Not a Valid JSON");
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
- BMCWEB_LOG_DEBUG << lockType;
- BMCWEB_LOG_DEBUG << resourceId;
+ BMCWEB_LOG_DEBUG("{}", lockType);
+ BMCWEB_LOG_DEBUG("{}", resourceId);
- BMCWEB_LOG_DEBUG << "Segment Flags are present";
+ BMCWEB_LOG_DEBUG("Segment Flags are present");
for (auto& e : segmentFlags)
{
@@ -440,8 +440,8 @@ inline void
return;
}
- BMCWEB_LOG_DEBUG << "Lockflag : " << lockFlags;
- BMCWEB_LOG_DEBUG << "SegmentLength : " << segmentLength;
+ BMCWEB_LOG_DEBUG("Lockflag : {}", lockFlags);
+ BMCWEB_LOG_DEBUG("SegmentLength : {}", segmentLength);
segInfo.emplace_back(std::make_pair(lockFlags, segmentLength));
}
@@ -455,14 +455,14 @@ inline void
for (auto& i : lockRequestStructure)
{
- BMCWEB_LOG_DEBUG << std::get<0>(i);
- BMCWEB_LOG_DEBUG << std::get<1>(i);
- BMCWEB_LOG_DEBUG << std::get<2>(i);
- BMCWEB_LOG_DEBUG << std::get<3>(i);
+ BMCWEB_LOG_DEBUG("{}", std::get<0>(i));
+ BMCWEB_LOG_DEBUG("{}", std::get<1>(i));
+ BMCWEB_LOG_DEBUG("{}", std::get<2>(i));
+ BMCWEB_LOG_DEBUG("{}", std::get<3>(i));
for (const auto& p : std::get<4>(i))
{
- BMCWEB_LOG_DEBUG << p.first << ", " << p.second;
+ BMCWEB_LOG_DEBUG("{}, {}", p.first, p.second);
}
}
@@ -479,14 +479,14 @@ inline void
if ((!validityStatus.first) && (validityStatus.second == 0))
{
- BMCWEB_LOG_DEBUG << "Not a Valid record";
- BMCWEB_LOG_DEBUG << "Bad json in request";
+ BMCWEB_LOG_DEBUG("Not a Valid record");
+ BMCWEB_LOG_DEBUG("Bad json in request");
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
if (validityStatus.first && (validityStatus.second == 1))
{
- BMCWEB_LOG_ERROR << "There is a conflict within itself";
+ BMCWEB_LOG_ERROR("There is a conflict within itself");
asyncResp->res.result(boost::beast::http::status::conflict);
return;
}
@@ -497,7 +497,7 @@ inline void
std::get<crow::ibm_mc_lock::Rc>(varAcquireLock.second);
if (!conflictStatus.first)
{
- BMCWEB_LOG_DEBUG << "There is no conflict with the locktable";
+ BMCWEB_LOG_DEBUG("There is no conflict with the locktable");
asyncResp->res.result(boost::beast::http::status::ok);
auto var = std::get<uint32_t>(conflictStatus.second);
@@ -506,7 +506,7 @@ inline void
asyncResp->res.jsonValue["TransactionID"] = var;
return;
}
- BMCWEB_LOG_DEBUG << "There is a conflict with the lock table";
+ BMCWEB_LOG_DEBUG("There is a conflict with the lock table");
asyncResp->res.result(boost::beast::http::status::conflict);
auto var =
std::get<std::pair<uint32_t, LockRequest>>(conflictStatus.second);
@@ -527,7 +527,7 @@ inline void
}
returnJson["SegmentFlags"] = myarray;
- BMCWEB_LOG_ERROR << "Conflicting lock record: " << returnJson;
+ BMCWEB_LOG_ERROR("Conflicting lock record: {}", returnJson);
asyncResp->res.jsonValue["Record"] = returnJson;
return;
}
@@ -545,11 +545,11 @@ inline void
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::vector<uint32_t>& listTransactionIds)
{
- BMCWEB_LOG_DEBUG << listTransactionIds.size();
- BMCWEB_LOG_DEBUG << "Data is present";
+ BMCWEB_LOG_DEBUG("{}", listTransactionIds.size());
+ BMCWEB_LOG_DEBUG("Data is present");
for (unsigned int listTransactionId : listTransactionIds)
{
- BMCWEB_LOG_DEBUG << listTransactionId;
+ BMCWEB_LOG_DEBUG("{}", listTransactionId);
}
// validate the request ids
@@ -561,7 +561,7 @@ inline void
if (!varReleaselock.first)
{
// validation Failed
- BMCWEB_LOG_ERROR << "handleReleaseLockAPI: validation failed";
+ BMCWEB_LOG_ERROR("handleReleaseLockAPI: validation failed");
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
@@ -575,7 +575,7 @@ inline void
}
// valid rid, but the current hmc does not own all the locks
- BMCWEB_LOG_DEBUG << "Current HMC does not own all the locks";
+ BMCWEB_LOG_DEBUG("Current HMC does not own all the locks");
asyncResp->res.result(boost::beast::http::status::unauthorized);
auto var = statusRelease.second;
@@ -596,7 +596,7 @@ inline void
}
returnJson["SegmentFlags"] = myArray;
- BMCWEB_LOG_DEBUG << "handleReleaseLockAPI: lockrecord: " << returnJson;
+ BMCWEB_LOG_DEBUG("handleReleaseLockAPI: lockrecord: {}", returnJson);
asyncResp->res.jsonValue["Record"] = returnJson;
}
@@ -604,7 +604,7 @@ inline void
handleGetLockListAPI(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const ListOfSessionIds& listSessionIds)
{
- BMCWEB_LOG_DEBUG << listSessionIds.size();
+ BMCWEB_LOG_DEBUG("{}", listSessionIds.size());
auto status =
crow::ibm_mc_lock::Lock::getInstance().getLockList(listSessionIds);
@@ -647,7 +647,7 @@ inline bool isValidConfigFileName(const std::string& fileName,
{
if (fileName.empty())
{
- BMCWEB_LOG_ERROR << "Empty filename";
+ BMCWEB_LOG_ERROR("Empty filename");
res.jsonValue["Description"] = "Empty file path in the url";
return false;
}
@@ -658,7 +658,7 @@ inline bool isValidConfigFileName(const std::string& fileName,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-");
if (found != std::string::npos)
{
- BMCWEB_LOG_ERROR << "Unsupported character in filename: " << fileName;
+ BMCWEB_LOG_ERROR("Unsupported character in filename: {}", fileName);
res.jsonValue["Description"] = "Unsupported character in filename";
return false;
}
@@ -666,9 +666,9 @@ inline bool isValidConfigFileName(const std::string& fileName,
// Check the filename length
if (fileName.length() > 20)
{
- BMCWEB_LOG_ERROR << "Name must be maximum 20 characters. "
- "Input filename length is: "
- << fileName.length();
+ BMCWEB_LOG_ERROR("Name must be maximum 20 characters. "
+ "Input filename length is: {}",
+ fileName.length());
res.jsonValue["Description"] = "Filename must be maximum 20 characters";
return false;
}
@@ -721,7 +721,7 @@ inline void requestRoutes(App& app)
[](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& fileName) {
- BMCWEB_LOG_DEBUG << "ConfigFile : " << fileName;
+ BMCWEB_LOG_DEBUG("ConfigFile : {}", fileName);
// Validate the incoming fileName
if (!isValidConfigFileName(fileName, asyncResp->res))
{
@@ -748,7 +748,7 @@ inline void requestRoutes(App& app)
if (!redfish::json_util::readJsonAction(req, asyncResp->res, "Request",
body))
{
- BMCWEB_LOG_DEBUG << "Not a Valid JSON";
+ BMCWEB_LOG_DEBUG("Not a Valid JSON");
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
@@ -779,8 +779,7 @@ inline void requestRoutes(App& app)
}
else
{
- BMCWEB_LOG_DEBUG << " Value of Type : " << type
- << "is Not a Valid key";
+ BMCWEB_LOG_DEBUG(" Value of Type : {}is Not a Valid key", type);
redfish::messages::propertyValueNotInList(asyncResp->res, type,
"Type");
}
diff --git a/include/ibm/utils.hpp b/include/ibm/utils.hpp
index bb439ee423..31f0a2e802 100644
--- a/include/ibm/utils.hpp
+++ b/include/ibm/utils.hpp
@@ -15,26 +15,26 @@ inline bool createDirectory(std::string_view path)
// Create persistent directory
std::error_code ec;
- BMCWEB_LOG_DEBUG << "Creating persistent directory : " << path;
+ BMCWEB_LOG_DEBUG("Creating persistent directory : {}", path);
bool dirCreated = std::filesystem::create_directories(path, ec);
if (ec)
{
- BMCWEB_LOG_ERROR << "Failed to create persistent directory : " << path;
+ BMCWEB_LOG_ERROR("Failed to create persistent directory : {}", path);
return false;
}
if (dirCreated)
{
// set the permission of the directory to 700
- BMCWEB_LOG_DEBUG << "Setting the permission to 700";
+ BMCWEB_LOG_DEBUG("Setting the permission to 700");
std::filesystem::perms permission = std::filesystem::perms::owner_all;
std::filesystem::permissions(path, permission);
}
else
{
- BMCWEB_LOG_DEBUG << path << " already exists";
+ BMCWEB_LOG_DEBUG("{} already exists", path);
}
return true;
}
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index cdd7dd47d2..521ff659f6 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -43,11 +43,11 @@ inline void
// expected, we were canceled before the timer completed.
return;
}
- BMCWEB_LOG_ERROR << "Timed out waiting for Version interface";
+ BMCWEB_LOG_ERROR("Timed out waiting for Version interface");
if (ec)
{
- BMCWEB_LOG_ERROR << "Async_wait failed " << ec;
+ BMCWEB_LOG_ERROR("Async_wait failed {}", ec);
return;
}
@@ -60,7 +60,7 @@ inline void
std::function<void(sdbusplus::message_t&)> callback =
[asyncResp](sdbusplus::message_t& m) {
- BMCWEB_LOG_DEBUG << "Match fired";
+ BMCWEB_LOG_DEBUG("Match fired");
sdbusplus::message::object_path path;
dbus::utility::DBusInteracesMap interfaces;
@@ -81,7 +81,7 @@ inline void
asyncResp->res.jsonValue["data"] = leaf;
asyncResp->res.jsonValue["message"] = "200 OK";
asyncResp->res.jsonValue["status"] = "ok";
- BMCWEB_LOG_DEBUG << "ending response";
+ BMCWEB_LOG_DEBUG("ending response");
fwUpdateMatcher = nullptr;
}
};
@@ -92,7 +92,7 @@ inline void
callback);
std::string filepath("/tmp/images/" + bmcweb::getRandomUUID());
- BMCWEB_LOG_DEBUG << "Writing file to " << filepath;
+ BMCWEB_LOG_DEBUG("Writing file to {}", filepath);
std::ofstream out(filepath, std::ofstream::out | std::ofstream::binary |
std::ofstream::trunc);
out << req.body();
diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp
index 8ea3434832..e3131bb3c2 100644
--- a/include/kvm_websocket.hpp
+++ b/include/kvm_websocket.hpp
@@ -26,9 +26,9 @@ class KvmSession
endpoint, [this, &connIn](const boost::system::error_code& ec) {
if (ec)
{
- BMCWEB_LOG_ERROR
- << "conn:" << &conn
- << ", Couldn't connect to KVM socket port: " << ec;
+ BMCWEB_LOG_ERROR(
+ "conn:{}, Couldn't connect to KVM socket port: {}",
+ logPtr(&conn), ec);
if (ec != boost::asio::error::operation_aborted)
{
connIn.close("Error in connecting to KVM port");
@@ -44,23 +44,22 @@ class KvmSession
{
if (data.length() > inputBuffer.capacity())
{
- BMCWEB_LOG_ERROR << "conn:" << &conn
- << ", Buffer overrun when writing "
- << data.length() << " bytes";
+ BMCWEB_LOG_ERROR("conn:{}, Buffer overrun when writing {} bytes",
+ logPtr(&conn), data.length());
conn.close("Buffer overrun");
return;
}
- BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Read " << data.size()
- << " bytes from websocket";
+ BMCWEB_LOG_DEBUG("conn:{}, Read {} bytes from websocket", logPtr(&conn),
+ data.size());
boost::asio::buffer_copy(inputBuffer.prepare(data.size()),
boost::asio::buffer(data));
- BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Committing " << data.size()
- << " bytes from websocket";
+ BMCWEB_LOG_DEBUG("conn:{}, Committing {} bytes from websocket",
+ logPtr(&conn), data.size());
inputBuffer.commit(data.size());
- BMCWEB_LOG_DEBUG << "conn:" << &conn << ", inputbuffer size "
- << inputBuffer.size();
+ BMCWEB_LOG_DEBUG("conn:{}, inputbuffer size {}", logPtr(&conn),
+ inputBuffer.size());
doWrite();
}
@@ -68,18 +67,18 @@ class KvmSession
void doRead()
{
std::size_t bytes = outputBuffer.capacity() - outputBuffer.size();
- BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Reading " << bytes
- << " from kvm socket";
+ BMCWEB_LOG_DEBUG("conn:{}, Reading {} from kvm socket", logPtr(&conn),
+ bytes);
hostSocket.async_read_some(
outputBuffer.prepare(outputBuffer.capacity() - outputBuffer.size()),
[this](const boost::system::error_code& ec, std::size_t bytesRead) {
- BMCWEB_LOG_DEBUG << "conn:" << &conn << ", read done. Read "
- << bytesRead << " bytes";
+ BMCWEB_LOG_DEBUG("conn:{}, read done. Read {} bytes",
+ logPtr(&conn), bytesRead);
if (ec)
{
- BMCWEB_LOG_ERROR
- << "conn:" << &conn
- << ", Couldn't read from KVM socket port: " << ec;
+ BMCWEB_LOG_ERROR(
+ "conn:{}, Couldn't read from KVM socket port: {}",
+ logPtr(&conn), ec);
if (ec != boost::asio::error::operation_aborted)
{
conn.close("Error in connecting to KVM port");
@@ -91,8 +90,8 @@ class KvmSession
std::string_view payload(
static_cast<const char*>(outputBuffer.data().data()),
bytesRead);
- BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Sending payload size "
- << payload.size();
+ BMCWEB_LOG_DEBUG("conn:{}, Sending payload size {}", logPtr(&conn),
+ payload.size());
conn.sendBinary(payload);
outputBuffer.consume(bytesRead);
@@ -104,14 +103,14 @@ class KvmSession
{
if (doingWrite)
{
- BMCWEB_LOG_DEBUG << "conn:" << &conn
- << ", Already writing. Bailing out";
+ BMCWEB_LOG_DEBUG("conn:{}, Already writing. Bailing out",
+ logPtr(&conn));
return;
}
if (inputBuffer.size() == 0)
{
- BMCWEB_LOG_DEBUG << "conn:" << &conn
- << ", inputBuffer empty. Bailing out";
+ BMCWEB_LOG_DEBUG("conn:{}, inputBuffer empty. Bailing out",
+ logPtr(&conn));
return;
}
@@ -119,8 +118,8 @@ class KvmSession
hostSocket.async_write_some(inputBuffer.data(),
[this](const boost::system::error_code& ec,
std::size_t bytesWritten) {
- BMCWEB_LOG_DEBUG << "conn:" << &conn << ", Wrote " << bytesWritten
- << "bytes";
+ BMCWEB_LOG_DEBUG("conn:{}, Wrote {}bytes", logPtr(&conn),
+ bytesWritten);
doingWrite = false;
inputBuffer.consume(bytesWritten);
@@ -131,8 +130,8 @@ class KvmSession
}
if (ec)
{
- BMCWEB_LOG_ERROR << "conn:" << &conn
- << ", Error in KVM socket write " << ec;
+ BMCWEB_LOG_ERROR("conn:{}, Error in KVM socket write {}",
+ logPtr(&conn), ec);
if (ec != boost::asio::error::operation_aborted)
{
conn.close("Error in reading to host port");
@@ -164,7 +163,7 @@ inline void requestRoutes(App& app)
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
.onopen([](crow::websocket::Connection& conn) {
- BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
+ BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn));
if (sessions.size() == maxSessions)
{
diff --git a/include/login_routes.hpp b/include/login_routes.hpp
index 482b613ecf..2ed9951af2 100644
--- a/include/login_routes.hpp
+++ b/include/login_routes.hpp
@@ -41,7 +41,7 @@ inline void requestRoutes(App& app)
false);
if (loginCredentials.is_discarded())
{
- BMCWEB_LOG_DEBUG << "Bad json in request";
+ BMCWEB_LOG_DEBUG("Bad json in request");
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
@@ -125,8 +125,8 @@ inline void requestRoutes(App& app)
if (ec != ParserError::PARSER_SUCCESS)
{
// handle error
- BMCWEB_LOG_ERROR << "MIME parse failed, ec : "
- << static_cast<int>(ec);
+ BMCWEB_LOG_ERROR("MIME parse failed, ec : {}",
+ static_cast<int>(ec));
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
}
@@ -137,13 +137,13 @@ inline void requestRoutes(App& app)
formpart.fields.find("Content-Disposition");
if (it == formpart.fields.end())
{
- BMCWEB_LOG_ERROR << "Couldn't find Content-Disposition";
+ BMCWEB_LOG_ERROR("Couldn't find Content-Disposition");
asyncResp->res.result(
boost::beast::http::status::bad_request);
continue;
}
- BMCWEB_LOG_INFO << "Parsing value " << it->value();
+ BMCWEB_LOG_INFO("Parsing value {}", it->value());
if (it->value() == "form-data; name=\"username\"")
{
@@ -155,8 +155,7 @@ inline void requestRoutes(App& app)
}
else
{
- BMCWEB_LOG_INFO << "Extra format, ignore it."
- << it->value();
+ BMCWEB_LOG_INFO("Extra format, ignore it.{}", it->value());
}
}
}
@@ -214,7 +213,7 @@ inline void requestRoutes(App& app)
}
else
{
- BMCWEB_LOG_DEBUG << "Couldn't interpret password";
+ BMCWEB_LOG_DEBUG("Couldn't interpret password");
asyncResp->res.result(boost::beast::http::status::bad_request);
}
});
diff --git a/include/nbd_proxy.hpp b/include/nbd_proxy.hpp
index 62bd324363..5de3039765 100644
--- a/include/nbd_proxy.hpp
+++ b/include/nbd_proxy.hpp
@@ -57,13 +57,13 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
~NbdProxyServer()
{
- BMCWEB_LOG_DEBUG << "NbdProxyServer destructor";
+ BMCWEB_LOG_DEBUG("NbdProxyServer destructor");
- BMCWEB_LOG_DEBUG << "peerSocket->close()";
+ BMCWEB_LOG_DEBUG("peerSocket->close()");
boost::system::error_code ec;
peerSocket.close(ec);
- BMCWEB_LOG_DEBUG << "std::remove(" << socketId << ")";
+ BMCWEB_LOG_DEBUG("std::remove({})", socketId);
std::remove(socketId.c_str());
crow::connections::systemBus->async_method_call(
@@ -83,12 +83,12 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
stream_protocol::socket socket) {
if (ec)
{
- BMCWEB_LOG_ERROR << "UNIX socket: async_accept error = "
- << ec.message();
+ BMCWEB_LOG_ERROR("UNIX socket: async_accept error = {}",
+ ec.message());
return;
}
- BMCWEB_LOG_DEBUG << "Connection opened";
+ BMCWEB_LOG_DEBUG("Connection opened");
std::shared_ptr<NbdProxyServer> self = weak.lock();
if (self == nullptr)
{
@@ -110,8 +110,8 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
}
if (ec)
{
- BMCWEB_LOG_ERROR << "DBus error: cannot call mount method = "
- << ec.message();
+ BMCWEB_LOG_ERROR("DBus error: cannot call mount method = {}",
+ ec.message());
self->connection.close("Failed to mount media");
return;
@@ -142,8 +142,8 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
size_t bytesRead) {
if (ec)
{
- BMCWEB_LOG_ERROR << "UNIX socket: async_read_some error = "
- << ec.message();
+ BMCWEB_LOG_ERROR("UNIX socket: async_read_some error = {}",
+ ec.message());
return;
}
std::shared_ptr<NbdProxyServer> self = weak.lock();
@@ -172,13 +172,13 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
{
if (uxWriteInProgress)
{
- BMCWEB_LOG_ERROR << "Write in progress";
+ BMCWEB_LOG_ERROR("Write in progress");
return;
}
if (ws2uxBuf.size() == 0)
{
- BMCWEB_LOG_ERROR << "No data to write to UNIX socket";
+ BMCWEB_LOG_ERROR("No data to write to UNIX socket");
return;
}
@@ -199,8 +199,7 @@ struct NbdProxyServer : std::enable_shared_from_this<NbdProxyServer>
if (ec)
{
- BMCWEB_LOG_ERROR << "UNIX: async_write error = "
- << ec.message();
+ BMCWEB_LOG_ERROR("UNIX: async_write error = {}", ec.message());
self->connection.close("Internal error");
return;
}
@@ -253,7 +252,7 @@ inline void
if (ec)
{
- BMCWEB_LOG_ERROR << "DBus error: " << ec.message();
+ BMCWEB_LOG_ERROR("DBus error: {}", ec.message());
conn.close("Failed to create mount point");
return;
}
@@ -275,7 +274,7 @@ inline void
if (endpointValue == nullptr)
{
- BMCWEB_LOG_ERROR << "EndpointId property value is null";
+ BMCWEB_LOG_ERROR("EndpointId property value is null");
}
}
if (name == "Socket")
@@ -283,7 +282,7 @@ inline void
socketValue = std::get_if<std::string>(&value);
if (socketValue == nullptr)
{
- BMCWEB_LOG_ERROR << "Socket property value is null";
+ BMCWEB_LOG_ERROR("Socket property value is null");
}
}
}
@@ -299,7 +298,7 @@ inline void
if (objects.empty() || endpointObjectPath == nullptr)
{
- BMCWEB_LOG_ERROR << "Cannot find requested EndpointId";
+ BMCWEB_LOG_ERROR("Cannot find requested EndpointId");
conn.close("Failed to match EndpointId");
return;
}
@@ -308,7 +307,7 @@ inline void
{
if (session.second->getEndpointId() == conn.req.target())
{
- BMCWEB_LOG_ERROR << "Cannot open new connection - socket is in use";
+ BMCWEB_LOG_ERROR("Cannot open new connection - socket is in use");
conn.close("Slot is in use");
return;
}
@@ -325,7 +324,7 @@ inline void
};
inline void onOpen(crow::websocket::Connection& conn)
{
- BMCWEB_LOG_DEBUG << "nbd-proxy.onopen(" << &conn << ")";
+ BMCWEB_LOG_DEBUG("nbd-proxy.onopen({})", logPtr(&conn));
sdbusplus::message::object_path path("/xyz/openbmc_project/VirtualMedia");
dbus::utility::getManagedObjects(
@@ -344,11 +343,11 @@ inline void onOpen(crow::websocket::Connection& conn)
inline void onClose(crow::websocket::Connection& conn,
const std::string& reason)
{
- BMCWEB_LOG_DEBUG << "nbd-proxy.onclose(reason = '" << reason << "')";
+ BMCWEB_LOG_DEBUG("nbd-proxy.onclose(reason = '{}')", reason);
auto session = sessions.find(&conn);
if (session == sessions.end())
{
- BMCWEB_LOG_DEBUG << "No session to close";
+ BMCWEB_LOG_DEBUG("No session to close");
return;
}
// Remove reference to session in global map
@@ -359,7 +358,7 @@ inline void onMessage(crow::websocket::Connection& conn, std::string_view data,
crow::websocket::MessageType /*type*/,
std::function<void()>&& whenComplete)
{
- BMCWEB_LOG_DEBUG << "nbd-proxy.onMessage(len = " << data.size() << ")";
+ BMCWEB_LOG_DEBUG("nbd-proxy.onMessage(len = {})", data.size());
// Acquire proxy from sessions
auto session = sessions.find(&conn);
diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index f9b978d1f5..2dd3edbf51 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -36,13 +36,13 @@ class ConsoleHandler : public std::enable_shared_from_this<ConsoleHandler>
{
if (doingWrite)
{
- BMCWEB_LOG_DEBUG << "Already writing. Bailing out";
+ BMCWEB_LOG_DEBUG("Already writing. Bailing out");
return;
}
if (inputBuffer.empty())
{
- BMCWEB_LOG_DEBUG << "Outbuffer empty. Bailing out";
+ BMCWEB_LOG_DEBUG("Outbuffer empty. Bailing out");
return;
}
@@ -67,8 +67,7 @@ class ConsoleHandler : public std::enable_shared_from_this<ConsoleHandler>
}
if (ec)
{
- BMCWEB_LOG_ERROR << "Error in host serial write "
- << ec.message();
+ BMCWEB_LOG_ERROR("Error in host serial write {}", ec.message());
return;
}
self->doWrite();
@@ -87,12 +86,12 @@ class ConsoleHandler : public std::enable_shared_from_this<ConsoleHandler>
void doRead()
{
- BMCWEB_LOG_DEBUG << "Reading from socket";
+ BMCWEB_LOG_DEBUG("Reading from socket");
hostSocket.async_read_some(
boost::asio::buffer(outputBuffer),
[this, weakSelf(weak_from_this())](
const boost::system::error_code& ec, std::size_t bytesRead) {
- BMCWEB_LOG_DEBUG << "read done. Read " << bytesRead << " bytes";
+ BMCWEB_LOG_DEBUG("read done. Read {} bytes", bytesRead);
std::shared_ptr<ConsoleHandler> self = weakSelf.lock();
if (self == nullptr)
{
@@ -100,8 +99,8 @@ class ConsoleHandler : public std::enable_shared_from_this<ConsoleHandler>
}
if (ec)
{
- BMCWEB_LOG_ERROR << "Couldn't read from host serial port: "
- << ec.message();
+ BMCWEB_LOG_ERROR("Couldn't read from host serial port: {}",
+ ec.message());
conn.close("Error connecting to host port");
return;
}
@@ -120,8 +119,9 @@ class ConsoleHandler : public std::enable_shared_from_this<ConsoleHandler>
if (ec)
{
- BMCWEB_LOG_ERROR << "Failed to assign the DBUS socket"
- << " Socket assign error: " << ec.message();
+ BMCWEB_LOG_ERROR(
+ "Failed to assign the DBUS socket Socket assign error: {}",
+ ec.message());
return false;
}
@@ -155,15 +155,15 @@ inline ObmcConsoleMap& getConsoleHandlerMap()
// then remove the handler from handlers map.
inline void onClose(crow::websocket::Connection& conn, const std::string& err)
{
- BMCWEB_LOG_INFO << "Closing websocket. Reason: " << err;
+ BMCWEB_LOG_INFO("Closing websocket. Reason: {}", err);
auto iter = getConsoleHandlerMap().find(&conn);
if (iter == getConsoleHandlerMap().end())
{
- BMCWEB_LOG_CRITICAL << "Unable to find connection " << &conn;
+ BMCWEB_LOG_CRITICAL("Unable to find connection {}", logPtr(&conn));
return;
}
- BMCWEB_LOG_DEBUG << "Remove connection " << &conn << " from obmc console";
+ BMCWEB_LOG_DEBUG("Remove connection {} from obmc console", logPtr(&conn));
// Removed last connection so remove the path
getConsoleHandlerMap().erase(iter);
@@ -175,8 +175,9 @@ inline void connectConsoleSocket(crow::websocket::Connection& conn,
{
if (ec)
{
- BMCWEB_LOG_ERROR << "Failed to call console Connect() method"
- << " DBUS error: " << ec.message();
+ BMCWEB_LOG_ERROR(
+ "Failed to call console Connect() method DBUS error: {}",
+ ec.message());
conn.close("Failed to connect");
return;
}
@@ -185,20 +186,20 @@ inline void connectConsoleSocket(crow::websocket::Connection& conn,
auto iter = getConsoleHandlerMap().find(&conn);
if (iter == getConsoleHandlerMap().end())
{
- BMCWEB_LOG_ERROR << "Connection was already closed";
+ BMCWEB_LOG_ERROR("Connection was already closed");
return;
}
int fd = dup(unixfd);
if (fd == -1)
{
- BMCWEB_LOG_ERROR << "Failed to dup the DBUS unixfd"
- << " error: " << strerror(errno);
+ BMCWEB_LOG_ERROR("Failed to dup the DBUS unixfd error: {}",
+ strerror(errno));
conn.close("Internal error");
return;
}
- BMCWEB_LOG_DEBUG << "Console unix FD: " << unixfd << " duped FD: " << fd;
+ BMCWEB_LOG_DEBUG("Console duped FD: {}", fd);
if (!iter->second->connect(fd))
{
@@ -217,14 +218,14 @@ inline void
auto iter = getConsoleHandlerMap().find(&conn);
if (iter == getConsoleHandlerMap().end())
{
- BMCWEB_LOG_ERROR << "Connection was already closed";
+ BMCWEB_LOG_ERROR("Connection was already closed");
return;
}
if (ec)
{
- BMCWEB_LOG_WARNING << "getDbusObject() for consoles failed. DBUS error:"
- << ec.message();
+ BMCWEB_LOG_WARNING("getDbusObject() for consoles failed. DBUS error:{}",
+ ec.message());
conn.close("getDbusObject() for consoles failed.");
return;
}
@@ -232,15 +233,15 @@ inline void
const auto valueIface = objInfo.begin();
if (valueIface == objInfo.end())
{
- BMCWEB_LOG_WARNING << "getDbusObject() returned unexpected size: "
- << objInfo.size();
+ BMCWEB_LOG_WARNING("getDbusObject() returned unexpected size: {}",
+ objInfo.size());
conn.close("getDbusObject() returned unexpected size");
return;
}
const std::string& consoleService = valueIface->first;
- BMCWEB_LOG_DEBUG << "Looking up unixFD for Service " << consoleService
- << " Path " << consoleObjPath;
+ BMCWEB_LOG_DEBUG("Looking up unixFD for Service {} Path {}", consoleService,
+ consoleObjPath);
// Call Connect() method to get the unix FD
crow::connections::systemBus->async_method_call(
[&conn](const boost::system::error_code& ec1,
@@ -257,7 +258,7 @@ inline void onOpen(crow::websocket::Connection& conn)
{
std::string consoleLeaf;
- BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
+ BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn));
if (getConsoleHandlerMap().size() >= maxSessions)
{
@@ -286,8 +287,8 @@ inline void onOpen(crow::websocket::Connection& conn)
sdbusplus::message::object_path("/xyz/openbmc_project/console") /
consoleLeaf;
- BMCWEB_LOG_DEBUG << "Console Object path = " << consolePath
- << " Request target = " << conn.url().path();
+ BMCWEB_LOG_DEBUG("Console Object path = {} Request target = {}",
+ consolePath, conn.url().path());
// mapper call lambda
constexpr std::array<std::string_view, 1> interfaces = {
@@ -307,7 +308,7 @@ inline void onMessage(crow::websocket::Connection& conn,
auto handler = getConsoleHandlerMap().find(&conn);
if (handler == getConsoleHandlerMap().end())
{
- BMCWEB_LOG_CRITICAL << "Unable to find connection " << &conn;
+ BMCWEB_LOG_CRITICAL("Unable to find connection {}", logPtr(&conn));
return;
}
handler->second->inputBuffer += data;
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 480736124d..6211fccfa2 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -135,10 +135,9 @@ inline void
const std::string& introspectXml) {
if (ec)
{
- BMCWEB_LOG_ERROR
- << "Introspect call failed with error: " << ec.message()
- << " on process: " << processName << " path: " << objectPath
- << "\n";
+ BMCWEB_LOG_ERROR(
+ "Introspect call failed with error: {} on process: {} path: {}",
+ ec.message(), processName, objectPath);
return;
}
nlohmann::json::object_t object;
@@ -152,8 +151,8 @@ inline void
tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
- BMCWEB_LOG_ERROR << "XML document failed to parse " << processName
- << " " << objectPath << "\n";
+ BMCWEB_LOG_ERROR("XML document failed to parse {} {}", processName,
+ objectPath);
}
else
{
@@ -186,8 +185,8 @@ inline void getPropertiesForEnumerate(
const std::string& interface,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- BMCWEB_LOG_DEBUG << "getPropertiesForEnumerate " << objectPath << " "
- << service << " " << interface;
+ BMCWEB_LOG_DEBUG("getPropertiesForEnumerate {} {} {}", objectPath, service,
+ interface);
sdbusplus::asio::getAllProperties(
*crow::connections::systemBus, service, objectPath, interface,
@@ -196,9 +195,9 @@ inline void getPropertiesForEnumerate(
const dbus::utility::DBusPropertiesMap& propertiesList) {
if (ec)
{
- BMCWEB_LOG_ERROR << "GetAll on path " << objectPath << " iface "
- << interface << " service " << service
- << " failed with code " << ec;
+ BMCWEB_LOG_ERROR(
+ "GetAll on path {} iface {} service {} failed with code {}",
+ objectPath, interface, service, ec);
return;
}
@@ -236,7 +235,7 @@ inline void findRemainingObjectsForEnumerate(
const std::shared_ptr<dbus::utility::MapperGetSubTreeResponse>& subtree,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- BMCWEB_LOG_DEBUG << "findRemainingObjectsForEnumerate";
+ BMCWEB_LOG_DEBUG("findRemainingObjectsForEnumerate");
const nlohmann::json& dataJson = asyncResp->res.jsonValue["data"];
for (const auto& [path, interface_map] : *subtree)
@@ -280,8 +279,8 @@ struct InProgressEnumerateData
}
catch (...)
{
- BMCWEB_LOG_CRITICAL
- << "findRemainingObjectsForEnumerate threw exception";
+ BMCWEB_LOG_CRITICAL(
+ "findRemainingObjectsForEnumerate threw exception");
}
}
@@ -299,9 +298,9 @@ inline void getManagedObjectsForEnumerate(
const std::string& connectionName,
const std::shared_ptr<InProgressEnumerateData>& transaction)
{
- BMCWEB_LOG_DEBUG << "getManagedObjectsForEnumerate " << objectName
- << " object_manager_path " << objectManagerPath
- << " connection_name " << connectionName;
+ BMCWEB_LOG_DEBUG(
+ "getManagedObjectsForEnumerate {} object_manager_path {} connection_name {}",
+ objectName, objectManagerPath, connectionName);
sdbusplus::message::object_path path(objectManagerPath);
dbus::utility::getManagedObjects(
connectionName, path,
@@ -310,9 +309,9 @@ inline void getManagedObjectsForEnumerate(
const dbus::utility::ManagedObjectType& objects) {
if (ec)
{
- BMCWEB_LOG_ERROR << "GetManagedObjects on path " << objectName
- << " on connection " << connectionName
- << " failed with code " << ec;
+ BMCWEB_LOG_ERROR(
+ "GetManagedObjects on path {} on connection {} failed with code {}",
+ objectName, connectionName, ec);
return;
}
@@ -323,7 +322,7 @@ inline void getManagedObjectsForEnumerate(
{
if (objectPath.first.str.starts_with(objectName))
{
- BMCWEB_LOG_DEBUG << "Reading object " << objectPath.first.str;
+ BMCWEB_LOG_DEBUG("Reading object {}", objectPath.first.str);
nlohmann::json& objectJson = dataJson[objectPath.first.str];
if (objectJson.is_null())
{
@@ -369,16 +368,16 @@ inline void findObjectManagerPathForEnumerate(
const std::string& objectName, const std::string& connectionName,
const std::shared_ptr<InProgressEnumerateData>& transaction)
{
- BMCWEB_LOG_DEBUG << "Finding objectmanager for path " << objectName
- << " on connection:" << connectionName;
+ BMCWEB_LOG_DEBUG("Finding objectmanager for path {} on connection:{}",
+ objectName, connectionName);
crow::connections::systemBus->async_method_call(
[transaction, objectName, connectionName](
const boost::system::error_code& ec,
const dbus::utility::MapperGetAncestorsResponse& objects) {
if (ec)
{
- BMCWEB_LOG_ERROR << "GetAncestors on path " << objectName
- << " failed with code " << ec;
+ BMCWEB_LOG_ERROR("GetAncestors on path {} failed with code {}",
+ objectName, ec);
return;
}
@@ -414,13 +413,13 @@ inline void getObjectAndEnumerate(
const dbus::utility::MapperGetObject& objects) {
if (ec)
{
- BMCWEB_LOG_ERROR << "GetObject for path " << transaction->objectPath
- << " failed with code " << ec;
+ BMCWEB_LOG_ERROR("GetObject for path {} failed with code {}",
+ transaction->objectPath, ec);
return;
}
- BMCWEB_LOG_DEBUG << "GetObject for " << transaction->objectPath
- << " has " << objects.size() << " entries";
+ BMCWEB_LOG_DEBUG("GetObject for {} has {} entries",
+ transaction->objectPath, objects.size());
if (!objects.empty())
{
transaction->subtree->emplace_back(transaction->objectPath,
@@ -437,18 +436,18 @@ inline void getObjectAndEnumerate(
{
for (const auto& interface : connection.second)
{
- BMCWEB_LOG_DEBUG << connection.first << " has interface "
- << interface;
+ BMCWEB_LOG_DEBUG("{} has interface {}", connection.first,
+ interface);
if (interface == "org.freedesktop.DBus.ObjectManager")
{
- BMCWEB_LOG_DEBUG << "found object manager path "
- << object.first;
+ BMCWEB_LOG_DEBUG("found object manager path {}",
+ object.first);
connections[connection.first] = object.first;
}
}
}
}
- BMCWEB_LOG_DEBUG << "Got " << connections.size() << " connections";
+ BMCWEB_LOG_DEBUG("Got {} connections", connections.size());
for (const auto& connection : connections)
{
@@ -596,10 +595,10 @@ inline int convertJsonToDbus(sd_bus_message* m, const std::string& argType,
const nlohmann::json& inputJson)
{
int r = 0;
- BMCWEB_LOG_DEBUG << "Converting "
- << inputJson.dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace)
- << " to type: " << argType;
+ BMCWEB_LOG_DEBUG(
+ "Converting {} to type: {}",
+ inputJson.dump(2, ' ', true, nlohmann::json::error_handler_t::replace),
+ argType);
const std::vector<std::string> argTypes = dbusArgSplit(argType);
// Assume a single object for now.
@@ -840,8 +839,8 @@ inline int convertJsonToDbus(sd_bus_message* m, const std::string& argType,
else if (argCode.starts_with("v"))
{
std::string containedType = argCode.substr(1);
- BMCWEB_LOG_DEBUG << "variant type: " << argCode
- << " appending variant of type: " << containedType;
+ BMCWEB_LOG_DEBUG("variant type: {} appending variant of type: {}",
+ argCode, containedType);
r = sd_bus_message_open_container(m, SD_BUS_TYPE_VARIANT,
containedType.c_str());
if (r < 0)
@@ -947,8 +946,8 @@ int readMessageItem(const std::string& typeCode, sdbusplus::message_t& m,
int r = sd_bus_message_read_basic(m.get(), typeCode.front(), &value);
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_read_basic on type " << typeCode
- << " failed!";
+ BMCWEB_LOG_ERROR("sd_bus_message_read_basic on type {} failed!",
+ typeCode);
return r;
}
@@ -966,8 +965,8 @@ inline int readDictEntryFromMessage(const std::string& typeCode,
std::vector<std::string> types = dbusArgSplit(typeCode);
if (types.size() != 2)
{
- BMCWEB_LOG_ERROR << "wrong number contained types in dictionary: "
- << types.size();
+ BMCWEB_LOG_ERROR("wrong number contained types in dictionary: {}",
+ types.size());
return -1;
}
@@ -975,7 +974,7 @@ inline int readDictEntryFromMessage(const std::string& typeCode,
typeCode.c_str());
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_enter_container with rc " << r;
+ BMCWEB_LOG_ERROR("sd_bus_message_enter_container with rc {}", r);
return r;
}
@@ -1011,7 +1010,7 @@ inline int readDictEntryFromMessage(const std::string& typeCode,
r = sd_bus_message_exit_container(m.get());
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_exit_container failed";
+ BMCWEB_LOG_ERROR("sd_bus_message_exit_container failed");
return r;
}
@@ -1023,8 +1022,7 @@ inline int readArrayFromMessage(const std::string& typeCode,
{
if (typeCode.size() < 2)
{
- BMCWEB_LOG_ERROR << "Type code " << typeCode
- << " too small for an array";
+ BMCWEB_LOG_ERROR("Type code {} too small for an array", typeCode);
return -1;
}
@@ -1034,8 +1032,7 @@ inline int readArrayFromMessage(const std::string& typeCode,
containedType.c_str());
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_enter_container failed with rc "
- << r;
+ BMCWEB_LOG_ERROR("sd_bus_message_enter_container failed with rc {}", r);
return r;
}
@@ -1057,7 +1054,7 @@ inline int readArrayFromMessage(const std::string& typeCode,
r = sd_bus_message_at_end(m.get(), 0);
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_at_end failed";
+ BMCWEB_LOG_ERROR("sd_bus_message_at_end failed");
return r;
}
@@ -1090,7 +1087,7 @@ inline int readArrayFromMessage(const std::string& typeCode,
r = sd_bus_message_exit_container(m.get());
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_exit_container failed";
+ BMCWEB_LOG_ERROR("sd_bus_message_exit_container failed");
return r;
}
@@ -1102,8 +1099,7 @@ inline int readStructFromMessage(const std::string& typeCode,
{
if (typeCode.size() < 3)
{
- BMCWEB_LOG_ERROR << "Type code " << typeCode
- << " too small for a struct";
+ BMCWEB_LOG_ERROR("Type code {} too small for a struct", typeCode);
return -1;
}
@@ -1114,8 +1110,7 @@ inline int readStructFromMessage(const std::string& typeCode,
containedTypes.c_str());
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_enter_container failed with rc "
- << r;
+ BMCWEB_LOG_ERROR("sd_bus_message_enter_container failed with rc {}", r);
return r;
}
@@ -1132,7 +1127,7 @@ inline int readStructFromMessage(const std::string& typeCode,
r = sd_bus_message_exit_container(m.get());
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_exit_container failed";
+ BMCWEB_LOG_ERROR("sd_bus_message_exit_container failed");
return r;
}
return 0;
@@ -1144,7 +1139,7 @@ inline int readVariantFromMessage(sdbusplus::message_t& m, nlohmann::json& data)
int r = sd_bus_message_peek_type(m.get(), nullptr, &containerType);
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_peek_type failed";
+ BMCWEB_LOG_ERROR("sd_bus_message_peek_type failed");
return r;
}
@@ -1152,8 +1147,7 @@ inline int readVariantFromMessage(sdbusplus::message_t& m, nlohmann::json& data)
containerType);
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_enter_container failed with rc "
- << r;
+ BMCWEB_LOG_ERROR("sd_bus_message_enter_container failed with rc {}", r);
return r;
}
@@ -1166,7 +1160,7 @@ inline int readVariantFromMessage(sdbusplus::message_t& m, nlohmann::json& data)
r = sd_bus_message_exit_container(m.get());
if (r < 0)
{
- BMCWEB_LOG_ERROR << "sd_bus_message_enter_container failed";
+ BMCWEB_LOG_ERROR("sd_bus_message_enter_container failed");
return r;
}
@@ -1304,7 +1298,7 @@ inline int convertDBusToJSON(const std::string& returnType,
}
else
{
- BMCWEB_LOG_ERROR << "Invalid D-Bus signature type " << typeCode;
+ BMCWEB_LOG_ERROR("Invalid D-Bus signature type {}", typeCode);
return -2;
}
}
@@ -1380,18 +1374,17 @@ inline void findActionOnInterface(
const std::shared_ptr<InProgressActionData>& transaction,
const std::string& connectionName)
{
- BMCWEB_LOG_DEBUG << "findActionOnInterface for connection "
- << connectionName;
+ BMCWEB_LOG_DEBUG("findActionOnInterface for connection {}", connectionName);
crow::connections::systemBus->async_method_call(
[transaction, connectionName{std::string(connectionName)}](
const boost::system::error_code& ec,
const std::string& introspectXml) {
- BMCWEB_LOG_DEBUG << "got xml:\n " << introspectXml;
+ BMCWEB_LOG_DEBUG("got xml:\n {}", introspectXml);
if (ec)
{
- BMCWEB_LOG_ERROR
- << "Introspect call failed with error: " << ec.message()
- << " on process: " << connectionName << "\n";
+ BMCWEB_LOG_ERROR(
+ "Introspect call failed with error: {} on process: {}",
+ ec.message(), connectionName);
return;
}
tinyxml2::XMLDocument doc;
@@ -1400,8 +1393,7 @@ inline void findActionOnInterface(
tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
- BMCWEB_LOG_ERROR << "XML document failed to parse "
- << connectionName << "\n";
+ BMCWEB_LOG_ERROR("XML document failed to parse {}", connectionName);
return;
}
tinyxml2::XMLElement* interfaceNode =
@@ -1424,13 +1416,13 @@ inline void findActionOnInterface(
while (methodNode != nullptr)
{
const char* thisMethodName = methodNode->Attribute("name");
- BMCWEB_LOG_DEBUG << "Found method: " << thisMethodName;
+ BMCWEB_LOG_DEBUG("Found method: {}", thisMethodName);
if (thisMethodName != nullptr &&
thisMethodName == transaction->methodName)
{
- BMCWEB_LOG_DEBUG << "Found method named "
- << thisMethodName << " on interface "
- << thisInterfaceName;
+ BMCWEB_LOG_DEBUG(
+ "Found method named {} on interface {}",
+ thisMethodName, thisInterfaceName);
sdbusplus::message_t m =
crow::connections::systemBus->new_method_call(
connectionName.c_str(),
@@ -1540,8 +1532,8 @@ inline void handleAction(const crow::Request& req,
const std::string& objectPath,
const std::string& methodName)
{
- BMCWEB_LOG_DEBUG << "handleAction on path: " << objectPath << " and method "
- << methodName;
+ BMCWEB_LOG_DEBUG("handleAction on path: {} and method {}", objectPath,
+ methodName);
nlohmann::json requestDbusData;
JsonParseResult ret = parseRequestAsJson(req, requestDbusData);
@@ -1588,15 +1580,15 @@ inline void handleAction(const crow::Request& req,
interfaceNames) {
if (ec || interfaceNames.empty())
{
- BMCWEB_LOG_ERROR << "Can't find object";
+ BMCWEB_LOG_ERROR("Can't find object");
setErrorResponse(transaction->asyncResp->res,
boost::beast::http::status::not_found,
notFoundDesc, notFoundMsg);
return;
}
- BMCWEB_LOG_DEBUG << "GetObject returned " << interfaceNames.size()
- << " object(s)";
+ BMCWEB_LOG_DEBUG("GetObject returned {} object(s)",
+ interfaceNames.size());
for (const std::pair<std::string, std::vector<std::string>>& object :
interfaceNames)
@@ -1609,7 +1601,7 @@ inline void handleAction(const crow::Request& req,
inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& objectPath)
{
- BMCWEB_LOG_DEBUG << "handleDelete on path: " << objectPath;
+ BMCWEB_LOG_DEBUG("handleDelete on path: {}", objectPath);
dbus::utility::getDbusObject(
objectPath, {},
@@ -1619,7 +1611,7 @@ inline void handleDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
interfaceNames) {
if (ec || interfaceNames.empty())
{
- BMCWEB_LOG_ERROR << "Can't find object";
+ BMCWEB_LOG_ERROR("Can't find object");
setErrorResponse(asyncResp->res,
boost::beast::http::status::method_not_allowed,
methodNotAllowedDesc, methodNotAllowedMsg);
@@ -1665,7 +1657,7 @@ inline void handleList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& objectPath)
{
- BMCWEB_LOG_DEBUG << "Doing enumerate on " << objectPath;
+ BMCWEB_LOG_DEBUG("Doing enumerate on {}", objectPath);
asyncResp->res.jsonValue["message"] = "200 OK";
asyncResp->res.jsonValue["status"] = "ok";
@@ -1685,8 +1677,8 @@ inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
if (ec)
{
- BMCWEB_LOG_ERROR << "GetSubTree failed on "
- << transaction->objectPath;
+ BMCWEB_LOG_ERROR("GetSubTree failed on {}",
+ transaction->objectPath);
setErrorResponse(transaction->asyncResp->res,
boost::beast::http::status::not_found,
notFoundDesc, notFoundMsg);
@@ -1702,7 +1694,7 @@ inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
std::string& objectPath, std::string& destProperty)
{
- BMCWEB_LOG_DEBUG << "handleGet: " << objectPath << " prop:" << destProperty;
+ BMCWEB_LOG_DEBUG("handleGet: {} prop:{}", objectPath, destProperty);
std::shared_ptr<std::string> propertyName =
std::make_shared<std::string>(std::move(destProperty));
@@ -1751,8 +1743,7 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
sdbusplus::message_t& msg) {
if (ec2)
{
- BMCWEB_LOG_ERROR << "Bad dbus request error: "
- << ec2;
+ BMCWEB_LOG_ERROR("Bad dbus request error: {}", ec2);
}
else
{
@@ -1760,7 +1751,7 @@ inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
int r = convertDBusToJSON("a{sv}", msg, properties);
if (r < 0)
{
- BMCWEB_LOG_ERROR << "convertDBusToJSON failed";
+ BMCWEB_LOG_ERROR("convertDBusToJSON failed");
}
else
{
@@ -1904,9 +1895,9 @@ inline void handlePut(const crow::Request& req,
const std::string& introspectXml) {
if (ec3)
{
- BMCWEB_LOG_ERROR << "Introspect call failed with error: "
- << ec3.message()
- << " on process: " << connectionName;
+ BMCWEB_LOG_ERROR(
+ "Introspect call failed with error: {} on process: {}",
+ ec3.message(), connectionName);
transaction->setErrorStatus("Unexpected Error");
return;
}
@@ -1916,8 +1907,8 @@ inline void handlePut(const crow::Request& req,
tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
- BMCWEB_LOG_ERROR << "XML document failed to parse: "
- << introspectXml;
+ BMCWEB_LOG_ERROR("XML document failed to parse: {}",
+ introspectXml);
transaction->setErrorStatus("Unexpected Error");
return;
}
@@ -1926,13 +1917,13 @@ inline void handlePut(const crow::Request& req,
while (ifaceNode != nullptr)
{
const char* interfaceName = ifaceNode->Attribute("name");
- BMCWEB_LOG_DEBUG << "found interface " << interfaceName;
+ BMCWEB_LOG_DEBUG("found interface {}", interfaceName);
tinyxml2::XMLElement* propNode =
ifaceNode->FirstChildElement("property");
while (propNode != nullptr)
{
const char* propertyName = propNode->Attribute("name");
- BMCWEB_LOG_DEBUG << "Found property " << propertyName;
+ BMCWEB_LOG_DEBUG("Found property {}", propertyName);
if (propertyName == transaction->propertyName)
{
const char* argType = propNode->Attribute("type");
@@ -1987,7 +1978,7 @@ inline void handlePut(const crow::Request& req,
[transaction](
const boost::system::error_code& ec,
sdbusplus::message_t& m2) {
- BMCWEB_LOG_DEBUG << "sent";
+ BMCWEB_LOG_DEBUG("sent");
if (ec)
{
const sd_bus_error* e = m2.get_error();
@@ -2161,10 +2152,9 @@ inline void
const std::string& introspectXml) {
if (ec)
{
- BMCWEB_LOG_ERROR
- << "Introspect call failed with error: " << ec.message()
- << " on process: " << processName << " path: " << objectPath
- << "\n";
+ BMCWEB_LOG_ERROR(
+ "Introspect call failed with error: {} on process: {} path: {}",
+ ec.message(), processName, objectPath);
return;
}
tinyxml2::XMLDocument doc;
@@ -2173,15 +2163,15 @@ inline void
tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
- BMCWEB_LOG_ERROR << "XML document failed to parse "
- << processName << " " << objectPath << "\n";
+ BMCWEB_LOG_ERROR("XML document failed to parse {} {}",
+ processName, objectPath);
asyncResp->res.jsonValue["status"] = "XML parse error";
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return;
}
- BMCWEB_LOG_DEBUG << introspectXml;
+ BMCWEB_LOG_DEBUG("{}", introspectXml);
asyncResp->res.jsonValue["status"] = "ok";
asyncResp->res.jsonValue["bus_name"] = processName;
asyncResp->res.jsonValue["object_path"] = objectPath;
@@ -2216,10 +2206,9 @@ inline void
const std::string& introspectXml) {
if (ec)
{
- BMCWEB_LOG_ERROR
- << "Introspect call failed with error: " << ec.message()
- << " on process: " << processName << " path: " << objectPath
- << "\n";
+ BMCWEB_LOG_ERROR(
+ "Introspect call failed with error: {} on process: {} path: {}",
+ ec.message(), processName, objectPath);
return;
}
tinyxml2::XMLDocument doc;
@@ -2228,8 +2217,8 @@ inline void
tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node");
if (pRoot == nullptr)
{
- BMCWEB_LOG_ERROR << "XML document failed to parse "
- << processName << " " << objectPath << "\n";
+ BMCWEB_LOG_ERROR("XML document failed to parse {} {}",
+ processName, objectPath);
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return;
@@ -2448,7 +2437,7 @@ inline void requestRoutes(App& app)
std::vector<std::string>& names) {
if (ec)
{
- BMCWEB_LOG_ERROR << "Dbus call failed with code " << ec;
+ BMCWEB_LOG_ERROR("Dbus call failed with code {}", ec);
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
}
@@ -2538,7 +2527,7 @@ inline void requestRoutes(App& app)
if (!std::filesystem::exists(loc) ||
!std::filesystem::is_directory(loc))
{
- BMCWEB_LOG_ERROR << loc.string() << "Not found";
+ BMCWEB_LOG_ERROR("{}Not found", loc.string());
asyncResp->res.result(boost::beast::http::status::not_found);
return;
}
@@ -2565,7 +2554,7 @@ inline void requestRoutes(App& app)
static std::regex dumpFileRegex("[a-zA-Z0-9\\._]+");
if (!std::regex_match(dumpFileName, dumpFileRegex))
{
- BMCWEB_LOG_ERROR << "Invalid dump filename " << dumpFileName;
+ BMCWEB_LOG_ERROR("Invalid dump filename {}", dumpFileName);
asyncResp->res.result(boost::beast::http::status::not_found);
return;
}
diff --git a/include/persistent_data.hpp b/include/persistent_data.hpp
index a08ca7e086..5079a8c151 100644
--- a/include/persistent_data.hpp
+++ b/include/persistent_data.hpp
@@ -57,8 +57,7 @@ class ConfigFile
auto data = nlohmann::json::parse(persistentFile, nullptr, false);
if (data.is_discarded())
{
- BMCWEB_LOG_ERROR
- << "Error parsing persistent data in json file.";
+ BMCWEB_LOG_ERROR("Error parsing persistent data in json file.");
}
else
{
@@ -72,7 +71,7 @@ class ConfigFile
item.value().get_ptr<const uint64_t*>();
if (uintPtr == nullptr)
{
- BMCWEB_LOG_ERROR << "Failed to read revision flag";
+ BMCWEB_LOG_ERROR("Failed to read revision flag");
}
else
{
@@ -103,15 +102,15 @@ class ConfigFile
if (newSession == nullptr)
{
- BMCWEB_LOG_ERROR << "Problem reading session "
- "from persistent store";
+ BMCWEB_LOG_ERROR("Problem reading session "
+ "from persistent store");
continue;
}
- BMCWEB_LOG_DEBUG
- << "Restored session: " << newSession->csrfToken
- << " " << newSession->uniqueId << " "
- << newSession->sessionToken;
+ BMCWEB_LOG_DEBUG("Restored session: {} {} {}",
+ newSession->csrfToken,
+ newSession->uniqueId,
+ newSession->sessionToken);
SessionStore::getInstance().authTokens.emplace(
newSession->sessionToken, newSession);
}
@@ -122,13 +121,13 @@ class ConfigFile
item.value().get_ptr<int64_t*>();
if (jTimeout == nullptr)
{
- BMCWEB_LOG_DEBUG
- << "Problem reading session timeout value";
+ BMCWEB_LOG_DEBUG(
+ "Problem reading session timeout value");
continue;
}
std::chrono::seconds sessionTimeoutInseconds(*jTimeout);
- BMCWEB_LOG_DEBUG << "Restored Session Timeout: "
- << sessionTimeoutInseconds.count();
+ BMCWEB_LOG_DEBUG("Restored Session Timeout: {}",
+ sessionTimeoutInseconds.count());
SessionStore::getInstance().updateSessionTimeout(
sessionTimeoutInseconds);
}
@@ -147,15 +146,14 @@ class ConfigFile
if (newSubscription == nullptr)
{
- BMCWEB_LOG_ERROR
- << "Problem reading subscription "
- "from persistent store";
+ BMCWEB_LOG_ERROR("Problem reading subscription "
+ "from persistent store");
continue;
}
- BMCWEB_LOG_DEBUG << "Restored subscription: "
- << newSubscription->id << " "
- << newSubscription->customText;
+ BMCWEB_LOG_DEBUG("Restored subscription: {} {}",
+ newSubscription->id,
+ newSubscription->customText);
EventServiceStore::getInstance()
.subscriptionsConfigMap.emplace(
newSubscription->id, newSubscription);
@@ -251,8 +249,7 @@ class ConfigFile
std::shared_ptr<UserSubscription> subValue = it.second;
if (subValue->subscriptionType == "SSE")
{
- BMCWEB_LOG_DEBUG
- << "The subscription type is SSE, so skipping.";
+ BMCWEB_LOG_DEBUG("The subscription type is SSE, so skipping.");
continue;
}
nlohmann::json::object_t headers;
diff --git a/include/sessions.hpp b/include/sessions.hpp
index 9179723e5f..cb7f78e78a 100644
--- a/include/sessions.hpp
+++ b/include/sessions.hpp
@@ -72,8 +72,9 @@ struct UserSession
element.value().get_ptr<const std::string*>();
if (thisValue == nullptr)
{
- BMCWEB_LOG_ERROR << "Error reading persistent store. Property "
- << element.key() << " was not of type string";
+ BMCWEB_LOG_ERROR(
+ "Error reading persistent store. Property {} was not of type string",
+ element.key());
continue;
}
if (element.key() == "unique_id")
@@ -103,9 +104,9 @@ struct UserSession
else
{
- BMCWEB_LOG_ERROR
- << "Got unexpected property reading persistent file: "
- << element.key();
+ BMCWEB_LOG_ERROR(
+ "Got unexpected property reading persistent file: {}",
+ element.key());
continue;
}
}
@@ -116,8 +117,8 @@ struct UserSession
if (userSession->uniqueId.empty() || userSession->username.empty() ||
userSession->sessionToken.empty() || userSession->csrfToken.empty())
{
- BMCWEB_LOG_DEBUG << "Session missing required security "
- "information, refusing to restore";
+ BMCWEB_LOG_DEBUG("Session missing required security "
+ "information, refusing to restore");
return nullptr;
}
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index abc9b50d61..f8142cf24b 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "bmcweb_config.h"
+
#include "logging.hpp"
#include "ossl_random.hpp"
@@ -46,7 +48,7 @@ inline bool validateCertificate(X509* const cert)
X509_STORE* x509Store = X509_STORE_new();
if (x509Store == nullptr)
{
- BMCWEB_LOG_ERROR << "Error occurred during X509_STORE_new call";
+ BMCWEB_LOG_ERROR("Error occurred during X509_STORE_new call");
return false;
}
@@ -54,7 +56,7 @@ inline bool validateCertificate(X509* const cert)
X509_STORE_CTX* storeCtx = X509_STORE_CTX_new();
if (storeCtx == nullptr)
{
- BMCWEB_LOG_ERROR << "Error occurred during X509_STORE_CTX_new call";
+ BMCWEB_LOG_ERROR("Error occurred during X509_STORE_CTX_new call");
X509_STORE_free(x509Store);
return false;
}
@@ -62,7 +64,7 @@ inline bool validateCertificate(X509* const cert)
int errCode = X509_STORE_CTX_init(storeCtx, x509Store, cert, nullptr);
if (errCode != 1)
{
- BMCWEB_LOG_ERROR << "Error occurred during X509_STORE_CTX_init call";
+ BMCWEB_LOG_ERROR("Error occurred during X509_STORE_CTX_init call");
X509_STORE_CTX_free(storeCtx);
X509_STORE_free(x509Store);
return false;
@@ -71,7 +73,7 @@ inline bool validateCertificate(X509* const cert)
errCode = X509_verify_cert(storeCtx);
if (errCode == 1)
{
- BMCWEB_LOG_INFO << "Certificate verification is success";
+ BMCWEB_LOG_INFO("Certificate verification is success");
X509_STORE_CTX_free(storeCtx);
X509_STORE_free(x509Store);
return true;
@@ -83,18 +85,17 @@ inline bool validateCertificate(X509* const cert)
X509_STORE_free(x509Store);
if (isTrustChainError(errCode))
{
- BMCWEB_LOG_DEBUG << "Ignoring Trust Chain error. Reason: "
- << X509_verify_cert_error_string(errCode);
+ BMCWEB_LOG_DEBUG("Ignoring Trust Chain error. Reason: {}",
+ X509_verify_cert_error_string(errCode));
return true;
}
- BMCWEB_LOG_ERROR << "Certificate verification failed. Reason: "
- << X509_verify_cert_error_string(errCode);
+ BMCWEB_LOG_ERROR("Certificate verification failed. Reason: {}",
+ X509_verify_cert_error_string(errCode));
return false;
}
- BMCWEB_LOG_ERROR
- << "Error occurred during X509_verify_cert call. ErrorCode: "
- << errCode;
+ BMCWEB_LOG_ERROR(
+ "Error occurred during X509_verify_cert call. ErrorCode: {}", errCode);
X509_STORE_CTX_free(storeCtx);
X509_STORE_free(x509Store);
return false;
@@ -203,24 +204,24 @@ inline X509* loadCert(const std::string& filePath)
BIO* certFileBio = BIO_new_file(filePath.c_str(), "rb");
if (certFileBio == nullptr)
{
- BMCWEB_LOG_ERROR << "Error occured during BIO_new_file call, "
- << "FILE= " << filePath;
+ BMCWEB_LOG_ERROR("Error occured during BIO_new_file call, FILE= {}",
+ filePath);
return nullptr;
}
X509* cert = X509_new();
if (cert == nullptr)
{
- BMCWEB_LOG_ERROR << "Error occured during X509_new call, "
- << ERR_get_error();
+ BMCWEB_LOG_ERROR("Error occured during X509_new call, {}",
+ ERR_get_error());
BIO_free(certFileBio);
return nullptr;
}
if (PEM_read_bio_X509(certFileBio, &cert, nullptr, nullptr) == nullptr)
{
- BMCWEB_LOG_ERROR << "Error occured during PEM_read_bio_X509 call, "
- << "FILE= " << filePath;
+ BMCWEB_LOG_ERROR(
+ "Error occured during PEM_read_bio_X509 call, FILE= {}", filePath);
BIO_free(certFileBio);
X509_free(cert);
@@ -240,7 +241,7 @@ inline int addExt(X509* cert, int nid, const char* value)
ex = X509V3_EXT_conf_nid(nullptr, &ctx, nid, const_cast<char*>(value));
if (ex == nullptr)
{
- BMCWEB_LOG_ERROR << "Error: In X509V3_EXT_conf_nidn: " << value;
+ BMCWEB_LOG_ERROR("Error: In X509V3_EXT_conf_nidn: {}", value);
return -1;
}
X509_add_ext(cert, ex, -1);
@@ -476,7 +477,7 @@ inline std::shared_ptr<boost::asio::ssl::context>
SSL_CTX_set_options(mSslContext->native_handle(), SSL_OP_NO_RENEGOTIATION);
- BMCWEB_LOG_DEBUG << "Using default TrustStore location: " << trustStorePath;
+ BMCWEB_LOG_DEBUG("Using default TrustStore location: {}", trustStorePath);
mSslContext->add_verify_path(trustStorePath);
mSslContext->use_certificate_file(sslPemFile,
@@ -497,9 +498,7 @@ inline std::shared_ptr<boost::asio::ssl::context>
// drop, use the right way
// http://stackoverflow.com/questions/18929049/boost-asio-with-ecdsa-certificate-issue
if (SSL_CTX_set_ecdh_auto(mSslContext->native_handle(), 1) != 1)
- {
- BMCWEB_LOG_ERROR << "Error setting tmp ecdh list\n";
- }
+ {}
// Mozilla intermediate cipher suites v5.7
// Sourced from: https://ssl-config.mozilla.org/guidelines/5.7.json
@@ -516,7 +515,7 @@ inline std::shared_ptr<boost::asio::ssl::context>
if (SSL_CTX_set_cipher_list(mSslContext->native_handle(),
mozillaIntermediate) != 1)
{
- BMCWEB_LOG_ERROR << "Error setting cipher list\n";
+ BMCWEB_LOG_ERROR("Error setting cipher list");
}
return mSslContext;
}
@@ -537,7 +536,7 @@ inline std::optional<boost::asio::ssl::context> getSSLClientContext()
ec);
if (ec)
{
- BMCWEB_LOG_ERROR << "SSL context set_options failed";
+ BMCWEB_LOG_ERROR("SSL context set_options failed");
return std::nullopt;
}
@@ -546,7 +545,7 @@ inline std::optional<boost::asio::ssl::context> getSSLClientContext()
sslCtx.set_default_verify_paths(ec);
if (ec)
{
- BMCWEB_LOG_ERROR << "SSL context set_default_verify failed";
+ BMCWEB_LOG_ERROR("SSL context set_default_verify failed");
return std::nullopt;
}
@@ -554,7 +553,7 @@ inline std::optional<boost::asio::ssl::context> getSSLClientContext()
sslCtx.set_verify_mode(boost::asio::ssl::verify_peer, ec);
if (ec)
{
- BMCWEB_LOG_ERROR << "SSL context set_verify_mode failed";
+ BMCWEB_LOG_ERROR("SSL context set_verify_mode failed");
return std::nullopt;
}
@@ -574,7 +573,7 @@ inline std::optional<boost::asio::ssl::context> getSSLClientContext()
if (SSL_CTX_set_cipher_list(sslCtx.native_handle(), sslCiphers) != 1)
{
- BMCWEB_LOG_ERROR << "SSL_CTX_set_cipher_list failed";
+ BMCWEB_LOG_ERROR("SSL_CTX_set_cipher_list failed");
return std::nullopt;
}
diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp
index 1e1b7e13d1..1b06a93db8 100644
--- a/include/vm_websocket.hpp
+++ b/include/vm_websocket.hpp
@@ -46,7 +46,7 @@ class Handler : public std::enable_shared_from_this<Handler>
int rc = kill(proxy.id(), SIGTERM);
if (rc != 0)
{
- BMCWEB_LOG_ERROR << "Failed to terminate nbd-proxy: " << errno;
+ BMCWEB_LOG_ERROR("Failed to terminate nbd-proxy: {}", errno);
return;
}
@@ -61,8 +61,7 @@ class Handler : public std::enable_shared_from_this<Handler>
boost::process::std_in < pipeIn, ec);
if (ec)
{
- BMCWEB_LOG_ERROR << "Couldn't connect to nbd-proxy: "
- << ec.message();
+ BMCWEB_LOG_ERROR("Couldn't connect to nbd-proxy: {}", ec.message());
if (session != nullptr)
{
session->close("Error connecting to nbd-proxy");
@@ -77,13 +76,13 @@ class Handler : public std::enable_shared_from_this<Handler>
{
if (doingWrite)
{
- BMCWEB_LOG_DEBUG << "Already writing. Bailing out";
+ BMCWEB_LOG_DEBUG("Already writing. Bailing out");
return;
}
if (inputBuffer->size() == 0)
{
- BMCWEB_LOG_DEBUG << "inputBuffer empty. Bailing out";
+ BMCWEB_LOG_DEBUG("inputBuffer empty. Bailing out");
return;
}
@@ -92,7 +91,7 @@ class Handler : public std::enable_shared_from_this<Handler>
inputBuffer->data(),
[this, self(shared_from_this())](const boost::beast::error_code& ec,
std::size_t bytesWritten) {
- BMCWEB_LOG_DEBUG << "Wrote " << bytesWritten << "bytes";
+ BMCWEB_LOG_DEBUG("Wrote {}bytes", bytesWritten);
doingWrite = false;
inputBuffer->consume(bytesWritten);
@@ -108,7 +107,7 @@ class Handler : public std::enable_shared_from_this<Handler>
if (ec)
{
session->close("Error in writing to proxy port");
- BMCWEB_LOG_ERROR << "Error in VM socket write " << ec;
+ BMCWEB_LOG_ERROR("Error in VM socket write {}", ec);
return;
}
doWrite();
@@ -123,10 +122,10 @@ class Handler : public std::enable_shared_from_this<Handler>
outputBuffer->prepare(bytes),
[this, self(shared_from_this())](
const boost::system::error_code& ec, std::size_t bytesRead) {
- BMCWEB_LOG_DEBUG << "Read done. Read " << bytesRead << " bytes";
+ BMCWEB_LOG_DEBUG("Read done. Read {} bytes", bytesRead);
if (ec)
{
- BMCWEB_LOG_ERROR << "Couldn't read from VM port: " << ec;
+ BMCWEB_LOG_ERROR("Couldn't read from VM port: {}", ec);
if (session != nullptr)
{
session->close("Error in connecting to VM port");
@@ -170,7 +169,7 @@ inline void requestRoutes(App& app)
.privileges({{"ConfigureComponents", "ConfigureManager"}})
.websocket()
.onopen([](crow::websocket::Connection& conn) {
- BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
+ BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn));
if (session != nullptr)
{
@@ -210,8 +209,8 @@ inline void requestRoutes(App& app)
if (data.length() >
handler->inputBuffer->capacity() - handler->inputBuffer->size())
{
- BMCWEB_LOG_ERROR << "Buffer overrun when writing "
- << data.length() << " bytes";
+ BMCWEB_LOG_ERROR("Buffer overrun when writing {} bytes",
+ data.length());
conn.close("Buffer overrun");
return;
}
diff --git a/include/webassets.hpp b/include/webassets.hpp
index ca4137448f..4deb7a78ee 100644
--- a/include/webassets.hpp
+++ b/include/webassets.hpp
@@ -57,8 +57,9 @@ inline void requestRoutes(App& app)
std::filesystem::recursive_directory_iterator dirIter(rootpath, ec);
if (ec)
{
- BMCWEB_LOG_ERROR << "Unable to find or open " << rootpath.string()
- << " static file hosting disabled";
+ BMCWEB_LOG_ERROR(
+ "Unable to find or open {} static file hosting disabled",
+ rootpath.string());
return;
}
@@ -117,7 +118,7 @@ inline void requestRoutes(App& app)
{
// Got a duplicated path. This is expected in certain
// situations
- BMCWEB_LOG_DEBUG << "Got duplicated path " << webpath.string();
+ BMCWEB_LOG_DEBUG("Got duplicated path {}", webpath.string());
continue;
}
const char* contentType = nullptr;
@@ -136,9 +137,9 @@ inline void requestRoutes(App& app)
if (contentType == nullptr)
{
- BMCWEB_LOG_ERROR << "Cannot determine content-type for "
- << absolutePath.string() << " with extension "
- << extension;
+ BMCWEB_LOG_ERROR(
+ "Cannot determine content-type for {} with extension {}",
+ absolutePath.string(), extension);
}
if (webpath == "/")
@@ -167,7 +168,7 @@ inline void requestRoutes(App& app)
std::ifstream inf(absolutePath);
if (!inf)
{
- BMCWEB_LOG_DEBUG << "failed to read file";
+ BMCWEB_LOG_DEBUG("failed to read file");
asyncResp->res.result(
boost::beast::http::status::internal_server_error);
return;