summaryrefslogtreecommitdiff
path: root/include/ibm
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/ibm
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/ibm')
-rw-r--r--include/ibm/locks.hpp94
-rw-r--r--include/ibm/management_console_rest.hpp139
-rw-r--r--include/ibm/utils.hpp8
3 files changed, 120 insertions, 121 deletions
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;
}