diff options
94 files changed, 2459 insertions, 2340 deletions
diff --git a/.clang-tidy b/.clang-tidy index 7a476aaf2a..71e80a4eed 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -330,5 +330,6 @@ CheckOptions: - { key: readability-identifier-naming.ParameterCase, value: camelBack } - { key: readability-identifier-naming.NamespaceCase, value: lower_case } - { key: readability-identifier-naming.StructCase, value: CamelCase } + - { key: readability-identifier-naming.FunctionIgnoredRegexp, value: (BMCWEB_LOG_DEBUG|BMCWEB_LOG_INFO|BMCWEB_LOG_WARNING|BMCWEB_LOG_ERROR|BMCWEB_LOG_CRITICAL) } - { key: cppcoreguidelines-macro-usage.AllowedRegexp, value: DEBUG*|NLOHMANN_JSON_SERIALIZE_ENUM } - { key: performance-unnecessary-value-param.AllowedTypes, value: ((segments_view)|(url_view)) } diff --git a/http/app.hpp b/http/app.hpp index 0f0f47b80f..d9c88b9563 100644 --- a/http/app.hpp +++ b/http/app.hpp @@ -144,7 +144,7 @@ class App void debugPrint() { - BMCWEB_LOG_DEBUG << "Routing:"; + BMCWEB_LOG_DEBUG("Routing:"); router.debugPrint(); } @@ -162,8 +162,8 @@ class App App& ssl(std::shared_ptr<boost::asio::ssl::context>&& ctx) { sslContext = std::move(ctx); - BMCWEB_LOG_INFO << "app::ssl context use_count=" - << sslContext.use_count(); + BMCWEB_LOG_INFO("app::ssl context use_count={}", + sslContext.use_count()); return *this; } diff --git a/http/complete_response_fields.hpp b/http/complete_response_fields.hpp index 1819db59b5..66a4bb79af 100644 --- a/http/complete_response_fields.hpp +++ b/http/complete_response_fields.hpp @@ -20,8 +20,8 @@ namespace crow inline void completeResponseFields(const Request& req, Response& res) { - BMCWEB_LOG_INFO << "Response: " << ' ' << req.url().encoded_path() << ' ' - << res.resultInt(); + BMCWEB_LOG_INFO("Response: {} {}", req.url().encoded_path(), + res.resultInt()); addSecurityHeaders(req, res); authentication::cleanupTempSession(req); diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp index dad5089731..a63b234575 100644 --- a/http/http2_connection.hpp +++ b/http/http2_connection.hpp @@ -66,7 +66,7 @@ class HTTP2Connection : if (sendServerConnectionHeader() != 0) { - BMCWEB_LOG_ERROR << "send_server_connection_header failed"; + BMCWEB_LOG_ERROR("send_server_connection_header failed"); return; } doRead(); @@ -74,7 +74,7 @@ class HTTP2Connection : int sendServerConnectionHeader() { - BMCWEB_LOG_DEBUG << "send_server_connection_header()"; + BMCWEB_LOG_DEBUG("send_server_connection_header()"); uint32_t maxStreams = 4; std::array<nghttp2_settings_entry, 2> iv = { @@ -83,7 +83,7 @@ class HTTP2Connection : int rv = ngSession.submitSettings(iv); if (rv != 0) { - BMCWEB_LOG_ERROR << "Fatal error: " << nghttp2_strerror(rv); + BMCWEB_LOG_ERROR("Fatal error: {}", nghttp2_strerror(rv)); return -1; } return 0; @@ -97,20 +97,20 @@ class HTTP2Connection : { if (source == nullptr || source->ptr == nullptr) { - BMCWEB_LOG_DEBUG << "Source was null???"; + BMCWEB_LOG_DEBUG("Source was null???"); return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; } - BMCWEB_LOG_DEBUG << "File read callback length: " << length; + BMCWEB_LOG_DEBUG("File read callback length: {}", length); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) Http2StreamData* str = reinterpret_cast<Http2StreamData*>(source->ptr); crow::Response& res = str->res; - BMCWEB_LOG_DEBUG << "total: " << res.body().size() - << " send_sofar: " << str->sentSofar; + BMCWEB_LOG_DEBUG("total: {} send_sofar: {}", res.body().size(), + str->sentSofar); size_t toSend = std::min(res.body().size() - str->sentSofar, length); - BMCWEB_LOG_DEBUG << "Copying " << toSend << " bytes to buf"; + BMCWEB_LOG_DEBUG("Copying {} bytes to buf", toSend); std::string::iterator bodyBegin = res.body().begin(); std::advance(bodyBegin, str->sentSofar); @@ -120,7 +120,7 @@ class HTTP2Connection : if (str->sentSofar >= res.body().size()) { - BMCWEB_LOG_DEBUG << "Setting OEF flag"; + BMCWEB_LOG_DEBUG("Setting OEF flag"); *dataFlags |= NGHTTP2_DATA_FLAG_EOF; //*dataFlags |= NGHTTP2_DATA_FLAG_NO_COPY; } @@ -138,7 +138,7 @@ class HTTP2Connection : int sendResponse(Response& completedRes, int32_t streamId) { - BMCWEB_LOG_DEBUG << "send_response stream_id:" << streamId; + BMCWEB_LOG_DEBUG("send_response stream_id:{}", streamId); auto it = streams.find(streamId); if (it == streams.end()) @@ -175,7 +175,7 @@ class HTTP2Connection : int rv = ngSession.submitResponse(streamId, hdr, &dataPrd); if (rv != 0) { - BMCWEB_LOG_ERROR << "Fatal error: " << nghttp2_strerror(rv); + BMCWEB_LOG_ERROR("Fatal error: {}", nghttp2_strerror(rv)); close(); return -1; } @@ -201,7 +201,7 @@ class HTTP2Connection : int onRequestRecv(int32_t streamId) { - BMCWEB_LOG_DEBUG << "on_request_recv"; + BMCWEB_LOG_DEBUG("on_request_recv"); auto it = streams.find(streamId); if (it == streams.end()) @@ -211,14 +211,14 @@ class HTTP2Connection : } crow::Request& thisReq = it->second->req; - BMCWEB_LOG_DEBUG << "Handling " << &thisReq << " \"" - << thisReq.url().encoded_path() << "\""; + BMCWEB_LOG_DEBUG("Handling {} \"{}\"", logPtr(&thisReq), + thisReq.url().encoded_path()); crow::Response& thisRes = it->second->res; thisRes.setCompleteRequestHandler( [this, streamId](Response& completeRes) { - BMCWEB_LOG_DEBUG << "res.completeRequestHandler called"; + BMCWEB_LOG_DEBUG("res.completeRequestHandler called"); if (sendResponse(completeRes, streamId) != 0) { close(); @@ -234,7 +234,7 @@ class HTTP2Connection : int onFrameRecvCallback(const nghttp2_frame& frame) { - BMCWEB_LOG_DEBUG << "frame type " << static_cast<int>(frame.hd.type); + BMCWEB_LOG_DEBUG("frame type {}", static_cast<int>(frame.hd.type)); switch (frame.hd.type) { case NGHTTP2_DATA: @@ -255,15 +255,15 @@ class HTTP2Connection : const nghttp2_frame* frame, void* userData) { - BMCWEB_LOG_DEBUG << "on_frame_recv_callback"; + BMCWEB_LOG_DEBUG("on_frame_recv_callback"); if (userData == nullptr) { - BMCWEB_LOG_CRITICAL << "user data was null?"; + BMCWEB_LOG_CRITICAL("user data was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } if (frame == nullptr) { - BMCWEB_LOG_CRITICAL << "frame was null?"; + BMCWEB_LOG_CRITICAL("frame was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } return userPtrToSelf(userData).onFrameRecvCallback(*frame); @@ -281,10 +281,10 @@ class HTTP2Connection : int32_t streamId, uint32_t /*unused*/, void* userData) { - BMCWEB_LOG_DEBUG << "on_stream_close_callback stream " << streamId; + BMCWEB_LOG_DEBUG("on_stream_close_callback stream {}", streamId); if (userData == nullptr) { - BMCWEB_LOG_CRITICAL << "user data was null?"; + BMCWEB_LOG_CRITICAL("user data was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } auto stream = userPtrToSelf(userData).streams.find(streamId); @@ -308,8 +308,8 @@ class HTTP2Connection : std::string_view valueSv(reinterpret_cast<const char*>(value.data()), value.size()); - BMCWEB_LOG_DEBUG << "on_header_callback name: " << nameSv << " value " - << valueSv; + BMCWEB_LOG_DEBUG("on_header_callback name: {} value {}", nameSv, + valueSv); switch (frame.hd.type) { @@ -321,7 +321,7 @@ class HTTP2Connection : auto thisStream = streams.find(frame.hd.stream_id); if (thisStream == streams.end()) { - BMCWEB_LOG_ERROR << "Unknown stream" << frame.hd.stream_id; + BMCWEB_LOG_ERROR("Unknown stream{}", frame.hd.stream_id); close(); return -1; } @@ -338,7 +338,7 @@ class HTTP2Connection : boost::beast::http::string_to_verb(valueSv); if (verb == boost::beast::http::verb::unknown) { - BMCWEB_LOG_ERROR << "Unknown http verb " << valueSv; + BMCWEB_LOG_ERROR("Unknown http verb {}", valueSv); close(); return -1; } @@ -365,22 +365,22 @@ class HTTP2Connection : { if (userData == nullptr) { - BMCWEB_LOG_CRITICAL << "user data was null?"; + BMCWEB_LOG_CRITICAL("user data was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } if (frame == nullptr) { - BMCWEB_LOG_CRITICAL << "frame was null?"; + BMCWEB_LOG_CRITICAL("frame was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } if (name == nullptr) { - BMCWEB_LOG_CRITICAL << "name was null?"; + BMCWEB_LOG_CRITICAL("name was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } if (value == nullptr) { - BMCWEB_LOG_CRITICAL << "value was null?"; + BMCWEB_LOG_CRITICAL("value was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } return userPtrToSelf(userData).onHeaderCallback(*frame, {name, namelen}, @@ -392,7 +392,7 @@ class HTTP2Connection : if (frame.hd.type == NGHTTP2_HEADERS && frame.headers.cat == NGHTTP2_HCAT_REQUEST) { - BMCWEB_LOG_DEBUG << "create stream for id " << frame.hd.stream_id; + BMCWEB_LOG_DEBUG("create stream for id {}", frame.hd.stream_id); std::pair<boost::container::flat_map< int32_t, std::unique_ptr<Http2StreamData>>::iterator, @@ -409,15 +409,15 @@ class HTTP2Connection : const nghttp2_frame* frame, void* userData) { - BMCWEB_LOG_DEBUG << "on_begin_headers_callback"; + BMCWEB_LOG_DEBUG("on_begin_headers_callback"); if (userData == nullptr) { - BMCWEB_LOG_CRITICAL << "user data was null?"; + BMCWEB_LOG_CRITICAL("user data was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } if (frame == nullptr) { - BMCWEB_LOG_CRITICAL << "frame was null?"; + BMCWEB_LOG_CRITICAL("frame was null?"); return NGHTTP2_ERR_CALLBACK_FAILURE; } return userPtrToSelf(userData).onBeginHeadersCallback(*frame); @@ -428,7 +428,7 @@ class HTTP2Connection : size_t sendLength) { self->isWriting = false; - BMCWEB_LOG_DEBUG << "Sent " << sendLength; + BMCWEB_LOG_DEBUG("Sent {}", sendLength); if (ec) { self->close(); @@ -457,7 +457,7 @@ class HTTP2Connection : ssize_t onSendCallback(nghttp2_session* /*session */, const uint8_t* data, size_t length, int /* flags */) { - BMCWEB_LOG_DEBUG << "On send callback size=" << length; + BMCWEB_LOG_DEBUG("On send callback size={}", length); size_t copied = boost::asio::buffer_copy( sendBuffer.prepare(length), boost::asio::buffer(data, length)); sendBuffer.commit(copied); @@ -489,20 +489,20 @@ class HTTP2Connection : void doRead() { - BMCWEB_LOG_DEBUG << this << " doRead"; + BMCWEB_LOG_DEBUG("{} doRead", logPtr(this)); adaptor.async_read_some( inBuffer.prepare(8192), [this, self(shared_from_this())]( const boost::system::error_code& ec, size_t bytesTransferred) { - BMCWEB_LOG_DEBUG << this << " async_read_some " << bytesTransferred - << " Bytes"; + BMCWEB_LOG_DEBUG("{} async_read_some {} Bytes", logPtr(this), + bytesTransferred); if (ec) { - BMCWEB_LOG_ERROR << this - << " Error while reading: " << ec.message(); + BMCWEB_LOG_ERROR("{} Error while reading: {}", logPtr(this), + ec.message()); close(); - BMCWEB_LOG_DEBUG << this << " from read(1)"; + BMCWEB_LOG_DEBUG("{} from read(1)", logPtr(this)); return; } inBuffer.commit(bytesTransferred); @@ -513,13 +513,13 @@ class HTTP2Connection : std::span<const uint8_t> bufferSpan{ std::bit_cast<const uint8_t*>(bufferIt.data()), bufferIt.size()}; - BMCWEB_LOG_DEBUG << "http2 is getting " << bufferSpan.size() - << " bytes"; + BMCWEB_LOG_DEBUG("http2 is getting {} bytes", + bufferSpan.size()); ssize_t readLen = ngSession.memRecv(bufferSpan); if (readLen <= 0) { - BMCWEB_LOG_ERROR << "nghttp2_session_mem_recv returned " - << readLen; + BMCWEB_LOG_ERROR("nghttp2_session_mem_recv returned {}", + readLen); close(); return; } diff --git a/http/http_client.hpp b/http/http_client.hpp index 07fa85d6f9..d82c566a06 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp @@ -84,7 +84,7 @@ static inline boost::system::error_code defaultRetryHandler(unsigned int respCode) { // As a default, assume 200X is alright - BMCWEB_LOG_DEBUG << "Using default check for response code validity"; + BMCWEB_LOG_DEBUG("Using default check for response code validity"); if ((respCode < 200) || (respCode >= 300)) { return boost::system::errc::make_error_code( @@ -165,9 +165,8 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> void doResolve() { state = ConnState::resolveInProgress; - BMCWEB_LOG_DEBUG << "Trying to resolve: " << host << ":" - << std::to_string(port) - << ", id: " << std::to_string(connId); + BMCWEB_LOG_DEBUG("Trying to resolve: {}:{}, id: {}", host, + std::to_string(port), std::to_string(connId)); resolver.async_resolve(host, std::to_string(port), std::bind_front(&ConnectionInfo::afterResolve, @@ -180,19 +179,18 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> { if (ec || (endpointList.empty())) { - BMCWEB_LOG_ERROR << "Resolve failed: " << ec.message() << " " - << host << ":" << std::to_string(port); + BMCWEB_LOG_ERROR("Resolve failed: {} {}:{}", ec.message(), host, + std::to_string(port)); state = ConnState::resolveFailed; waitAndRetry(); return; } - BMCWEB_LOG_DEBUG << "Resolved " << host << ":" << std::to_string(port) - << ", id: " << std::to_string(connId); + BMCWEB_LOG_DEBUG("Resolved {}:{}, id: {}", host, std::to_string(port), + std::to_string(connId)); state = ConnState::connectInProgress; - BMCWEB_LOG_DEBUG << "Trying to connect to: " << host << ":" - << std::to_string(port) - << ", id: " << std::to_string(connId); + BMCWEB_LOG_DEBUG("Trying to connect to: {}:{}, id: {}", host, + std::to_string(port), std::to_string(connId)); timer.expires_after(std::chrono::seconds(30)); timer.async_wait(std::bind_front(onTimeout, weak_from_this())); @@ -217,17 +215,17 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> timer.cancel(); if (ec) { - BMCWEB_LOG_ERROR << "Connect " << endpoint.address().to_string() - << ":" << std::to_string(endpoint.port()) - << ", id: " << std::to_string(connId) - << " failed: " << ec.message(); + BMCWEB_LOG_ERROR("Connect {}:{}, id: {} failed: {}", + endpoint.address().to_string(), + std::to_string(endpoint.port()), + std::to_string(connId), ec.message()); state = ConnState::connectFailed; waitAndRetry(); return; } - BMCWEB_LOG_DEBUG << "Connected to: " << endpoint.address().to_string() - << ":" << std::to_string(endpoint.port()) - << ", id: " << std::to_string(connId); + BMCWEB_LOG_DEBUG( + "Connected to: {}:{}, id: {}", endpoint.address().to_string(), + std::to_string(endpoint.port()), std::to_string(connId)); if (sslConn) { doSslHandshake(); @@ -265,15 +263,14 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> timer.cancel(); if (ec) { - BMCWEB_LOG_ERROR << "SSL Handshake failed -" - << " id: " << std::to_string(connId) - << " error: " << ec.message(); + BMCWEB_LOG_ERROR("SSL Handshake failed - id: {} error: {}", + std::to_string(connId), ec.message()); state = ConnState::handshakeFailed; waitAndRetry(); return; } - BMCWEB_LOG_DEBUG << "SSL Handshake successful -" - << " id: " << std::to_string(connId); + BMCWEB_LOG_DEBUG("SSL Handshake successful - id: {}", + std::to_string(connId)); state = ConnState::connected; sendMessage(); } @@ -316,14 +313,14 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> timer.cancel(); if (ec) { - BMCWEB_LOG_ERROR << "sendMessage() failed: " << ec.message() << " " - << host << ":" << std::to_string(port); + BMCWEB_LOG_ERROR("sendMessage() failed: {} {}:{}", ec.message(), + host, std::to_string(port)); state = ConnState::sendFailed; waitAndRetry(); return; } - BMCWEB_LOG_DEBUG << "sendMessage() bytes transferred: " - << bytesTransferred; + BMCWEB_LOG_DEBUG("sendMessage() bytes transferred: {}", + bytesTransferred); recvMessage(); } @@ -370,28 +367,28 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> timer.cancel(); if (ec && ec != boost::asio::ssl::error::stream_truncated) { - BMCWEB_LOG_ERROR << "recvMessage() failed: " << ec.message() - << " from " << host << ":" << std::to_string(port); + BMCWEB_LOG_ERROR("recvMessage() failed: {} from {}:{}", + ec.message(), host, std::to_string(port)); state = ConnState::recvFailed; waitAndRetry(); return; } - BMCWEB_LOG_DEBUG << "recvMessage() bytes transferred: " - << bytesTransferred; - BMCWEB_LOG_DEBUG << "recvMessage() data: " << parser->get().body(); + BMCWEB_LOG_DEBUG("recvMessage() bytes transferred: {}", + bytesTransferred); + BMCWEB_LOG_DEBUG("recvMessage() data: {}", parser->get().body()); unsigned int respCode = parser->get().result_int(); - BMCWEB_LOG_DEBUG << "recvMessage() Header Response Code: " << respCode; + BMCWEB_LOG_DEBUG("recvMessage() Header Response Code: {}", respCode); // Make sure the received response code is valid as defined by // the associated retry policy if (connPolicy->invalidResp(respCode)) { // The listener failed to receive the Sent-Event - BMCWEB_LOG_ERROR << "recvMessage() Listener Failed to " - "receive Sent-Event. Header Response Code: " - << respCode << " from " << host << ":" - << std::to_string(port); + BMCWEB_LOG_ERROR( + "recvMessage() Listener Failed to " + "receive Sent-Event. Header Response Code: {} from {}:{}", + respCode, host, std::to_string(port)); state = ConnState::recvFailed; waitAndRetry(); return; @@ -403,8 +400,7 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> // Keep the connection alive if server supports it // Else close the connection - BMCWEB_LOG_DEBUG << "recvMessage() keepalive : " - << parser->keep_alive(); + BMCWEB_LOG_DEBUG("recvMessage() keepalive : {}", parser->keep_alive()); // Copy the response into a Response object so that it can be // processed by the callback function. @@ -418,13 +414,13 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> { if (ec == boost::asio::error::operation_aborted) { - BMCWEB_LOG_DEBUG - << "async_wait failed since the operation is aborted"; + BMCWEB_LOG_DEBUG( + "async_wait failed since the operation is aborted"); return; } if (ec) { - BMCWEB_LOG_ERROR << "async_wait failed: " << ec.message(); + BMCWEB_LOG_ERROR("async_wait failed: {}", ec.message()); // If the timer fails, we need to close the socket anyway, same as // if it expired. } @@ -441,10 +437,9 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> if ((retryCount >= connPolicy->maxRetryAttempts) || (state == ConnState::sslInitFailed)) { - BMCWEB_LOG_ERROR << "Maximum number of retries reached." - << " " << host << ":" << std::to_string(port); - BMCWEB_LOG_DEBUG << "Retry policy: " - << connPolicy->retryPolicyAction; + BMCWEB_LOG_ERROR("Maximum number of retries reached. {}:{}", host, + std::to_string(port)); + BMCWEB_LOG_DEBUG("Retry policy: {}", connPolicy->retryPolicyAction); if (connPolicy->retryPolicyAction == "TerminateAfterRetries") { @@ -470,10 +465,9 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> retryCount++; - BMCWEB_LOG_DEBUG << "Attempt retry after " - << std::to_string( - connPolicy->retryIntervalSecs.count()) - << " seconds. RetryCount = " << retryCount; + BMCWEB_LOG_DEBUG("Attempt retry after {} seconds. RetryCount = {}", + std::to_string(connPolicy->retryIntervalSecs.count()), + retryCount); timer.expires_after(connPolicy->retryIntervalSecs); timer.async_wait(std::bind_front(&ConnectionInfo::onTimerDone, this, shared_from_this())); @@ -484,13 +478,13 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> { if (ec == boost::asio::error::operation_aborted) { - BMCWEB_LOG_DEBUG - << "async_wait failed since the operation is aborted" - << ec.message(); + BMCWEB_LOG_DEBUG( + "async_wait failed since the operation is aborted{}", + ec.message()); } else if (ec) { - BMCWEB_LOG_ERROR << "async_wait failed: " << ec.message(); + BMCWEB_LOG_ERROR("async_wait failed: {}", ec.message()); // Ignore the error and continue the retry loop to attempt // sending the event as per the retry policy } @@ -508,15 +502,14 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> // not_connected happens sometimes so don't bother reporting it. if (ec && ec != boost::beast::errc::not_connected) { - BMCWEB_LOG_ERROR << host << ":" << std::to_string(port) - << ", id: " << std::to_string(connId) - << " shutdown failed: " << ec.message(); + BMCWEB_LOG_ERROR("{}:{}, id: {} shutdown failed: {}", host, + std::to_string(port), std::to_string(connId), + ec.message()); } else { - BMCWEB_LOG_DEBUG << host << ":" << std::to_string(port) - << ", id: " << std::to_string(connId) - << " closed gracefully"; + BMCWEB_LOG_DEBUG("{}:{}, id: {} closed gracefully", host, + std::to_string(port), std::to_string(connId)); } if (retry) @@ -549,15 +542,14 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> { if (ec) { - BMCWEB_LOG_ERROR << host << ":" << std::to_string(port) - << ", id: " << std::to_string(connId) - << " shutdown failed: " << ec.message(); + BMCWEB_LOG_ERROR("{}:{}, id: {} shutdown failed: {}", host, + std::to_string(port), std::to_string(connId), + ec.message()); } else { - BMCWEB_LOG_DEBUG << host << ":" << std::to_string(port) - << ", id: " << std::to_string(connId) - << " closed gracefully"; + BMCWEB_LOG_DEBUG("{}:{}, id: {} closed gracefully", host, + std::to_string(port), std::to_string(connId)); } shutdownConn(retry); } @@ -583,9 +575,9 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> boost::beast::error_code ec{static_cast<int>(::ERR_get_error()), boost::asio::error::get_ssl_category()}; - BMCWEB_LOG_ERROR << "SSL_set_tlsext_host_name " << host << ":" - << port << ", id: " << std::to_string(connId) - << " failed: " << ec.message(); + BMCWEB_LOG_ERROR( + "SSL_set_tlsext_host_name {}:{}, id: {} failed: {}", host, port, + std::to_string(connId), ec.message()); // Set state as sslInit failed so that we close the connection // and take appropriate action as per retry configuration. state = ConnState::sslInitFailed; @@ -611,8 +603,8 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo> if (!sslCtx) { - BMCWEB_LOG_ERROR << "prepareSSLContext failed - " << host << ":" - << port << ", id: " << std::to_string(connId); + BMCWEB_LOG_ERROR("prepareSSLContext failed - {}:{}, id: {}", + host, port, std::to_string(connId)); // Don't retry if failure occurs while preparing SSL context // such as certificate is invalid or set cipher failure or set // host name failure etc... Setting conn state to sslInitFailed @@ -648,8 +640,8 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> { if (requestQueue.empty()) { - BMCWEB_LOG_ERROR - << "setConnProps() should not have been called when requestQueue is empty"; + BMCWEB_LOG_ERROR( + "setConnProps() should not have been called when requestQueue is empty"); return; } @@ -657,9 +649,9 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> conn.req = std::move(nextReq.req); conn.callback = std::move(nextReq.callback); - BMCWEB_LOG_DEBUG << "Setting properties for connection " << conn.host - << ":" << std::to_string(conn.port) - << ", id: " << std::to_string(conn.connId); + BMCWEB_LOG_DEBUG("Setting properties for connection {}:{}, id: {}", + conn.host, std::to_string(conn.port), + std::to_string(conn.connId)); // We can remove the request from the queue at this point requestQueue.pop_front(); @@ -680,11 +672,10 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> // Reuse the connection to send the next request in the queue if (!requestQueue.empty()) { - BMCWEB_LOG_DEBUG << std::to_string(requestQueue.size()) - << " requests remaining in queue for " << destIP - << ":" << std::to_string(destPort) - << ", reusing connnection " - << std::to_string(connId); + BMCWEB_LOG_DEBUG( + "{} requests remaining in queue for {}:{}, reusing connnection {}", + std::to_string(requestQueue.size()), destIP, + std::to_string(destPort), std::to_string(connId)); setConnProps(*conn); @@ -744,14 +735,13 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> if (conn->state == ConnState::idle) { - BMCWEB_LOG_DEBUG << "Grabbing idle connection " - << commonMsg; + BMCWEB_LOG_DEBUG("Grabbing idle connection {}", commonMsg); conn->sendMessage(); } else { - BMCWEB_LOG_DEBUG << "Reusing existing connection " - << commonMsg; + BMCWEB_LOG_DEBUG("Reusing existing connection {}", + commonMsg); conn->doResolve(); } return; @@ -762,8 +752,8 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> // the queue if (connections.size() < connPolicy->maxConnections) { - BMCWEB_LOG_DEBUG << "Adding new connection to pool " << destIP - << ":" << std::to_string(destPort); + BMCWEB_LOG_DEBUG("Adding new connection to pool {}:{}", destIP, + std::to_string(destPort)); auto conn = addConnection(); conn->req = std::move(thisReq); conn->callback = std::move(cb); @@ -771,16 +761,17 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> } else if (requestQueue.size() < maxRequestQueueSize) { - BMCWEB_LOG_ERROR << "Max pool size reached. Adding data to queue." - << destIP << ":" << std::to_string(destPort); + BMCWEB_LOG_ERROR( + "Max pool size reached. Adding data to queue.{}:{}", destIP, + std::to_string(destPort)); requestQueue.emplace_back(std::move(thisReq), std::move(cb)); } else { // If we can't buffer the request then we should let the callback // handle a 429 Too Many Requests dummy response - BMCWEB_LOG_ERROR << destIP << ":" << std::to_string(destPort) - << " request queue full. Dropping request."; + BMCWEB_LOG_ERROR("{}:{} request queue full. Dropping request.", + destIP, std::to_string(destPort)); Response dummyRes; dummyRes.result(boost::beast::http::status::too_many_requests); resHandler(dummyRes); @@ -801,7 +792,8 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> std::shared_ptr<ConnectionPool> self = weakSelf.lock(); if (!self) { - BMCWEB_LOG_CRITICAL << self << " Failed to capture connection"; + BMCWEB_LOG_CRITICAL("{} Failed to capture connection", + logPtr(self.get())); return; } @@ -815,10 +807,9 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> auto& ret = connections.emplace_back(std::make_shared<ConnectionInfo>( ioc, id, connPolicy, destIP, destPort, useSSL, newId)); - BMCWEB_LOG_DEBUG << "Added connection " - << std::to_string(connections.size() - 1) - << " to pool " << destIP << ":" - << std::to_string(destPort); + BMCWEB_LOG_DEBUG("Added connection {} to pool {}:{}", + std::to_string(connections.size() - 1), destIP, + std::to_string(destPort)); return ret; } @@ -832,8 +823,8 @@ class ConnectionPool : public std::enable_shared_from_this<ConnectionPool> id(idIn), connPolicy(connPolicyIn), destIP(destIPIn), destPort(destPortIn), useSSL(useSSLIn) { - BMCWEB_LOG_DEBUG << "Initializing connection pool for " << destIP << ":" - << std::to_string(destPort); + BMCWEB_LOG_DEBUG("Initializing connection pool for {}:{}", destIP, + std::to_string(destPort)); // Initialize the pool with a single connection addConnection(); @@ -852,8 +843,8 @@ class HttpClient // sendDataWithCallback() static void genericResHandler(const Response& res) { - BMCWEB_LOG_DEBUG << "Response handled with return code: " - << std::to_string(res.resultInt()); + BMCWEB_LOG_DEBUG("Response handled with return code: {}", + std::to_string(res.resultInt())); } public: diff --git a/http/http_connection.hpp b/http/http_connection.hpp index cb252f96aa..b5d0d2e59e 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp @@ -68,8 +68,8 @@ class Connection : connectionCount++; - BMCWEB_LOG_DEBUG << this << " Connection open, total " - << connectionCount; + BMCWEB_LOG_DEBUG("{} Connection open, total {}", logPtr(this), + connectionCount); } ~Connection() @@ -78,8 +78,8 @@ class Connection : cancelDeadlineTimer(); connectionCount--; - BMCWEB_LOG_DEBUG << this << " Connection closed, total " - << connectionCount; + BMCWEB_LOG_DEBUG("{} Connection closed, total {}", logPtr(this), + connectionCount); } Connection(const Connection&) = delete; @@ -97,9 +97,8 @@ class Connection : mtlsSession = verifyMtlsUser(req->ipAddress, ctx); if (mtlsSession) { - BMCWEB_LOG_DEBUG - << this - << " Generating TLS session: " << mtlsSession->uniqueId; + BMCWEB_LOG_DEBUG("{} Generating TLS session: {}", logPtr(this), + mtlsSession->uniqueId); } } return true; @@ -126,7 +125,7 @@ class Connection : static_cast<unsigned int>(id.length())); if (ret == 0) { - BMCWEB_LOG_ERROR << this << " failed to set SSL id"; + BMCWEB_LOG_ERROR("{} failed to set SSL id", logPtr(this)); } } @@ -143,7 +142,8 @@ class Connection : { if (connectionCount >= 100) { - BMCWEB_LOG_CRITICAL << this << "Max connection count exceeded."; + BMCWEB_LOG_CRITICAL("{}Max connection count exceeded.", + logPtr(this)); return; } @@ -183,8 +183,8 @@ class Connection : { std::string_view selectedProtocol( std::bit_cast<const char*>(alpn), alpnlen); - BMCWEB_LOG_DEBUG << "ALPN selected protocol \"" - << selectedProtocol << "\" len: " << alpnlen; + BMCWEB_LOG_DEBUG("ALPN selected protocol \"{}\" len: {}", + selectedProtocol, alpnlen); if (selectedProtocol == "h2") { auto http2 = @@ -205,7 +205,7 @@ class Connection : crow::Request& thisReq = req.emplace(parser->release(), reqEc); if (reqEc) { - BMCWEB_LOG_DEBUG << "Request failed to construct" << reqEc; + BMCWEB_LOG_DEBUG("Request failed to construct{}", reqEc.message()); res.result(boost::beast::http::status::bad_request); completeRequest(res); return; @@ -226,11 +226,10 @@ class Connection : } } - BMCWEB_LOG_INFO << "Request: " - << " " << this << " HTTP/" << thisReq.version() / 10 - << "." << thisReq.version() % 10 << ' ' - << thisReq.methodString() << " " << thisReq.target() - << " " << thisReq.ipAddress.to_string(); + BMCWEB_LOG_INFO("Request: {} HTTP/{}.{} {} {} {}", logPtr(this), + thisReq.version() / 10, thisReq.version() % 10, + thisReq.methodString(), thisReq.target(), + thisReq.ipAddress.to_string()); res.isAliveHelper = [this]() -> bool { return isAlive(); }; @@ -248,7 +247,7 @@ class Connection : req->method()) && thisReq.session == nullptr) { - BMCWEB_LOG_WARNING << "Authentication failed"; + BMCWEB_LOG_WARNING("Authentication failed"); forward_unauthorized::sendUnauthorized( req->url().encoded_path(), req->getHeaderValue("X-Requested-With"), @@ -258,7 +257,7 @@ class Connection : } #endif // BMCWEB_INSECURE_DISABLE_AUTHX auto asyncResp = std::make_shared<bmcweb::AsyncResp>(); - BMCWEB_LOG_DEBUG << "Setting completion handler"; + BMCWEB_LOG_DEBUG("Setting completion handler"); asyncResp->res.setCompleteRequestHandler( [self(shared_from_this())](crow::Response& thisRes) { self->completeRequest(thisRes); @@ -320,9 +319,8 @@ class Connection : adaptor.next_layer().close(); if (mtlsSession != nullptr) { - BMCWEB_LOG_DEBUG - << this - << " Removing TLS session: " << mtlsSession->uniqueId; + BMCWEB_LOG_DEBUG("{} Removing TLS session: {}", logPtr(this), + mtlsSession->uniqueId); persistent_data::SessionStore::getInstance().removeSession( mtlsSession); } @@ -371,7 +369,7 @@ class Connection : boost::system::error_code getClientIp(boost::asio::ip::address& ip) { boost::system::error_code ec; - BMCWEB_LOG_DEBUG << "Fetch the client IP address"; + BMCWEB_LOG_DEBUG("Fetch the client IP address"); boost::asio::ip::tcp::endpoint endpoint = boost::beast::get_lowest_layer(adaptor).remote_endpoint(ec); @@ -379,8 +377,8 @@ class Connection : { // If remote endpoint fails keep going. "ClientOriginIPAddress" // will be empty. - BMCWEB_LOG_ERROR << "Failed to get the client's IP Address. ec : " - << ec; + BMCWEB_LOG_ERROR("Failed to get the client's IP Address. ec : {}", + ec); return ec; } ip = endpoint.address(); @@ -390,7 +388,7 @@ class Connection : private: void doReadHeaders() { - BMCWEB_LOG_DEBUG << this << " doReadHeaders"; + BMCWEB_LOG_DEBUG("{} doReadHeaders", logPtr(this)); // Clean up any previous Connection. boost::beast::http::async_read_header( @@ -398,21 +396,21 @@ class Connection : [this, self(shared_from_this())](const boost::system::error_code& ec, std::size_t bytesTransferred) { - BMCWEB_LOG_DEBUG << this << " async_read_header " - << bytesTransferred << " Bytes"; + BMCWEB_LOG_DEBUG("{} async_read_header {} Bytes", logPtr(this), + bytesTransferred); bool errorWhileReading = false; if (ec) { errorWhileReading = true; if (ec == boost::beast::http::error::end_of_stream) { - BMCWEB_LOG_WARNING - << this << " Error while reading: " << ec.message(); + BMCWEB_LOG_WARNING("{} Error while reading: {}", + logPtr(this), ec.message()); } else { - BMCWEB_LOG_ERROR - << this << " Error while reading: " << ec.message(); + BMCWEB_LOG_ERROR("{} Error while reading: {}", logPtr(this), + ec.message()); } } else @@ -431,7 +429,7 @@ class Connection : if (errorWhileReading) { close(); - BMCWEB_LOG_DEBUG << this << " from read(1)"; + BMCWEB_LOG_DEBUG("{} from read(1)", logPtr(this)); return; } @@ -440,7 +438,7 @@ class Connection : boost::asio::ip::address ip; if (getClientIp(ip)) { - BMCWEB_LOG_DEBUG << "Unable to get client IP"; + BMCWEB_LOG_DEBUG("Unable to get client IP"); } #ifndef BMCWEB_INSECURE_DISABLE_AUTHX boost::beast::http::verb method = parser->get().method(); @@ -454,13 +452,13 @@ class Connection : parser->content_length(); if (contentLength && *contentLength > loggedOutPostBodyLimit) { - BMCWEB_LOG_DEBUG << "Content length greater than limit " - << *contentLength; + BMCWEB_LOG_DEBUG("Content length greater than limit {}", + *contentLength); close(); return; } - BMCWEB_LOG_DEBUG << "Starting quick deadline"; + BMCWEB_LOG_DEBUG("Starting quick deadline"); } #endif // BMCWEB_INSECURE_DISABLE_AUTHX @@ -476,22 +474,22 @@ class Connection : void doRead() { - BMCWEB_LOG_DEBUG << this << " doRead"; + BMCWEB_LOG_DEBUG("{} doRead", logPtr(this)); startDeadline(); boost::beast::http::async_read_some( adaptor, buffer, *parser, [this, self(shared_from_this())](const boost::system::error_code& ec, std::size_t bytesTransferred) { - BMCWEB_LOG_DEBUG << this << " async_read_some " << bytesTransferred - << " Bytes"; + BMCWEB_LOG_DEBUG("{} async_read_some {} Bytes", logPtr(this), + bytesTransferred); if (ec) { - BMCWEB_LOG_ERROR << this - << " Error while reading: " << ec.message(); + BMCWEB_LOG_ERROR("{} Error while reading: {}", logPtr(this), + ec.message()); close(); - BMCWEB_LOG_DEBUG << this << " from read(1)"; + BMCWEB_LOG_DEBUG("{} from read(1)", logPtr(this)); return; } @@ -515,7 +513,7 @@ class Connection : void doWrite(crow::Response& thisRes) { - BMCWEB_LOG_DEBUG << this << " doWrite"; + BMCWEB_LOG_DEBUG("{} doWrite", logPtr(this)); thisRes.preparePayload(); serializer.emplace(*thisRes.stringResponse); startDeadline(); @@ -523,25 +521,25 @@ class Connection : [this, self(shared_from_this())]( const boost::system::error_code& ec, std::size_t bytesTransferred) { - BMCWEB_LOG_DEBUG << this << " async_write " << bytesTransferred - << " bytes"; + BMCWEB_LOG_DEBUG("{} async_write {} bytes", logPtr(this), + bytesTransferred); cancelDeadlineTimer(); if (ec) { - BMCWEB_LOG_DEBUG << this << " from write(2)"; + BMCWEB_LOG_DEBUG("{} from write(2)", logPtr(this)); return; } if (!keepAlive) { close(); - BMCWEB_LOG_DEBUG << this << " from write(1)"; + BMCWEB_LOG_DEBUG("{} from write(1)", logPtr(this)); return; } serializer.reset(); - BMCWEB_LOG_DEBUG << this << " Clearing response"; + BMCWEB_LOG_DEBUG("{} Clearing response", logPtr(this)); res.clear(); parser.emplace(std::piecewise_construct, std::make_tuple()); parser->body_limit(httpReqBodyLimit); // reset body limit for @@ -580,7 +578,8 @@ class Connection : weakSelf.lock(); if (!self) { - BMCWEB_LOG_CRITICAL << self << " Failed to capture connection"; + BMCWEB_LOG_CRITICAL("{} Failed to capture connection", + logPtr(self.get())); return; } @@ -593,16 +592,18 @@ class Connection : } if (ec) { - BMCWEB_LOG_CRITICAL << self << " timer failed " << ec; + BMCWEB_LOG_CRITICAL("{} timer failed {}", logPtr(self.get()), + ec); } - BMCWEB_LOG_WARNING << self << "Connection timed out, closing"; + BMCWEB_LOG_WARNING("{}Connection timed out, closing", + logPtr(self.get())); self->close(); }); timerStarted = true; - BMCWEB_LOG_DEBUG << this << " timer started"; + BMCWEB_LOG_DEBUG("{} timer started", logPtr(this)); } Adaptor adaptor; diff --git a/http/http_response.hpp b/http/http_response.hpp index 93c90d7d09..c4f9366ed3 100644 --- a/http/http_response.hpp +++ b/http/http_response.hpp @@ -66,8 +66,8 @@ struct Response Response& operator=(Response&& r) noexcept { - BMCWEB_LOG_DEBUG << "Moving response containers; this: " << this - << "; other: " << &r; + BMCWEB_LOG_DEBUG("Moving response containers; this: {}; other: {}", + logPtr(this), logPtr(&r)); if (this == &r) { return *this; @@ -167,9 +167,9 @@ struct Response stringResponse->result() == status::no_content || stringResponse->result() == status::not_modified)) { - BMCWEB_LOG_CRITICAL - << this - << " Response content provided but code was no-content or not_modified, which aren't allowed to have a body"; + BMCWEB_LOG_CRITICAL( + "{} Response content provided but code was no-content or not_modified, which aren't allowed to have a body", + logPtr(this)); pSize = 0; body().clear(); } @@ -179,7 +179,7 @@ struct Response void clear() { - BMCWEB_LOG_DEBUG << this << " Clearing response containers"; + BMCWEB_LOG_DEBUG("{} Clearing response containers", logPtr(this)); stringResponse.emplace(response_type{}); jsonValue = nullptr; completed = false; @@ -216,14 +216,14 @@ struct Response } if (completed) { - BMCWEB_LOG_ERROR << this << " Response was ended twice"; + BMCWEB_LOG_ERROR("{} Response was ended twice", logPtr(this)); return; } completed = true; - BMCWEB_LOG_DEBUG << this << " calling completion handler"; + BMCWEB_LOG_DEBUG("{} calling completion handler", logPtr(this)); if (completeRequestHandler) { - BMCWEB_LOG_DEBUG << this << " completion handler was valid"; + BMCWEB_LOG_DEBUG("{} completion handler was valid", logPtr(this)); completeRequestHandler(*this); } } @@ -235,7 +235,7 @@ struct Response void setCompleteRequestHandler(std::function<void(Response&)>&& handler) { - BMCWEB_LOG_DEBUG << this << " setting completion handler"; + BMCWEB_LOG_DEBUG("{} setting completion handler", logPtr(this)); completeRequestHandler = std::move(handler); // Now that we have a new completion handler attached, we're no longer @@ -245,8 +245,8 @@ struct Response std::function<void(Response&)> releaseCompleteRequestHandler() { - BMCWEB_LOG_DEBUG << this << " releasing completion handler" - << static_cast<bool>(completeRequestHandler); + BMCWEB_LOG_DEBUG("{} releasing completion handler{}", logPtr(this), + static_cast<bool>(completeRequestHandler)); std::function<void(Response&)> ret = completeRequestHandler; completeRequestHandler = nullptr; completed = true; diff --git a/http/http_server.hpp b/http/http_server.hpp index 91de8db37d..dbb95b42dd 100644 --- a/http/http_server.hpp +++ b/http/http_server.hpp @@ -89,8 +89,8 @@ class Server return dateStr; }; - BMCWEB_LOG_INFO << "bmcweb server is running, local endpoint " - << acceptor->local_endpoint().address().to_string(); + BMCWEB_LOG_INFO("bmcweb server is running, local endpoint {}", + acceptor->local_endpoint().address().to_string()); startAsyncWaitForSignal(); doAccept(); } @@ -114,7 +114,7 @@ class Server fs::create_directories(certPath); } fs::path certFile = certPath / "server.pem"; - BMCWEB_LOG_INFO << "Building SSL Context file=" << certFile.string(); + BMCWEB_LOG_INFO("Building SSL Context file={}", certFile.string()); std::string sslPemFile(certFile); ensuressl::ensureOpensslKeyPresentAndValid(sslPemFile); std::shared_ptr<boost::asio::ssl::context> sslContext = @@ -130,21 +130,21 @@ class Server [this](const boost::system::error_code& ec, int signalNo) { if (ec) { - BMCWEB_LOG_INFO << "Error in signal handler" << ec.message(); + BMCWEB_LOG_INFO("Error in signal handler{}", ec.message()); } else { if (signalNo == SIGHUP) { - BMCWEB_LOG_INFO << "Receivied reload signal"; + BMCWEB_LOG_INFO("Receivied reload signal"); loadCertificate(); boost::system::error_code ec2; acceptor->cancel(ec2); if (ec2) { - BMCWEB_LOG_ERROR - << "Error while canceling async operations:" - << ec2.message(); + BMCWEB_LOG_ERROR( + "Error while canceling async operations:{}", + ec2.message()); } startAsyncWaitForSignal(); } diff --git a/http/logging.hpp b/http/logging.hpp index 368548f9c0..bf5e42eb79 100644 --- a/http/logging.hpp +++ b/http/logging.hpp @@ -2,16 +2,119 @@ #include "bmcweb_config.h" -#include <algorithm> -#include <array> -#include <cstdio> -#include <cstdlib> -#include <ctime> -#include <filesystem> +#include <boost/system/error_code.hpp> +#include <boost/url/pct_string_view.hpp> +#include <boost/url/string_view.hpp> +#include <boost/url/url.hpp> +#include <nlohmann/json.hpp> + +#include <bit> +#include <format> #include <iostream> -#include <sstream> -#include <string> +#include <source_location> #include <string_view> +#include <system_error> + +// Clang-tidy would rather these be static, but using static causes the template +// specialization to not function. Ignore the warning. +// NOLINTBEGIN(readability-convert-member-functions-to-static, cert-dcl58-cpp) +template <> +struct std::formatter<boost::system::error_code> +{ + constexpr auto parse(std::format_parse_context& ctx) + { + return ctx.begin(); + } + + auto format(const boost::system::error_code& ec, auto& ctx) const + { + return std::format_to(ctx.out(), "{}", ec.what()); + } +}; + +template <> +struct std::formatter<boost::urls::pct_string_view> +{ + constexpr auto parse(std::format_parse_context& ctx) + { + return ctx.begin(); + } + auto format(const boost::urls::pct_string_view& msg, auto& ctx) const + { + return std::format_to(ctx.out(), "{}", + std::string_view(msg.data(), msg.size())); + } +}; + +template <> +struct std::formatter<boost::urls::url> +{ + constexpr auto parse(std::format_parse_context& ctx) + { + return ctx.begin(); + } + auto format(const boost::urls::url& msg, auto& ctx) const + { + return std::format_to(ctx.out(), "{}", std::string_view(msg.buffer())); + } +}; + +template <> +struct std::formatter<boost::core::string_view> +{ + constexpr auto parse(std::format_parse_context& ctx) + { + return ctx.begin(); + } + auto format(const boost::core::string_view& msg, auto& ctx) const + { + return std::format_to(ctx.out(), "{}", std::string_view(msg)); + } +}; + +template <> +struct std::formatter<void*> +{ + constexpr auto parse(std::format_parse_context& ctx) + { + return ctx.begin(); + } + auto format(const void*& ptr, auto& ctx) const + { + return std::format_to(ctx.out(), "{}", + std::to_string(std::bit_cast<size_t>(ptr))); + } +}; + +template <> +struct std::formatter<nlohmann::json::json_pointer> +{ + constexpr auto parse(std::format_parse_context& ctx) + { + return ctx.begin(); + } + auto format(const nlohmann::json::json_pointer& ptr, auto& ctx) const + { + return std::format_to(ctx.out(), "{}", ptr.to_string()); + } +}; + +template <> +struct std::formatter<nlohmann::json> +{ + static constexpr auto parse(std::format_parse_context& ctx) + { + return ctx.begin(); + } + auto format(const nlohmann::json& json, auto& ctx) const + { + return std::format_to( + ctx.out(), "{}", + json.dump(-1, ' ', false, + nlohmann::json::error_handler_t::replace)); + } +}; +// NOLINTEND(readability-convert-member-functions-to-static, cert-dcl58-cpp) namespace crow { @@ -51,103 +154,83 @@ constexpr crow::LogLevel getLogLevelFromName(std::string_view name) constexpr crow::LogLevel bmcwebCurrentLoggingLevel = getLogLevelFromName(bmcwebLoggingLevel); -class Logger +struct FormatString { - private: - // - static std::string timestamp() - { - std::string date; - date.resize(32, '\0'); - time_t t = time(nullptr); - - tm myTm{}; - - gmtime_r(&t, &myTm); - - size_t sz = strftime(date.data(), date.size(), "%Y-%m-%d %H:%M:%S", - &myTm); - date.resize(sz); - return date; - } - - public: - Logger([[maybe_unused]] const std::string& prefix, - [[maybe_unused]] const std::string& filename, - [[maybe_unused]] const size_t line) - { - stringstream << "(" << timestamp() << ") [" << prefix << " " - << std::filesystem::path(filename).filename() << ":" - << line << "] "; - } - ~Logger() - { - stringstream << std::endl; - std::cerr << stringstream.str(); - } - - Logger(const Logger&) = delete; - Logger(Logger&&) = delete; - Logger& operator=(const Logger&) = delete; - Logger& operator=(const Logger&&) = delete; - - // - template <typename T> - Logger& operator<<([[maybe_unused]] const T& value) - { - // Somewhere in the code we're implicitly casting an array to a - // pointer in logging code. It's non-trivial to find, - // so disable the check here for now - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) - stringstream << value; - return *this; - } + std::string_view str; + std::source_location loc; + + // NOLINTNEXTLINE(google-explicit-constructor) + FormatString(const char* strIn, const std::source_location& locIn = + std::source_location::current()) : + str(strIn), + loc(locIn) + {} +}; - constexpr static LogLevel getCurrentLogLevel() - { - return bmcwebCurrentLoggingLevel; - } +template <typename T> +const void* logPtr(T p) +{ + static_assert(std::is_pointer<T>::value, + "Can't use logPtr without pointer"); + return std::bit_cast<const void*>(p); +} - constexpr static bool isLoggingEnabled() +template <LogLevel level> +inline void vlog(const FormatString& format, std::format_args&& args) +{ + if constexpr (bmcwebCurrentLoggingLevel > level) { - return getCurrentLogLevel() >= crow::LogLevel::Debug; + return; } - - constexpr static bool checkLoggingLevel(const LogLevel level) + constexpr size_t stringIndex = static_cast<size_t>(level); + static_assert(stringIndex < mapLogLevelFromName.size(), + "Missing string for level"); + constexpr std::string_view levelString = + mapLogLevelFromName[stringIndex].first; + std::string_view filename = format.loc.file_name(); + if (filename.starts_with("../")) { - return isLoggingEnabled() && (getCurrentLogLevel() <= level); + filename = filename.substr(3); } - - private: - // - std::ostringstream stringstream; -}; + std::cout << std::format("[{} {}:{}] ", levelString, filename, + format.loc.line()); + std::cout << std::vformat(format.str, args); + std::putc('\n', stdout); +} } // namespace crow -// Disable clang-tidy warnings about unused macros. -// NOLINTBEGIN(cppcoreguidelines-macro-usage, clang-diagnostic-unused-macros) - -// The logging functions currently use macros. Now that we have c++20, ideally -// they'd use source_location with fixed functions, but for the moment, disable -// the check. -#define BMCWEB_LOG_CRITICAL \ - if constexpr (crow::Logger::checkLoggingLevel(crow::LogLevel::Critical)) \ - crow::Logger("CRITICAL", __FILE__, __LINE__) - -#define BMCWEB_LOG_ERROR \ - if constexpr (crow::Logger::checkLoggingLevel(crow::LogLevel::Error)) \ - crow::Logger("ERROR", __FILE__, __LINE__) +template <typename... Args> +inline void BMCWEB_LOG_CRITICAL(const crow::FormatString& format, + Args&&... args) +{ + crow::vlog<crow::LogLevel::Critical>( + format, std::make_format_args(std::forward<Args>(args)...)); +} -#define BMCWEB_LOG_WARNING \ - if constexpr (crow::Logger::checkLoggingLevel(crow::LogLevel::Warning)) \ - crow::Logger("WARNING", __FILE__, __LINE__) +template <typename... Args> +inline void BMCWEB_LOG_ERROR(const crow::FormatString& format, Args&&... args) +{ + crow::vlog<crow::LogLevel::Error>( + format, std::make_format_args(std::forward<Args>(args)...)); +} -#define BMCWEB_LOG_INFO \ - if constexpr (crow::Logger::checkLoggingLevel(crow::LogLevel::Info)) \ - crow::Logger("INFO", __FILE__, __LINE__) +template <typename... Args> +inline void BMCWEB_LOG_WARNING(const crow::FormatString& format, Args&&... args) +{ + crow::vlog<crow::LogLevel::Warning>( + format, std::make_format_args(std::forward<Args>(args)...)); +} -#define BMCWEB_LOG_DEBUG \ - if constexpr (crow::Logger::checkLoggingLevel(crow::LogLevel::Debug)) \ - crow::Logger("DEBUG", __FILE__, __LINE__) +template <typename... Args> +inline void BMCWEB_LOG_INFO(const crow::FormatString& format, Args&&... args) +{ + crow::vlog<crow::LogLevel::Info>( + format, std::make_format_args(std::forward<Args>(args)...)); +} -// NOLINTEND(cppcoreguidelines-macro-usage, clang-diagnostic-unused-macros) +template <typename... Args> +inline void BMCWEB_LOG_DEBUG(const crow::FormatString& format, Args&&... args) +{ + crow::vlog<crow::LogLevel::Debug>( + format, std::make_format_args(std::forward<Args>(args)...)); +} diff --git a/http/mutual_tls.hpp b/http/mutual_tls.hpp index f8af0f6f57..9cd4cde01c 100644 --- a/http/mutual_tls.hpp +++ b/http/mutual_tls.hpp @@ -21,14 +21,14 @@ inline std::shared_ptr<persistent_data::UserSession> .getAuthMethodsConfig() .tls) { - BMCWEB_LOG_DEBUG << "TLS auth_config is disabled"; + BMCWEB_LOG_DEBUG("TLS auth_config is disabled"); return nullptr; } X509_STORE_CTX* cts = ctx.native_handle(); if (cts == nullptr) { - BMCWEB_LOG_DEBUG << "Cannot get native TLS handle."; + BMCWEB_LOG_DEBUG("Cannot get native TLS handle."); return nullptr; } @@ -36,7 +36,7 @@ inline std::shared_ptr<persistent_data::UserSession> X509* peerCert = X509_STORE_CTX_get_current_cert(ctx.native_handle()); if (peerCert == nullptr) { - BMCWEB_LOG_DEBUG << "Cannot get current TLS certificate."; + BMCWEB_LOG_DEBUG("Cannot get current TLS certificate."); return nullptr; } @@ -44,7 +44,7 @@ inline std::shared_ptr<persistent_data::UserSession> int ctxError = X509_STORE_CTX_get_error(cts); if (ctxError != X509_V_OK) { - BMCWEB_LOG_INFO << "Last TLS error is: " << ctxError; + BMCWEB_LOG_INFO("Last TLS error is: {}", ctxError); return nullptr; } // Check that we have reached final certificate in chain @@ -52,12 +52,13 @@ inline std::shared_ptr<persistent_data::UserSession> if (depth != 0) { - BMCWEB_LOG_DEBUG << "Certificate verification in progress (depth " - << depth << "), waiting to reach final depth"; + BMCWEB_LOG_DEBUG( + "Certificate verification in progress (depth {}), waiting to reach final depth", + depth); return nullptr; } - BMCWEB_LOG_DEBUG << "Certificate verification of final depth"; + BMCWEB_LOG_DEBUG("Certificate verification of final depth"); // Verify KeyUsage bool isKeyUsageDigitalSignature = false; @@ -68,7 +69,7 @@ inline std::shared_ptr<persistent_data::UserSession> if ((usage == nullptr) || (usage->data == nullptr)) { - BMCWEB_LOG_DEBUG << "TLS usage is null"; + BMCWEB_LOG_DEBUG("TLS usage is null"); return nullptr; } @@ -88,9 +89,9 @@ inline std::shared_ptr<persistent_data::UserSession> if (!isKeyUsageDigitalSignature || !isKeyUsageKeyAgreement) { - BMCWEB_LOG_DEBUG << "Certificate ExtendedKeyUsage does " - "not allow provided certificate to " - "be used for user authentication"; + BMCWEB_LOG_DEBUG("Certificate ExtendedKeyUsage does " + "not allow provided certificate to " + "be used for user authentication"); return nullptr; } @@ -101,7 +102,7 @@ inline std::shared_ptr<persistent_data::UserSession> if (extUsage == nullptr) { - BMCWEB_LOG_DEBUG << "TLS extUsage is null"; + BMCWEB_LOG_DEBUG("TLS extUsage is null"); return nullptr; } @@ -121,9 +122,9 @@ inline std::shared_ptr<persistent_data::UserSession> // Certificate has to have proper key usages set if (!isExKeyUsageClientAuth) { - BMCWEB_LOG_DEBUG << "Certificate ExtendedKeyUsage does " - "not allow provided certificate to " - "be used for user authentication"; + BMCWEB_LOG_DEBUG("Certificate ExtendedKeyUsage does " + "not allow provided certificate to " + "be used for user authentication"); return nullptr; } std::string sslUser; @@ -136,14 +137,14 @@ inline std::shared_ptr<persistent_data::UserSession> if (status == -1) { - BMCWEB_LOG_DEBUG << "TLS cannot get username to create session"; + BMCWEB_LOG_DEBUG("TLS cannot get username to create session"); return nullptr; } size_t lastChar = sslUser.find('\0'); if (lastChar == std::string::npos || lastChar == 0) { - BMCWEB_LOG_DEBUG << "Invalid TLS user name"; + BMCWEB_LOG_DEBUG("Invalid TLS user name"); return nullptr; } sslUser.resize(lastChar); diff --git a/http/nghttp2_adapters.hpp b/http/nghttp2_adapters.hpp index 3c1f549e85..9f4dc911d7 100644 --- a/http/nghttp2_adapters.hpp +++ b/http/nghttp2_adapters.hpp @@ -99,7 +99,7 @@ struct nghttp2_session { if (nghttp2_session_server_new(&ptr, callbacks.get(), nullptr) != 0) { - BMCWEB_LOG_ERROR << "nghttp2_session_server_new failed"; + BMCWEB_LOG_ERROR("nghttp2_session_server_new failed"); return; } } diff --git a/http/parsing.hpp b/http/parsing.hpp index f16d8903da..839b51cae1 100644 --- a/http/parsing.hpp +++ b/http/parsing.hpp @@ -24,7 +24,7 @@ inline JsonParseResult parseRequestAsJson(const crow::Request& req, if (!boost::iequals(contentType, "application/json") && !boost::iequals(contentType, "application/json; charset=utf-8")) { - BMCWEB_LOG_WARNING << "Failed to parse content type on request"; + BMCWEB_LOG_WARNING("Failed to parse content type on request"); #ifndef BMCWEB_INSECURE_IGNORE_CONTENT_TYPE return JsonParseResult::BadContentType; #endif @@ -32,7 +32,7 @@ inline JsonParseResult parseRequestAsJson(const crow::Request& req, jsonOut = nlohmann::json::parse(req.body(), nullptr, false); if (jsonOut.is_discarded()) { - BMCWEB_LOG_WARNING << "Failed to parse json in request"; + BMCWEB_LOG_WARNING("Failed to parse json in request"); return JsonParseResult::BadJsonData; } diff --git a/http/routing.hpp b/http/routing.hpp index 1b2c131576..49a51f18e7 100644 --- a/http/routing.hpp +++ b/http/routing.hpp @@ -307,18 +307,20 @@ class Trie { if (n->paramChildrens[i] != 0U) { - BMCWEB_LOG_DEBUG << std::string( - 2U * level, ' ') /*<< "("<<n->paramChildrens[i]<<") "*/; + BMCWEB_LOG_DEBUG( + "{}({}{}", + std::string(2U * level, + ' ') /*, n->paramChildrens[i], ") "*/); switch (static_cast<ParamType>(i)) { case ParamType::STRING: - BMCWEB_LOG_DEBUG << "<str>"; + BMCWEB_LOG_DEBUG("<str>"); break; case ParamType::PATH: - BMCWEB_LOG_DEBUG << "<path>"; + BMCWEB_LOG_DEBUG("<path>"); break; case ParamType::MAX: - BMCWEB_LOG_DEBUG << "<ERROR>"; + BMCWEB_LOG_DEBUG("<ERROR>"); break; } @@ -327,9 +329,9 @@ class Trie } for (const Node::ChildMap::value_type& kv : n->children) { - BMCWEB_LOG_DEBUG - << std::string(2U * level, ' ') /*<< "(" << kv.second << ") "*/ - << kv.first; + BMCWEB_LOG_DEBUG("{}({}{}{}", + std::string(2U * level, ' ') /*, kv.second, ") "*/, + kv.first); debugNodePrint(&nodes[kv.second], level + 1); } } @@ -498,7 +500,7 @@ class Router FindRoute route; if (index >= perMethods.size()) { - BMCWEB_LOG_CRITICAL << "Bad index???"; + BMCWEB_LOG_CRITICAL("Bad index???"); return route; } const PerMethod& perMethod = perMethods[index]; @@ -574,8 +576,7 @@ class Router unsigned ruleIndex = found.first; if (ruleIndex == 0U) { - BMCWEB_LOG_DEBUG << "Cannot match rules " - << req.url().encoded_path(); + BMCWEB_LOG_DEBUG("Cannot match rules {}", req.url().encoded_path()); asyncResp->res.result(boost::beast::http::status::not_found); return; } @@ -589,16 +590,16 @@ class Router size_t methods = rule.getMethods(); if ((methods & (1U << static_cast<size_t>(*verb))) == 0) { - BMCWEB_LOG_DEBUG - << "Rule found but method mismatch: " - << req.url().encoded_path() << " with " << req.methodString() - << "(" << static_cast<uint32_t>(*verb) << ") / " << methods; + BMCWEB_LOG_DEBUG( + "Rule found but method mismatch: {} with {}({}) / {}", + req.url().encoded_path(), req.methodString(), + static_cast<uint32_t>(*verb), methods); asyncResp->res.result(boost::beast::http::status::not_found); return; } - BMCWEB_LOG_DEBUG << "Matched rule (upgrade) '" << rule.rule << "' " - << static_cast<uint32_t>(*verb) << " / " << methods; + BMCWEB_LOG_DEBUG("Matched rule (upgrade) '{}' {} / {}", rule.rule, + static_cast<uint32_t>(*verb), methods); // TODO(ed) This should be able to use std::bind_front, but it doesn't // appear to work with the std::move on adaptor. @@ -665,9 +666,8 @@ class Router BaseRule& rule = *foundRoute.route.rule; std::vector<std::string> params = std::move(foundRoute.route.params); - BMCWEB_LOG_DEBUG << "Matched rule '" << rule.rule << "' " - << static_cast<uint32_t>(*verb) << " / " - << rule.getMethods(); + BMCWEB_LOG_DEBUG("Matched rule '{}' {} / {}", rule.rule, + static_cast<uint32_t>(*verb), rule.getMethods()); if (req.session == nullptr) { @@ -684,8 +684,9 @@ class Router { for (size_t i = 0; i < perMethods.size(); i++) { - BMCWEB_LOG_DEBUG << boost::beast::http::to_string( - static_cast<boost::beast::http::verb>(i)); + BMCWEB_LOG_DEBUG("{}", + boost::beast::http::to_string( + static_cast<boost::beast::http::verb>(i))); perMethods[i].trie.debugPrint(); } } diff --git a/http/routing/websocketrule.hpp b/http/routing/websocketrule.hpp index c8f706db51..5e558f2edb 100644 --- a/http/routing/websocketrule.hpp +++ b/http/routing/websocketrule.hpp @@ -32,7 +32,7 @@ class WebSocketRule : public BaseRule const std::shared_ptr<bmcweb::AsyncResp>& /*asyncResp*/, boost::asio::ip::tcp::socket&& adaptor) override { - BMCWEB_LOG_DEBUG << "Websocket handles upgrade"; + BMCWEB_LOG_DEBUG("Websocket handles upgrade"); std::shared_ptr< crow::websocket::ConnectionImpl<boost::asio::ip::tcp::socket>> myConnection = std::make_shared< @@ -47,7 +47,7 @@ class WebSocketRule : public BaseRule boost::beast::ssl_stream<boost::asio::ip::tcp::socket>&& adaptor) override { - BMCWEB_LOG_DEBUG << "Websocket handles upgrade"; + BMCWEB_LOG_DEBUG("Websocket handles upgrade"); std::shared_ptr<crow::websocket::ConnectionImpl< boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>> myConnection = std::make_shared<crow::websocket::ConnectionImpl< diff --git a/http/server_sent_event.hpp b/http/server_sent_event.hpp index 02af0b7523..773394836f 100644 --- a/http/server_sent_event.hpp +++ b/http/server_sent_event.hpp @@ -49,7 +49,7 @@ class ConnectionImpl : public Connection timer(ioc), openHandler(std::move(openHandlerIn)), closeHandler(std::move(closeHandlerIn)) { - BMCWEB_LOG_DEBUG << "SseConnectionImpl: SSE constructor " << this; + BMCWEB_LOG_DEBUG("SseConnectionImpl: SSE constructor {}", logPtr(this)); } ConnectionImpl(const ConnectionImpl&) = delete; @@ -59,7 +59,7 @@ class ConnectionImpl : public Connection ~ConnectionImpl() override { - BMCWEB_LOG_DEBUG << "SSE ConnectionImpl: SSE destructor " << this; + BMCWEB_LOG_DEBUG("SSE ConnectionImpl: SSE destructor {}", logPtr(this)); } boost::asio::io_context& getIoContext() override @@ -72,7 +72,7 @@ class ConnectionImpl : public Connection { if (!openHandler) { - BMCWEB_LOG_CRITICAL << "No open handler???"; + BMCWEB_LOG_CRITICAL("No open handler???"); return; } openHandler(*this); @@ -85,13 +85,13 @@ class ConnectionImpl : public Connection { closeHandler(*this); } - BMCWEB_LOG_DEBUG << "Closing SSE connection " << this << " - " << msg; + BMCWEB_LOG_DEBUG("Closing SSE connection {} - {}", logPtr(this), msg); boost::beast::get_lowest_layer(adaptor).close(); } void sendSSEHeader() { - BMCWEB_LOG_DEBUG << "Starting SSE connection"; + BMCWEB_LOG_DEBUG("Starting SSE connection"); using BodyType = boost::beast::http::buffer_body; boost::beast::http::response<BodyType> res( boost::beast::http::status::ok, 11, BodyType{}); @@ -113,11 +113,11 @@ class ConnectionImpl : public Connection serializer.reset(); if (ec) { - BMCWEB_LOG_ERROR << "Error sending header" << ec; + BMCWEB_LOG_ERROR("Error sending header{}", ec); close("async_write_header failed"); return; } - BMCWEB_LOG_DEBUG << "SSE header sent - Connection established"; + BMCWEB_LOG_DEBUG("SSE header sent - Connection established"); serializer.reset(); @@ -138,7 +138,7 @@ class ConnectionImpl : public Connection } if (ec) { - BMCWEB_LOG_ERROR << "Read error: " << ec; + BMCWEB_LOG_ERROR("Read error: {}", ec); } close("Close SSE connection"); @@ -152,7 +152,7 @@ class ConnectionImpl : public Connection } if (inputBuffer.size() == 0) { - BMCWEB_LOG_DEBUG << "inputBuffer is empty... Bailing out"; + BMCWEB_LOG_DEBUG("inputBuffer is empty... Bailing out"); return; } startTimeout(); @@ -179,19 +179,19 @@ class ConnectionImpl : public Connection if (ec == boost::asio::error::eof) { - BMCWEB_LOG_ERROR << "async_write_some() SSE stream closed"; + BMCWEB_LOG_ERROR("async_write_some() SSE stream closed"); close("SSE stream closed"); return; } if (ec) { - BMCWEB_LOG_ERROR << "async_write_some() failed: " << ec.message(); + BMCWEB_LOG_ERROR("async_write_some() failed: {}", ec.message()); close("async_write_some failed"); return; } - BMCWEB_LOG_DEBUG << "async_write_some() bytes transferred: " - << bytesTransferred; + BMCWEB_LOG_DEBUG("async_write_some() bytes transferred: {}", + bytesTransferred); doWrite(); } @@ -200,7 +200,7 @@ class ConnectionImpl : public Connection { if (msg.empty()) { - BMCWEB_LOG_DEBUG << "Empty data, bailing out."; + BMCWEB_LOG_DEBUG("Empty data, bailing out."); return; } @@ -249,22 +249,24 @@ class ConnectionImpl : public Connection std::shared_ptr<Connection> self = weakSelf.lock(); if (!self) { - BMCWEB_LOG_CRITICAL << self << " Failed to capture connection"; + BMCWEB_LOG_CRITICAL("{} Failed to capture connection", + logPtr(self.get())); return; } if (ec == boost::asio::error::operation_aborted) { - BMCWEB_LOG_DEBUG << "operation aborted"; + BMCWEB_LOG_DEBUG("operation aborted"); // Canceled wait means the path succeeeded. return; } if (ec) { - BMCWEB_LOG_CRITICAL << self << " timer failed " << ec; + BMCWEB_LOG_CRITICAL("{} timer failed {}", logPtr(self.get()), ec); } - BMCWEB_LOG_WARNING << self << "Connection timed out, closing"; + BMCWEB_LOG_WARNING("{}Connection timed out, closing", + logPtr(self.get())); self->close("closing connection"); } diff --git a/http/websocket.hpp b/http/websocket.hpp index 434a0c1944..216c4131db 100644 --- a/http/websocket.hpp +++ b/http/websocket.hpp @@ -75,7 +75,7 @@ class ConnectionImpl : public Connection /* Turn on the timeouts on websocket stream to server role */ ws.set_option(boost::beast::websocket::stream_base::timeout::suggested( boost::beast::role_type::server)); - BMCWEB_LOG_DEBUG << "Creating new connection " << this; + BMCWEB_LOG_DEBUG("Creating new connection {}", logPtr(this)); } boost::asio::io_context& getIoContext() override @@ -86,7 +86,7 @@ class ConnectionImpl : public Connection void start() { - BMCWEB_LOG_DEBUG << "starting connection " << this; + BMCWEB_LOG_DEBUG("starting connection {}", logPtr(this)); using bf = boost::beast::http::field; @@ -104,7 +104,7 @@ class ConnectionImpl : public Connection !crow::utility::constantTimeStringCompare( protocol, session->csrfToken)) { - BMCWEB_LOG_ERROR << "Websocket CSRF error"; + BMCWEB_LOG_ERROR("Websocket CSRF error"); m.result(boost::beast::http::status::unauthorized); return; } @@ -131,7 +131,7 @@ class ConnectionImpl : public Connection const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Error in ws.async_accept " << ec; + BMCWEB_LOG_ERROR("Error in ws.async_accept {}", ec); return; } acceptDone(); @@ -151,8 +151,8 @@ class ConnectionImpl : public Connection { if (doingWrite) { - BMCWEB_LOG_CRITICAL - << "Cannot mix sendEx usage with sendBinary or sendText"; + BMCWEB_LOG_CRITICAL( + "Cannot mix sendEx usage with sendBinary or sendText"); onDone(); return; } @@ -169,7 +169,7 @@ class ConnectionImpl : public Connection if (ec) { - BMCWEB_LOG_ERROR << "Error in ws.async_write " << ec; + BMCWEB_LOG_ERROR("Error in ws.async_write {}", ec); self->close("write error"); } }); @@ -210,7 +210,7 @@ class ConnectionImpl : public Connection } if (ec) { - BMCWEB_LOG_ERROR << "Error closing websocket " << ec; + BMCWEB_LOG_ERROR("Error closing websocket {}", ec); return; } }); @@ -223,7 +223,7 @@ class ConnectionImpl : public Connection void acceptDone() { - BMCWEB_LOG_DEBUG << "Websocket accepted connection"; + BMCWEB_LOG_DEBUG("Websocket accepted connection"); if (openHandler) { @@ -264,7 +264,7 @@ class ConnectionImpl : public Connection { if (ec != boost::beast::websocket::error::closed) { - BMCWEB_LOG_ERROR << "doRead error " << ec; + BMCWEB_LOG_ERROR("doRead error {}", ec); } if (closeHandler) { @@ -306,7 +306,7 @@ class ConnectionImpl : public Connection } if (ec) { - BMCWEB_LOG_ERROR << "Error in ws.async_write " << ec; + BMCWEB_LOG_ERROR("Error in ws.async_write {}", ec); return; } doWrite(); 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; diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index a1c4fb9fe1..00d77c8767 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -287,13 +287,13 @@ inline bool // NOLINTNEXTLINE bmcweb::split(result, sseFilter, ' '); - BMCWEB_LOG_DEBUG << "No of tokens in SEE query: " << result.size(); + BMCWEB_LOG_DEBUG("No of tokens in SEE query: {}", result.size()); constexpr uint8_t divisor = 4; constexpr uint8_t minTokenSize = 3; if (result.size() % divisor != minTokenSize) { - BMCWEB_LOG_ERROR << "Invalid SSE filter specified."; + BMCWEB_LOG_ERROR("Invalid SSE filter specified."); return false; } @@ -309,8 +309,8 @@ inline bool // SSE supports only "or" and "and" in query params. if ((separator != "or") && (separator != "and")) { - BMCWEB_LOG_ERROR - << "Invalid group operator in SSE query parameters"; + BMCWEB_LOG_ERROR( + "Invalid group operator in SSE query parameters"); return false; } } @@ -318,12 +318,12 @@ inline bool // SSE supports only "eq" as per spec. if (op != "eq") { - BMCWEB_LOG_ERROR - << "Invalid assignment operator in SSE query parameters"; + BMCWEB_LOG_ERROR( + "Invalid assignment operator in SSE query parameters"); return false; } - BMCWEB_LOG_DEBUG << key << " : " << value; + BMCWEB_LOG_DEBUG("{} : {}", key, value); if (key == "EventFormatType") { formatType = value; @@ -342,8 +342,7 @@ inline bool } else { - BMCWEB_LOG_ERROR << "Invalid property(" << key - << ")in SSE filter query."; + BMCWEB_LOG_ERROR("Invalid property({})in SSE filter query.", key); return false; } } @@ -477,14 +476,14 @@ class Subscription : public persistent_data::UserSubscription messageArgsView, timestamp, customText, bmcLogEntry) != 0) { - BMCWEB_LOG_DEBUG << "Read eventLog entry failed"; + BMCWEB_LOG_DEBUG("Read eventLog entry failed"); continue; } } if (logEntryArray.empty()) { - BMCWEB_LOG_DEBUG << "No log entries available to be transferred."; + BMCWEB_LOG_DEBUG("No log entries available to be transferred."); return; } @@ -521,9 +520,9 @@ class Subscription : public persistent_data::UserSubscription nlohmann::json msg; if (!telemetry::fillReport(msg, reportId, var)) { - BMCWEB_LOG_ERROR << "Failed to fill the MetricReport for DBus " - "Report with id " - << reportId; + BMCWEB_LOG_ERROR("Failed to fill the MetricReport for DBus " + "Report with id {}", + reportId); return; } @@ -553,7 +552,7 @@ class Subscription : public persistent_data::UserSubscription void setSubscriptionId(const std::string& id2) { - BMCWEB_LOG_DEBUG << "Subscription ID: " << id2; + BMCWEB_LOG_DEBUG("Subscription ID: {}", id2); subId = id2; } @@ -582,8 +581,8 @@ class Subscription : public persistent_data::UserSubscription // policy. 2XX is considered acceptable static boost::system::error_code retryRespHandler(unsigned int respCode) { - BMCWEB_LOG_DEBUG - << "Checking response code validity for SubscriptionEvent"; + BMCWEB_LOG_DEBUG( + "Checking response code validity for SubscriptionEvent"); if ((respCode < 200) || (respCode >= 300)) { return boost::system::errc::make_error_code( @@ -661,8 +660,8 @@ class EventServiceManager if (!status) { - BMCWEB_LOG_ERROR - << "Failed to validate and split destination url"; + BMCWEB_LOG_ERROR( + "Failed to validate and split destination url"); continue; } std::shared_ptr<Subscription> subValue = @@ -683,7 +682,7 @@ class EventServiceManager if (subValue->id.empty()) { - BMCWEB_LOG_ERROR << "Failed to add subscription"; + BMCWEB_LOG_ERROR("Failed to add subscription"); } subscriptionsMap.insert(std::pair(subValue->id, subValue)); @@ -704,13 +703,13 @@ class EventServiceManager std::ifstream eventConfigFile(eventServiceFile); if (!eventConfigFile.good()) { - BMCWEB_LOG_DEBUG << "Old eventService config not exist"; + BMCWEB_LOG_DEBUG("Old eventService config not exist"); return; } auto jsonData = nlohmann::json::parse(eventConfigFile, nullptr, false); if (jsonData.is_discarded()) { - BMCWEB_LOG_ERROR << "Old eventService config parse error."; + BMCWEB_LOG_ERROR("Old eventService config parse error."); return; } @@ -732,8 +731,8 @@ class EventServiceManager true); if (newSubscription == nullptr) { - BMCWEB_LOG_ERROR << "Problem reading subscription " - "from old persistent store"; + BMCWEB_LOG_ERROR("Problem reading subscription " + "from old persistent store"); continue; } @@ -765,9 +764,9 @@ class EventServiceManager if (retry <= 0) { - BMCWEB_LOG_ERROR - << "Failed to generate random number from old " - "persistent store"; + BMCWEB_LOG_ERROR( + "Failed to generate random number from old " + "persistent store"); continue; } } @@ -775,7 +774,7 @@ class EventServiceManager persistent_data::getConfig().writeData(); std::remove(eventServiceFile); - BMCWEB_LOG_DEBUG << "Remove old eventservice config"; + BMCWEB_LOG_DEBUG("Remove old eventservice config"); } } @@ -878,7 +877,7 @@ class EventServiceManager auto obj = subscriptionsMap.find(id); if (obj == subscriptionsMap.end()) { - BMCWEB_LOG_ERROR << "No subscription exist with ID:" << id; + BMCWEB_LOG_ERROR("No subscription exist with ID:{}", id); return nullptr; } std::shared_ptr<Subscription> subValue = obj->second; @@ -912,7 +911,7 @@ class EventServiceManager if (retry <= 0) { - BMCWEB_LOG_ERROR << "Failed to generate random number"; + BMCWEB_LOG_ERROR("Failed to generate random number"); return ""; } @@ -1024,7 +1023,7 @@ class EventServiceManager std::shared_ptr<Subscription> entry = it.second; if (entry->destinationUrl == destUrl) { - BMCWEB_LOG_ERROR << "Destination exist already" << destUrl; + BMCWEB_LOG_ERROR("Destination exist already{}", destUrl); return true; } } @@ -1049,7 +1048,7 @@ class EventServiceManager { if (!serviceEnabled || (noOfEventLogSubscribers == 0U)) { - BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions."; + BMCWEB_LOG_DEBUG("EventService disabled or no Subscriptions."); return; } nlohmann::json eventRecord = nlohmann::json::array(); @@ -1076,8 +1075,9 @@ class EventServiceManager { if (resType == resource) { - BMCWEB_LOG_INFO << "ResourceType " << resource - << " found in the subscribed list"; + BMCWEB_LOG_INFO( + "ResourceType {} found in the subscribed list", + resource); isSubscribed = true; break; } @@ -1103,7 +1103,7 @@ class EventServiceManager } else { - BMCWEB_LOG_INFO << "Not subscribed to this resource"; + BMCWEB_LOG_INFO("Not subscribed to this resource"); } } } @@ -1124,7 +1124,7 @@ class EventServiceManager std::ifstream logStream(redfishEventLogFile); if (!logStream.good()) { - BMCWEB_LOG_ERROR << " Redfish log file open failed \n"; + BMCWEB_LOG_ERROR(" Redfish log file open failed "); return; } std::string logEntry; @@ -1132,8 +1132,6 @@ class EventServiceManager { redfishLogFilePosition = logStream.tellg(); } - - BMCWEB_LOG_DEBUG << "Next Log Position : " << redfishLogFilePosition; } void readEventLogsFromFile() @@ -1141,7 +1139,7 @@ class EventServiceManager std::ifstream logStream(redfishEventLogFile); if (!logStream.good()) { - BMCWEB_LOG_ERROR << " Redfish log file open failed"; + BMCWEB_LOG_ERROR(" Redfish log file open failed"); return; } @@ -1177,7 +1175,7 @@ class EventServiceManager if (event_log::getEventLogParams(logEntry, timestamp, messageID, messageArgs) != 0) { - BMCWEB_LOG_DEBUG << "Read eventLog entry params failed"; + BMCWEB_LOG_DEBUG("Read eventLog entry params failed"); continue; } @@ -1196,14 +1194,14 @@ class EventServiceManager if (!serviceEnabled || noOfEventLogSubscribers == 0) { - BMCWEB_LOG_DEBUG << "EventService disabled or no Subscriptions."; + BMCWEB_LOG_DEBUG("EventService disabled or no Subscriptions."); return; } if (eventRecords.empty()) { // No Records to send - BMCWEB_LOG_DEBUG << "No log entries available to be transferred."; + BMCWEB_LOG_DEBUG("No log entries available to be transferred."); return; } @@ -1231,7 +1229,7 @@ class EventServiceManager const std::size_t& bytesTransferred) { if (ec) { - BMCWEB_LOG_ERROR << "Callback Error: " << ec.message(); + BMCWEB_LOG_ERROR("Callback Error: {}", ec.message()); return; } std::size_t index = 0; @@ -1256,16 +1254,16 @@ class EventServiceManager continue; } - BMCWEB_LOG_DEBUG - << "Redfish log file created/deleted. event.name: " - << fileName; + BMCWEB_LOG_DEBUG( + "Redfish log file created/deleted. event.name: {}", + fileName); if (event.mask == IN_CREATE) { if (fileWatchDesc != -1) { - BMCWEB_LOG_DEBUG - << "Remove and Add inotify watcher on " - "redfish event log file"; + BMCWEB_LOG_DEBUG( + "Remove and Add inotify watcher on " + "redfish event log file"); // Remove existing inotify watcher and add // with new redfish event log file. inotify_rm_watch(inotifyFd, fileWatchDesc); @@ -1276,8 +1274,8 @@ class EventServiceManager inotifyFd, redfishEventLogFile, IN_MODIFY); if (fileWatchDesc == -1) { - BMCWEB_LOG_ERROR << "inotify_add_watch failed for " - "redfish log file."; + BMCWEB_LOG_ERROR("inotify_add_watch failed for " + "redfish log file."); return; } @@ -1317,7 +1315,7 @@ class EventServiceManager inotifyFd = inotify_init1(IN_NONBLOCK); if (inotifyFd == -1) { - BMCWEB_LOG_ERROR << "inotify_init1 failed."; + BMCWEB_LOG_ERROR("inotify_init1 failed."); return -1; } @@ -1327,8 +1325,8 @@ class EventServiceManager IN_CREATE | IN_MOVED_TO | IN_DELETE); if (dirWatchDesc == -1) { - BMCWEB_LOG_ERROR - << "inotify_add_watch failed for event log directory."; + BMCWEB_LOG_ERROR( + "inotify_add_watch failed for event log directory."); return -1; } @@ -1337,8 +1335,7 @@ class EventServiceManager IN_MODIFY); if (fileWatchDesc == -1) { - BMCWEB_LOG_ERROR - << "inotify_add_watch failed for redfish log file."; + BMCWEB_LOG_ERROR("inotify_add_watch failed for redfish log file."); // Don't return error if file not exist. // Watch on directory will handle create/delete of file. } @@ -1355,7 +1352,7 @@ class EventServiceManager { if (msg.is_method_error()) { - BMCWEB_LOG_ERROR << "TelemetryMonitor Signal error"; + BMCWEB_LOG_ERROR("TelemetryMonitor Signal error"); return; } @@ -1363,7 +1360,7 @@ class EventServiceManager std::string id = path.filename(); if (id.empty()) { - BMCWEB_LOG_ERROR << "Failed to get Id from path"; + BMCWEB_LOG_ERROR("Failed to get Id from path"); return; } @@ -1377,7 +1374,7 @@ class EventServiceManager [](const auto& x) { return x.first == "Readings"; }); if (found == props.end()) { - BMCWEB_LOG_INFO << "Failed to get Readings from Report properties"; + BMCWEB_LOG_INFO("Failed to get Readings from Report properties"); return; } @@ -1385,7 +1382,7 @@ class EventServiceManager std::get_if<telemetry::TimestampReadings>(&found->second); if (readings == nullptr) { - BMCWEB_LOG_INFO << "Failed to get Readings from Report properties"; + BMCWEB_LOG_INFO("Failed to get Readings from Report properties"); return; } @@ -1404,7 +1401,7 @@ class EventServiceManager { if (matchTelemetryMonitor) { - BMCWEB_LOG_DEBUG << "Metrics report signal - Unregister"; + BMCWEB_LOG_DEBUG("Metrics report signal - Unregister"); matchTelemetryMonitor.reset(); matchTelemetryMonitor = nullptr; } @@ -1414,11 +1411,11 @@ class EventServiceManager { if (!serviceEnabled || matchTelemetryMonitor) { - BMCWEB_LOG_DEBUG << "Not registering metric report signal."; + BMCWEB_LOG_DEBUG("Not registering metric report signal."); return; } - BMCWEB_LOG_DEBUG << "Metrics report signal - Register"; + BMCWEB_LOG_DEBUG("Metrics report signal - Register"); std::string matchStr = "type='signal',member='PropertiesChanged'," "interface='org.freedesktop.DBus.Properties'," "arg0=xyz.openbmc_project.Telemetry.Report"; diff --git a/redfish-core/include/gzfile.hpp b/redfish-core/include/gzfile.hpp index 34bc151ef5..3fa1e49e34 100644 --- a/redfish-core/include/gzfile.hpp +++ b/redfish-core/include/gzfile.hpp @@ -18,7 +18,7 @@ class GzFileReader gzFile logStream = gzopen(filename.c_str(), "r"); if (logStream == nullptr) { - BMCWEB_LOG_ERROR << "Can't open gz file: " << filename << '\n'; + BMCWEB_LOG_ERROR("Can't open gz file: {}", filename); return false; } @@ -46,9 +46,9 @@ class GzFileReader int errNum = 0; const char* errMsg = gzerror(logStream, &errNum); - BMCWEB_LOG_ERROR << "Error reading gz compressed data.\n" - << "Error Message: " << errMsg << '\n' - << "Error Number: " << errNum; + BMCWEB_LOG_ERROR( + "Error reading gz compressed data.\nError Message: {}\nError Number: {}", + errMsg, errNum); } bool readFile(gzFile logStream, uint64_t skip, uint64_t top, @@ -71,7 +71,7 @@ class GzFileReader bufferStr.resize(static_cast<size_t>(bytesRead)); if (!hostLogEntryParser(bufferStr, skip, top, logEntries, logCount)) { - BMCWEB_LOG_ERROR << "Error occurs during parsing host log.\n"; + BMCWEB_LOG_ERROR("Error occurs during parsing host log."); return false; } } while (gzeof(logStream) != 1); @@ -114,9 +114,9 @@ class GzFileReader totalFilesSize += logEntry.size(); if (totalFilesSize > maxTotalFilesSize) { - BMCWEB_LOG_ERROR - << "File size exceeds maximum allowed size of " - << maxTotalFilesSize; + BMCWEB_LOG_ERROR( + "File size exceeds maximum allowed size of {}", + maxTotalFilesSize); return false; } logEntries.push_back(logEntry); @@ -145,9 +145,9 @@ class GzFileReader totalFilesSize++; if (totalFilesSize > maxTotalFilesSize) { - BMCWEB_LOG_ERROR - << "File size exceeds maximum allowed size of " - << maxTotalFilesSize; + BMCWEB_LOG_ERROR( + "File size exceeds maximum allowed size of {}", + maxTotalFilesSize); return false; } logEntries.emplace_back("\n"); @@ -188,9 +188,9 @@ class GzFileReader size_t tmpMessageSize = totalFilesSize + lastMessage.size(); if (tmpMessageSize > maxTotalFilesSize) { - BMCWEB_LOG_ERROR - << "File size exceeds maximum allowed size of " - << maxTotalFilesSize; + BMCWEB_LOG_ERROR( + "File size exceeds maximum allowed size of {}", + maxTotalFilesSize); return false; } } diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp index bb2c2f3024..8b4220847b 100644 --- a/redfish-core/include/privileges.hpp +++ b/redfish-core/include/privileges.hpp @@ -102,8 +102,8 @@ class Privileges { if (!setSinglePrivilege(privilege)) { - BMCWEB_LOG_CRITICAL << "Unable to set privilege " << privilege - << "in constructor"; + BMCWEB_LOG_CRITICAL("Unable to set privilege {}in constructor", + privilege); } } } @@ -295,10 +295,10 @@ inline bool isOperationAllowedWithPrivileges( } for (const auto& requiredPrivileges : operationPrivilegesRequired) { - BMCWEB_LOG_DEBUG << "Checking operation privileges..."; + BMCWEB_LOG_DEBUG("Checking operation privileges..."); if (userPrivileges.isSupersetOf(requiredPrivileges)) { - BMCWEB_LOG_DEBUG << "...success"; + BMCWEB_LOG_DEBUG("...success"); return true; } } diff --git a/redfish-core/include/query.hpp b/redfish-core/include/query.hpp index c1ca38e957..78de6cae06 100644 --- a/redfish-core/include/query.hpp +++ b/redfish-core/include/query.hpp @@ -38,8 +38,8 @@ inline void const crow::Response& resIn) { std::string computedEtag = resIn.computeEtag(); - BMCWEB_LOG_DEBUG << "User provided if-match etag " << ifMatchHeader - << " computed etag " << computedEtag; + BMCWEB_LOG_DEBUG("User provided if-match etag {} computed etag {}", + ifMatchHeader, computedEtag); if (computedEtag != ifMatchHeader) { messages::preconditionFailed(asyncResp->res); @@ -47,7 +47,7 @@ inline void } // Restart the request without if-match req.req.erase(boost::beast::http::field::if_match); - BMCWEB_LOG_DEBUG << "Restarting request"; + BMCWEB_LOG_DEBUG("Restarting request"); app.handle(req, asyncResp); } @@ -118,7 +118,7 @@ inline bool handleIfMatch(crow::App& app, const crow::Request& req, query_param::Query& delegated, const query_param::QueryCapabilities& queryCapabilities) { - BMCWEB_LOG_DEBUG << "setup redfish route"; + BMCWEB_LOG_DEBUG("setup redfish route"); // Section 7.4 of the redfish spec "Redfish Services shall process the // [OData-Version header] in the following table as defined by the HTTP 1.1 diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp index 7cae89af86..59a4eb97d4 100644 --- a/redfish-core/include/redfish_aggregator.hpp +++ b/redfish-core/include/redfish_aggregator.hpp @@ -83,8 +83,8 @@ inline bool searchCollectionsArray(std::string_view uri, uri.substr(serviceRootUri.size(), parseCount)); if (!parsedUrl) { - BMCWEB_LOG_ERROR << "Failed to get target URI from " - << uri.substr(serviceRootUri.size()); + BMCWEB_LOG_ERROR("Failed to get target URI from {}", + uri.substr(serviceRootUri.size())); return false; } @@ -165,7 +165,7 @@ static inline void addPrefixToStringItem(std::string& strValue, auto parsed = boost::urls::parse_relative_ref(strValue); if (!parsed) { - BMCWEB_LOG_CRITICAL << "Couldn't parse URI from resource " << strValue; + BMCWEB_LOG_CRITICAL("Couldn't parse URI from resource {}", strValue); return; } @@ -178,7 +178,7 @@ static inline void addPrefixToStringItem(std::string& strValue, if (crow::utility::readUrlSegments(thisUrl, "redfish", "v1", "JsonSchemas", crow::utility::OrMorePaths())) { - BMCWEB_LOG_DEBUG << "Skipping JsonSchemas URI prefix fixing"; + BMCWEB_LOG_DEBUG("Skipping JsonSchemas URI prefix fixing"); return; } @@ -244,7 +244,7 @@ static inline void addPrefixToItem(nlohmann::json& item, std::string* strValue = item.get_ptr<std::string*>(); if (strValue == nullptr) { - BMCWEB_LOG_CRITICAL << "Field wasn't a string????"; + BMCWEB_LOG_CRITICAL("Field wasn't a string????"); return; } addPrefixToStringItem(*strValue, prefix); @@ -288,7 +288,7 @@ static inline void addPrefixToHeadersInResp(nlohmann::json& json, nlohmann::json::array_t* array = json.get_ptr<nlohmann::json::array_t*>(); if (array == nullptr) { - BMCWEB_LOG_ERROR << "Field wasn't an array_t????"; + BMCWEB_LOG_ERROR("Field wasn't an array_t????"); return; } @@ -298,7 +298,7 @@ static inline void addPrefixToHeadersInResp(nlohmann::json& json, std::string* strHeader = item.get_ptr<std::string*>(); if (strHeader == nullptr) { - BMCWEB_LOG_CRITICAL << "Field wasn't a string????"; + BMCWEB_LOG_CRITICAL("Field wasn't a string????"); continue; } @@ -355,7 +355,7 @@ inline boost::system::error_code aggregationRetryHandler(unsigned int respCode) { // Allow all response codes because we want to surface any satellite // issue to the client - BMCWEB_LOG_DEBUG << "Received " << respCode << " response from satellite"; + BMCWEB_LOG_DEBUG("Received {} response from satellite", respCode); return boost::system::errc::make_error_code(boost::system::errc::success); } @@ -382,13 +382,12 @@ class RedfishAggregator { if (ec) { - BMCWEB_LOG_ERROR << "Something went wrong while querying dbus!"; + BMCWEB_LOG_ERROR("Something went wrong while querying dbus!"); return; } - BMCWEB_LOG_DEBUG << "There were " - << std::to_string(satelliteInfo.size()) - << " satellite configs found at startup"; + BMCWEB_LOG_DEBUG("There were {} satellite configs found at startup", + std::to_string(satelliteInfo.size())); } // Search D-Bus objects for satellite config objects and add their @@ -404,14 +403,14 @@ class RedfishAggregator if (interface.first == "xyz.openbmc_project.Configuration.SatelliteController") { - BMCWEB_LOG_DEBUG << "Found Satellite Controller at " - << objectPath.first.str; + BMCWEB_LOG_DEBUG("Found Satellite Controller at {}", + objectPath.first.str); if (!satelliteInfo.empty()) { - BMCWEB_LOG_ERROR - << "Redfish Aggregation only supports one satellite!"; - BMCWEB_LOG_DEBUG << "Clearing all satellite data"; + BMCWEB_LOG_ERROR( + "Redfish Aggregation only supports one satellite!"); + BMCWEB_LOG_DEBUG("Clearing all satellite data"); satelliteInfo.clear(); return; } @@ -442,7 +441,7 @@ class RedfishAggregator std::get_if<std::string>(&prop.second); if (propVal == nullptr) { - BMCWEB_LOG_ERROR << "Invalid Hostname value"; + BMCWEB_LOG_ERROR("Invalid Hostname value"); return; } url.set_host(*propVal); @@ -453,13 +452,13 @@ class RedfishAggregator const uint64_t* propVal = std::get_if<uint64_t>(&prop.second); if (propVal == nullptr) { - BMCWEB_LOG_ERROR << "Invalid Port value"; + BMCWEB_LOG_ERROR("Invalid Port value"); return; } if (*propVal > std::numeric_limits<uint16_t>::max()) { - BMCWEB_LOG_ERROR << "Port value out of range"; + BMCWEB_LOG_ERROR("Port value out of range"); return; } url.set_port(std::to_string(static_cast<uint16_t>(*propVal))); @@ -471,7 +470,7 @@ class RedfishAggregator std::get_if<std::string>(&prop.second); if (propVal == nullptr) { - BMCWEB_LOG_ERROR << "Invalid AuthType value"; + BMCWEB_LOG_ERROR("Invalid AuthType value"); return; } @@ -479,9 +478,9 @@ class RedfishAggregator // with the satellite BMC if (*propVal != "None") { - BMCWEB_LOG_ERROR - << "Unsupported AuthType value: " << *propVal - << ", only \"none\" is supported"; + BMCWEB_LOG_ERROR( + "Unsupported AuthType value: {}, only \"none\" is supported", + *propVal); return; } url.set_scheme("http"); @@ -491,20 +490,19 @@ class RedfishAggregator // Make sure all required config information was made available if (url.host().empty()) { - BMCWEB_LOG_ERROR << "Satellite config " << name << " missing Host"; + BMCWEB_LOG_ERROR("Satellite config {} missing Host", name); return; } if (!url.has_port()) { - BMCWEB_LOG_ERROR << "Satellite config " << name << " missing Port"; + BMCWEB_LOG_ERROR("Satellite config {} missing Port", name); return; } if (!url.has_scheme()) { - BMCWEB_LOG_ERROR << "Satellite config " << name - << " missing AuthType"; + BMCWEB_LOG_ERROR("Satellite config {} missing AuthType", name); return; } @@ -519,9 +517,9 @@ class RedfishAggregator resultString = "Updated existing satellite config "; } - BMCWEB_LOG_DEBUG << resultString << name << " at " - << result.first->second.scheme() << "://" - << result.first->second.encoded_host_and_port(); + BMCWEB_LOG_DEBUG("{}{} at {}://{}", resultString, name, + result.first->second.scheme(), + result.first->second.encoded_host_and_port()); } enum AggregationType @@ -539,15 +537,15 @@ class RedfishAggregator { if (aggType == AggregationType::Collection) { - BMCWEB_LOG_DEBUG - << "Only aggregate GET requests to top level collections"; + BMCWEB_LOG_DEBUG( + "Only aggregate GET requests to top level collections"); return; } if (aggType == AggregationType::ContainsSubordinate) { - BMCWEB_LOG_DEBUG << "Only aggregate GET requests when uptree of" - << " a top level collection"; + BMCWEB_LOG_DEBUG( + "Only aggregate GET requests when uptree of a top level collection"); return; } } @@ -557,7 +555,7 @@ class RedfishAggregator auto localReq = std::make_shared<crow::Request>(thisReq.req, ec); if (ec) { - BMCWEB_LOG_ERROR << "Failed to create copy of request"; + BMCWEB_LOG_ERROR("Failed to create copy of request"); if (aggType == AggregationType::Resource) { messages::internalError(asyncResp->res); @@ -582,8 +580,7 @@ class RedfishAggregator targetPrefix += "_"; if (memberName.starts_with(targetPrefix)) { - BMCWEB_LOG_DEBUG << "\"" << satellite.first - << "\" is a known prefix"; + BMCWEB_LOG_DEBUG("\"{}\" is a known prefix", satellite.first); // Remove the known prefix from the request's URI and // then forward to the associated satellite BMC @@ -634,14 +631,14 @@ class RedfishAggregator } const crow::Request& thisReq = *sharedReq; - BMCWEB_LOG_DEBUG << "Aggregation is enabled, begin processing of " - << thisReq.target(); + BMCWEB_LOG_DEBUG("Aggregation is enabled, begin processing of {}", + thisReq.target()); // We previously determined the request is for a collection. No need to // check again if (aggType == AggregationType::Collection) { - BMCWEB_LOG_DEBUG << "Aggregating a collection"; + BMCWEB_LOG_DEBUG("Aggregating a collection"); // We need to use a specific response handler and send the // request to all known satellites getInstance().forwardCollectionRequests(thisReq, asyncResp, @@ -653,8 +650,8 @@ class RedfishAggregator // collection. No need to check again if (aggType == AggregationType::ContainsSubordinate) { - BMCWEB_LOG_DEBUG - << "Aggregating what may have a subordinate collection"; + BMCWEB_LOG_DEBUG( + "Aggregating what may have a subordinate collection"); // We need to use a specific response handler and send the // request to all known satellites getInstance().forwardContainsSubordinateRequests(thisReq, asyncResp, @@ -703,8 +700,7 @@ class RedfishAggregator { // Realistically this shouldn't get called since we perform an // earlier check to make sure the prefix exists - BMCWEB_LOG_ERROR << "Unrecognized satellite prefix \"" << prefix - << "\""; + BMCWEB_LOG_ERROR("Unrecognized satellite prefix \"{}\"", prefix); return; } @@ -714,8 +710,8 @@ class RedfishAggregator if (pos == std::string::npos) { // If this fails then something went wrong - BMCWEB_LOG_ERROR << "Error removing prefix \"" << prefix - << "_\" from request URI"; + BMCWEB_LOG_ERROR("Error removing prefix \"{}_\" from request URI", + prefix); messages::internalError(asyncResp->res); return; } @@ -803,7 +799,7 @@ class RedfishAggregator const std::unordered_map<std::string, boost::urls::url>&)> handler) { - BMCWEB_LOG_DEBUG << "Gathering satellite configs"; + BMCWEB_LOG_DEBUG("Gathering satellite configs"); sdbusplus::message::object_path path("/xyz/openbmc_project/inventory"); dbus::utility::getManagedObjects( "xyz.openbmc_project.EntityManager", path, @@ -813,8 +809,8 @@ class RedfishAggregator std::unordered_map<std::string, boost::urls::url> satelliteInfo; if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec.value() << ", " - << ec.message(); + BMCWEB_LOG_ERROR("DBUS response error {}, {}", ec.value(), + ec.message()); handler(ec, satelliteInfo); return; } @@ -826,14 +822,14 @@ class RedfishAggregator if (!satelliteInfo.empty()) { - BMCWEB_LOG_DEBUG << "Redfish Aggregation enabled with " - << std::to_string(satelliteInfo.size()) - << " satellite BMCs"; + BMCWEB_LOG_DEBUG( + "Redfish Aggregation enabled with {} satellite BMCs", + std::to_string(satelliteInfo.size())); } else { - BMCWEB_LOG_DEBUG - << "No satellite BMCs detected. Redfish Aggregation not enabled"; + BMCWEB_LOG_DEBUG( + "No satellite BMCs detected. Redfish Aggregation not enabled"); } handler(ec, satelliteInfo); }); @@ -866,21 +862,21 @@ class RedfishAggregator false); if (jsonVal.is_discarded()) { - BMCWEB_LOG_ERROR << "Error parsing satellite response as JSON"; + BMCWEB_LOG_ERROR("Error parsing satellite response as JSON"); messages::operationFailed(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Successfully parsed satellite response"; + BMCWEB_LOG_DEBUG("Successfully parsed satellite response"); addPrefixes(jsonVal, prefix); - BMCWEB_LOG_DEBUG << "Added prefix to parsed satellite response"; + BMCWEB_LOG_DEBUG("Added prefix to parsed satellite response"); asyncResp->res.result(resp.result()); asyncResp->res.jsonValue = std::move(jsonVal); - BMCWEB_LOG_DEBUG << "Finished writing asyncResp"; + BMCWEB_LOG_DEBUG("Finished writing asyncResp"); } else { @@ -908,9 +904,9 @@ class RedfishAggregator if (resp.resultInt() != 200) { - BMCWEB_LOG_DEBUG - << "Collection resource does not exist in satellite BMC \"" - << prefix << "\""; + BMCWEB_LOG_DEBUG( + "Collection resource does not exist in satellite BMC \"{}\"", + prefix); // Return the error if we haven't had any successes if (asyncResp->res.resultInt() != 200) { @@ -930,7 +926,7 @@ class RedfishAggregator false); if (jsonVal.is_discarded()) { - BMCWEB_LOG_ERROR << "Error parsing satellite response as JSON"; + BMCWEB_LOG_ERROR("Error parsing satellite response as JSON"); // Notify the user if doing so won't overwrite a valid response if (asyncResp->res.resultInt() != 200) @@ -940,13 +936,13 @@ class RedfishAggregator return; } - BMCWEB_LOG_DEBUG << "Successfully parsed satellite response"; + BMCWEB_LOG_DEBUG("Successfully parsed satellite response"); // Now we need to add the prefix to the URIs contained in the // response. addPrefixes(jsonVal, prefix); - BMCWEB_LOG_DEBUG << "Added prefix to parsed satellite response"; + BMCWEB_LOG_DEBUG("Added prefix to parsed satellite response"); // If this resource collection does not exist on the aggregating bmc // and has not already been added from processing the response from @@ -959,18 +955,18 @@ class RedfishAggregator if ((!jsonVal.contains("Members")) && (!jsonVal["Members"].is_array())) { - BMCWEB_LOG_DEBUG - << "Skipping aggregating unsupported resource"; + BMCWEB_LOG_DEBUG( + "Skipping aggregating unsupported resource"); return; } - BMCWEB_LOG_DEBUG - << "Collection does not exist, overwriting asyncResp"; + BMCWEB_LOG_DEBUG( + "Collection does not exist, overwriting asyncResp"); asyncResp->res.result(resp.result()); asyncResp->res.jsonValue = std::move(jsonVal); asyncResp->res.addHeader("Content-Type", "application/json"); - BMCWEB_LOG_DEBUG << "Finished overwriting asyncResp"; + BMCWEB_LOG_DEBUG("Finished overwriting asyncResp"); } else { @@ -980,13 +976,14 @@ class RedfishAggregator (!asyncResp->res.jsonValue["Members"].is_array())) { - BMCWEB_LOG_DEBUG - << "Skipping aggregating unsupported resource"; + BMCWEB_LOG_DEBUG( + "Skipping aggregating unsupported resource"); return; } - BMCWEB_LOG_DEBUG << "Adding aggregated resources from \"" - << prefix << "\" to collection"; + BMCWEB_LOG_DEBUG( + "Adding aggregated resources from \"{}\" to collection", + prefix); // TODO: This is a potential race condition with multiple // satellites and the aggregating bmc attempting to write to @@ -1010,8 +1007,8 @@ class RedfishAggregator } else { - BMCWEB_LOG_ERROR << "Received unparsable response from \"" << prefix - << "\""; + BMCWEB_LOG_ERROR("Received unparsable response from \"{}\"", + prefix); // We received a response that was not a json. // Notify the user only if we did not receive any valid responses // and if the resource collection does not already exist on the @@ -1041,9 +1038,9 @@ class RedfishAggregator if (resp.resultInt() != 200) { - BMCWEB_LOG_DEBUG - << "Resource uptree from Collection does not exist in " - << "satellite BMC \"" << prefix << "\""; + BMCWEB_LOG_DEBUG( + "Resource uptree from Collection does not exist in satellite BMC \"{}\"", + prefix); // Return the error if we haven't had any successes if (asyncResp->res.resultInt() != 200) { @@ -1064,7 +1061,7 @@ class RedfishAggregator false); if (jsonVal.is_discarded()) { - BMCWEB_LOG_ERROR << "Error parsing satellite response as JSON"; + BMCWEB_LOG_ERROR("Error parsing satellite response as JSON"); // Notify the user if doing so won't overwrite a valid response if (asyncResp->res.resultInt() != 200) @@ -1074,7 +1071,7 @@ class RedfishAggregator return; } - BMCWEB_LOG_DEBUG << "Successfully parsed satellite response"; + BMCWEB_LOG_DEBUG("Successfully parsed satellite response"); // Parse response and add properties missing from the AsyncResp // Valid properties will be of the form <property>.@odata.id and @@ -1085,7 +1082,7 @@ class RedfishAggregator jsonVal.get_ptr<nlohmann::json::object_t*>(); if (object == nullptr) { - BMCWEB_LOG_ERROR << "Parsed JSON was not an object?"; + BMCWEB_LOG_ERROR("Parsed JSON was not an object?"); return; } @@ -1100,7 +1097,7 @@ class RedfishAggregator prop.second["@odata.id"].get_ptr<std::string*>(); if (strValue == nullptr) { - BMCWEB_LOG_CRITICAL << "Field wasn't a string????"; + BMCWEB_LOG_CRITICAL("Field wasn't a string????"); continue; } if (!searchCollectionsArray(*strValue, SearchType::CollOrCon)) @@ -1112,8 +1109,8 @@ class RedfishAggregator if (!asyncResp->res.jsonValue.contains(prop.first)) { // Only add the property if it did not already exist - BMCWEB_LOG_DEBUG << "Adding link for " << *strValue - << " from BMC " << prefix; + BMCWEB_LOG_DEBUG("Adding link for {} from BMC {}", + *strValue, prefix); asyncResp->res.jsonValue[prop.first]["@odata.id"] = *strValue; continue; @@ -1157,8 +1154,8 @@ class RedfishAggregator } else { - BMCWEB_LOG_ERROR << "Received unparsable response from \"" << prefix - << "\""; + BMCWEB_LOG_ERROR("Received unparsable response from \"{}\"", + prefix); // We received as response that was not a json // Notify the user only if we did not receive any valid responses, // and if the resource does not already exist on the aggregating BMC @@ -1225,7 +1222,7 @@ class RedfishAggregator // being a local resource describing the satellite if (collectionItem.starts_with("5B247A_")) { - BMCWEB_LOG_DEBUG << "Need to forward a request"; + BMCWEB_LOG_DEBUG("Need to forward a request"); // Extract the prefix from the request's URI, retrieve the // associated satellite config information, and then forward @@ -1271,7 +1268,7 @@ class RedfishAggregator return Result::LocalHandle; } - BMCWEB_LOG_DEBUG << "Aggregation not required for " << url.buffer(); + BMCWEB_LOG_DEBUG("Aggregation not required for {}", url.buffer()); return Result::LocalHandle; } }; diff --git a/redfish-core/include/snmp_trap_event_clients.hpp b/redfish-core/include/snmp_trap_event_clients.hpp index 08ff81b439..de7bf9d95d 100644 --- a/redfish-core/include/snmp_trap_event_clients.hpp +++ b/redfish-core/include/snmp_trap_event_clients.hpp @@ -28,7 +28,7 @@ inline void afterGetSnmpTrapClientdata( { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus response error on GetSubTree " << ec; + BMCWEB_LOG_ERROR("D-Bus response error on GetSubTree {}", ec); messages::internalError(asyncResp->res); return; } @@ -95,8 +95,8 @@ inline void dbus::utility::ManagedObjectType& resp) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus response error on GetManagedObjects " - << ec; + BMCWEB_LOG_ERROR("D-Bus response error on GetManagedObjects {}", + ec); messages::internalError(asyncResp->res); return; } @@ -107,7 +107,7 @@ inline void const std::string snmpId = path.filename(); if (snmpId.empty()) { - BMCWEB_LOG_ERROR << "The SNMP client ID is wrong"; + BMCWEB_LOG_ERROR("The SNMP client ID is wrong"); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/include/utils/chassis_utils.hpp b/redfish-core/include/utils/chassis_utils.hpp index 9c7c7db6bc..c8c203d3d3 100644 --- a/redfish-core/include/utils/chassis_utils.hpp +++ b/redfish-core/include/utils/chassis_utils.hpp @@ -21,7 +21,7 @@ template <typename Callback> void getValidChassisPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& chassisId, Callback&& callback) { - BMCWEB_LOG_DEBUG << "checkChassisId enter"; + BMCWEB_LOG_DEBUG("checkChassisId enter"); constexpr std::array<std::string_view, 2> interfaces = { "xyz.openbmc_project.Inventory.Item.Board", "xyz.openbmc_project.Inventory.Item.Chassis"}; @@ -33,11 +33,11 @@ void getValidChassisPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, chassisId](const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreePathsResponse& chassisPaths) mutable { - BMCWEB_LOG_DEBUG << "getValidChassisPath respHandler enter"; + BMCWEB_LOG_DEBUG("getValidChassisPath respHandler enter"); if (ec) { - BMCWEB_LOG_ERROR << "getValidChassisPath respHandler DBUS error: " - << ec; + BMCWEB_LOG_ERROR("getValidChassisPath respHandler DBUS error: {}", + ec); messages::internalError(asyncResp->res); return; } @@ -49,7 +49,7 @@ void getValidChassisPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string chassisName = path.filename(); if (chassisName.empty()) { - BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis; + BMCWEB_LOG_ERROR("Failed to find '/' in {}", chassis); continue; } if (chassisName == chassisId) @@ -60,7 +60,7 @@ void getValidChassisPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } callback(chassisPath); }); - BMCWEB_LOG_DEBUG << "checkChassisId exit"; + BMCWEB_LOG_DEBUG("checkChassisId exit"); } } // namespace chassis_utils diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp index 500749cd54..862be90efd 100644 --- a/redfish-core/include/utils/collection.hpp +++ b/redfish-core/include/utils/collection.hpp @@ -37,8 +37,7 @@ inline void std::span<const std::string_view> interfaces, const char* subtree = "/xyz/openbmc_project/inventory") { - BMCWEB_LOG_DEBUG << "Get collection members for: " - << collectionPath.buffer(); + BMCWEB_LOG_DEBUG("Get collection members for: {}", collectionPath.buffer()); dbus::utility::getSubTreePaths( subtree, 0, interfaces, [collectionPath, asyncResp{std::move(asyncResp)}]( @@ -53,7 +52,7 @@ inline void if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec.value(); + BMCWEB_LOG_DEBUG("DBUS response error {}", ec.value()); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/include/utils/dbus_utils.hpp b/redfish-core/include/utils/dbus_utils.hpp index 7e895fea47..298a56b6ec 100644 --- a/redfish-core/include/utils/dbus_utils.hpp +++ b/redfish-core/include/utils/dbus_utils.hpp @@ -14,11 +14,10 @@ struct UnpackErrorPrinter void operator()(const sdbusplus::UnpackErrorReason reason, const std::string& property) const noexcept { - BMCWEB_LOG_ERROR - << "DBUS property error in property: " << property << ", reason: " - << static_cast< - std::underlying_type_t<sdbusplus::UnpackErrorReason>>( - reason); + BMCWEB_LOG_ERROR( + "DBUS property error in property: {}, reason: {}", property, + static_cast<std::underlying_type_t<sdbusplus::UnpackErrorReason>>( + reason)); } }; diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp index 642ca802eb..3d3ae8d4bd 100644 --- a/redfish-core/include/utils/json_utils.hpp +++ b/redfish-core/include/utils/json_utils.hpp @@ -101,21 +101,21 @@ bool checkRange(const FromType& from, std::string_view key) { if (from > std::numeric_limits<ToType>::max()) { - BMCWEB_LOG_DEBUG << "Value for key " << key - << " was greater than max: " << __PRETTY_FUNCTION__; + BMCWEB_LOG_DEBUG("Value for key {} was greater than max: {}", key, + __PRETTY_FUNCTION__); return false; } if (from < std::numeric_limits<ToType>::lowest()) { - BMCWEB_LOG_DEBUG << "Value for key " << key - << " was less than min: " << __PRETTY_FUNCTION__; + BMCWEB_LOG_DEBUG("Value for key {} was less than min: {}", key, + __PRETTY_FUNCTION__); return false; } if constexpr (std::is_floating_point_v<ToType>) { if (std::isnan(from)) { - BMCWEB_LOG_DEBUG << "Value for key " << key << " was NAN"; + BMCWEB_LOG_DEBUG("Value for key {} was NAN", key); return false; } } @@ -193,9 +193,8 @@ UnpackErrorCode unpackValueWithErrorCode(nlohmann::json& jsonValue, JsonType jsonPtr = jsonValue.get_ptr<JsonType>(); if (jsonPtr == nullptr) { - BMCWEB_LOG_DEBUG - << "Value for key " << key - << " was incorrect type: " << jsonValue.type_name(); + BMCWEB_LOG_DEBUG("Value for key {} was incorrect type: {}", key, + jsonValue.type_name()); return UnpackErrorCode::invalidType; } value = std::move(*jsonPtr); @@ -392,7 +391,7 @@ inline bool readJsonHelper(nlohmann::json& jsonRequest, crow::Response& res, jsonRequest.get_ptr<nlohmann::json::object_t*>(); if (obj == nullptr) { - BMCWEB_LOG_DEBUG << "Json value is not an object"; + BMCWEB_LOG_DEBUG("Json value is not an object"); messages::unrecognizedRequestBody(res); return false; } @@ -521,14 +520,14 @@ inline std::optional<nlohmann::json> nlohmann::json jsonRequest; if (!json_util::processJsonFromRequest(res, req, jsonRequest)) { - BMCWEB_LOG_DEBUG << "Json value not readable"; + BMCWEB_LOG_DEBUG("Json value not readable"); return std::nullopt; } nlohmann::json::object_t* object = jsonRequest.get_ptr<nlohmann::json::object_t*>(); if (object == nullptr || object->empty()) { - BMCWEB_LOG_DEBUG << "Json value is empty"; + BMCWEB_LOG_DEBUG("Json value is empty"); messages::emptyJSON(res); return std::nullopt; } @@ -568,7 +567,7 @@ bool readJsonAction(const crow::Request& req, crow::Response& res, nlohmann::json jsonRequest; if (!json_util::processJsonFromRequest(res, req, jsonRequest)) { - BMCWEB_LOG_DEBUG << "Json value not readable"; + BMCWEB_LOG_DEBUG("Json value not readable"); return false; } return readJson(jsonRequest, res, key, std::forward<UnpackTypes&&>(in)...); diff --git a/redfish-core/include/utils/pcie_util.hpp b/redfish-core/include/utils/pcie_util.hpp index 4db6e03249..a889f936ab 100644 --- a/redfish-core/include/utils/pcie_util.hpp +++ b/redfish-core/include/utils/pcie_util.hpp @@ -46,8 +46,7 @@ inline void pcieDevicePaths) { if (ec) { - BMCWEB_LOG_DEBUG << "no PCIe device paths found ec: " - << ec.message(); + BMCWEB_LOG_DEBUG("no PCIe device paths found ec: {}", ec.message()); // Not an error, system just doesn't have PCIe info return; } diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp index 4ba521b692..696e323d96 100644 --- a/redfish-core/include/utils/query_param.hpp +++ b/redfish-core/include/utils/query_param.hpp @@ -462,7 +462,7 @@ inline std::optional<Query> parseParameters(boost::urls::params_view urlParams, inline bool processOnly(crow::App& app, crow::Response& res, std::function<void(crow::Response&)>& completionHandler) { - BMCWEB_LOG_DEBUG << "Processing only query param"; + BMCWEB_LOG_DEBUG("Processing only query param"); auto itMembers = res.jsonValue.find("Members"); if (itMembers == res.jsonValue.end()) { @@ -473,8 +473,9 @@ inline bool processOnly(crow::App& app, crow::Response& res, auto itMemBegin = itMembers->begin(); if (itMemBegin == itMembers->end() || itMembers->size() != 1) { - BMCWEB_LOG_DEBUG << "Members contains " << itMembers->size() - << " element, returning full collection."; + BMCWEB_LOG_DEBUG( + "Members contains {} element, returning full collection.", + itMembers->size()); completionHandler(res); return false; } @@ -482,7 +483,7 @@ inline bool processOnly(crow::App& app, crow::Response& res, auto itUrl = itMemBegin->find("@odata.id"); if (itUrl == itMemBegin->end()) { - BMCWEB_LOG_DEBUG << "No found odata.id"; + BMCWEB_LOG_DEBUG("No found odata.id"); messages::internalError(res); completionHandler(res); return false; @@ -490,7 +491,7 @@ inline bool processOnly(crow::App& app, crow::Response& res, const std::string* url = itUrl->get_ptr<const std::string*>(); if (url == nullptr) { - BMCWEB_LOG_DEBUG << "@odata.id wasn't a string????"; + BMCWEB_LOG_DEBUG("@odata.id wasn't a string????"); messages::internalError(res); completionHandler(res); return false; @@ -507,7 +508,8 @@ inline bool processOnly(crow::App& app, crow::Response& res, } auto asyncResp = std::make_shared<bmcweb::AsyncResp>(); - BMCWEB_LOG_DEBUG << "setting completion handler on " << &asyncResp->res; + BMCWEB_LOG_DEBUG("setting completion handler on {}", + logPtr(&asyncResp->res)); asyncResp->res.setCompleteRequestHandler(std::move(completionHandler)); asyncResp->res.setIsAliveHelper(res.releaseIsAliveHelper()); app.handle(newReq, asyncResp); @@ -579,7 +581,7 @@ inline void findNavigationReferencesInArrayRecursive( for (auto& element : array) { nlohmann::json::json_pointer newPtr = jsonPtr / index; - BMCWEB_LOG_DEBUG << "Traversing response at " << newPtr.to_string(); + BMCWEB_LOG_DEBUG("Traversing response at {}", newPtr.to_string()); findNavigationReferencesRecursive(eType, element, newPtr, depth, skipDepth, inLinks, out); index++; @@ -600,8 +602,7 @@ inline void findNavigationReferencesInObjectRecursive( obj.begin()->second.get_ptr<const std::string*>(); if (uri != nullptr) { - BMCWEB_LOG_DEBUG << "Found " << *uri << " at " - << jsonPtr.to_string(); + BMCWEB_LOG_DEBUG("Found {} at {}", *uri, jsonPtr.to_string()); if (skipDepth == 0) { out.push_back({jsonPtr, *uri}); @@ -658,7 +659,7 @@ inline void findNavigationReferencesInObjectRecursive( continue; } nlohmann::json::json_pointer newPtr = jsonPtr / element.first; - BMCWEB_LOG_DEBUG << "Traversing response at " << newPtr; + BMCWEB_LOG_DEBUG("Traversing response at {}", newPtr); findNavigationReferencesRecursive(eType, element.second, newPtr, newDepth, skipDepth, localInLinks, @@ -827,7 +828,7 @@ class MultiAsyncResp : public std::enable_shared_from_this<MultiAsyncResp> void placeResult(const nlohmann::json::json_pointer& locationToPlace, crow::Response& res) { - BMCWEB_LOG_DEBUG << "placeResult for " << locationToPlace; + BMCWEB_LOG_DEBUG("placeResult for {}", locationToPlace); propogateError(finalRes->res, res); if (!res.jsonValue.is_object() || res.jsonValue.empty()) { @@ -844,7 +845,7 @@ class MultiAsyncResp : public std::enable_shared_from_this<MultiAsyncResp> std::vector<ExpandNode> nodes = findNavigationReferences( query.expandType, query.expandLevel, delegated.expandLevel, finalRes->res.jsonValue); - BMCWEB_LOG_DEBUG << nodes.size() << " nodes to traverse"; + BMCWEB_LOG_DEBUG("{} nodes to traverse", nodes.size()); const std::optional<std::string> queryStr = formatQueryForExpand(query); if (!queryStr) { @@ -854,7 +855,7 @@ class MultiAsyncResp : public std::enable_shared_from_this<MultiAsyncResp> for (const ExpandNode& node : nodes) { const std::string subQuery = node.uri + *queryStr; - BMCWEB_LOG_DEBUG << "URL of subquery: " << subQuery; + BMCWEB_LOG_DEBUG("URL of subquery: {}", subQuery); std::error_code ec; crow::Request newReq({boost::beast::http::verb::get, subQuery, 11}, ec); @@ -865,8 +866,8 @@ class MultiAsyncResp : public std::enable_shared_from_this<MultiAsyncResp> } auto asyncResp = std::make_shared<bmcweb::AsyncResp>(); - BMCWEB_LOG_DEBUG << "setting completion handler on " - << &asyncResp->res; + BMCWEB_LOG_DEBUG("setting completion handler on {}", + logPtr(&asyncResp->res)); addAwaitingResponse(asyncResp, node.location); app.handle(newReq, asyncResp); @@ -902,7 +903,7 @@ inline void processTopAndSkip(const Query& query, crow::Response& res) return; } - BMCWEB_LOG_DEBUG << "Handling top/skip"; + BMCWEB_LOG_DEBUG("Handling top/skip"); nlohmann::json::object_t::iterator members = obj->find("Members"); if (members == obj->end()) { @@ -946,12 +947,12 @@ inline void recursiveSelect(nlohmann::json& currRoot, currRoot.get_ptr<nlohmann::json::object_t*>(); if (object != nullptr) { - BMCWEB_LOG_DEBUG << "Current JSON is an object"; + BMCWEB_LOG_DEBUG("Current JSON is an object"); auto it = currRoot.begin(); while (it != currRoot.end()) { auto nextIt = std::next(it); - BMCWEB_LOG_DEBUG << "key=" << it.key(); + BMCWEB_LOG_DEBUG("key={}", it.key()); const SelectTrieNode* nextNode = currNode.find(it.key()); // Per the Redfish spec section 7.3.3, the service shall select // certain properties as if $select was omitted. This applies to @@ -969,12 +970,12 @@ inline void recursiveSelect(nlohmann::json& currRoot, } if (nextNode != nullptr) { - BMCWEB_LOG_DEBUG << "Recursively select: " << it.key(); + BMCWEB_LOG_DEBUG("Recursively select: {}", it.key()); recursiveSelect(*it, *nextNode); it = nextIt; continue; } - BMCWEB_LOG_DEBUG << it.key() << " is getting removed!"; + BMCWEB_LOG_DEBUG("{} is getting removed!", it.key()); it = currRoot.erase(it); } } @@ -982,7 +983,7 @@ inline void recursiveSelect(nlohmann::json& currRoot, currRoot.get_ptr<nlohmann::json::array_t*>(); if (array != nullptr) { - BMCWEB_LOG_DEBUG << "Current JSON is an array"; + BMCWEB_LOG_DEBUG("Current JSON is an array"); // Array index is omitted, so reuse the same Trie node for (nlohmann::json& nextRoot : *array) { @@ -1000,7 +1001,7 @@ inline void recursiveSelect(nlohmann::json& currRoot, inline void processSelect(crow::Response& intermediateResponse, const SelectTrieNode& trieRoot) { - BMCWEB_LOG_DEBUG << "Process $select quary parameter"; + BMCWEB_LOG_DEBUG("Process $select quary parameter"); recursiveSelect(intermediateResponse.jsonValue, trieRoot); } @@ -1011,11 +1012,11 @@ inline void { if (!completionHandler) { - BMCWEB_LOG_DEBUG << "Function was invalid?"; + BMCWEB_LOG_DEBUG("Function was invalid?"); return; } - BMCWEB_LOG_DEBUG << "Processing query params"; + BMCWEB_LOG_DEBUG("Processing query params"); // If the request failed, there's no reason to even try to run query // params. if (intermediateResponse.resultInt() < 200 || @@ -1037,7 +1038,7 @@ inline void if (query.expandType != ExpandType::None) { - BMCWEB_LOG_DEBUG << "Executing expand query"; + BMCWEB_LOG_DEBUG("Executing expand query"); auto asyncResp = std::make_shared<bmcweb::AsyncResp>( std::move(intermediateResponse)); diff --git a/redfish-core/include/utils/sw_utils.hpp b/redfish-core/include/utils/sw_utils.hpp index 176586fb69..cffc637ff7 100644 --- a/redfish-core/include/utils/sw_utils.hpp +++ b/redfish-core/include/utils/sw_utils.hpp @@ -54,11 +54,11 @@ inline void populateSoftwareInformation( populateLinkToImages]( const boost::system::error_code& ec, const dbus::utility::MapperEndPoints& functionalSw) { - BMCWEB_LOG_DEBUG << "populateSoftwareInformation enter"; + BMCWEB_LOG_DEBUG("populateSoftwareInformation enter"); if (ec) { - BMCWEB_LOG_ERROR << "error_code = " << ec; - BMCWEB_LOG_ERROR << "error msg = " << ec.message(); + BMCWEB_LOG_ERROR("error_code = {}", ec); + BMCWEB_LOG_ERROR("error msg = {}", ec.message()); messages::internalError(asyncResp->res); return; } @@ -67,7 +67,7 @@ inline void populateSoftwareInformation( { // Could keep going and try to populate SoftwareImages but // something is seriously wrong, so just fail - BMCWEB_LOG_ERROR << "Zero functional software in system"; + BMCWEB_LOG_ERROR("Zero functional software in system"); messages::internalError(asyncResp->res); return; } @@ -98,13 +98,13 @@ inline void populateSoftwareInformation( const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec2) { - BMCWEB_LOG_ERROR << "error_code = " << ec2; - BMCWEB_LOG_ERROR << "error msg = " << ec2.message(); + BMCWEB_LOG_ERROR("error_code = {}", ec2); + BMCWEB_LOG_ERROR("error msg = {}", ec2.message()); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Found " << subtree.size() << " images"; + BMCWEB_LOG_DEBUG("Found {} images", subtree.size()); for (const std::pair<std::string, std::vector<std::pair< @@ -116,7 +116,7 @@ inline void populateSoftwareInformation( if (swId.empty()) { messages::internalError(asyncResp->res); - BMCWEB_LOG_ERROR << "Invalid software ID"; + BMCWEB_LOG_ERROR("Invalid software ID"); return; } @@ -142,8 +142,8 @@ inline void populateSoftwareInformation( propertiesList) { if (ec3) { - BMCWEB_LOG_ERROR << "error_code = " << ec3; - BMCWEB_LOG_ERROR << "error msg = " << ec3.message(); + BMCWEB_LOG_ERROR("error_code = {}", ec3); + BMCWEB_LOG_ERROR("error msg = {}", ec3.message()); // Have seen the code update app delete the D-Bus // object, during code update, between the call to // mapper and here. Just leave these properties off if @@ -185,9 +185,9 @@ inline void populateSoftwareInformation( return; } - BMCWEB_LOG_DEBUG << "Image ID: " << swId; - BMCWEB_LOG_DEBUG << "Running image: " << runningImage; - BMCWEB_LOG_DEBUG << "Image purpose: " << *swInvPurpose; + BMCWEB_LOG_DEBUG("Image ID: {}", swId); + BMCWEB_LOG_DEBUG("Running image: {}", runningImage); + BMCWEB_LOG_DEBUG("Image purpose: {}", *swInvPurpose); if (populateLinkToImages) { @@ -253,7 +253,7 @@ inline resource::State getRedfishSwState(const std::string& swState) { return resource::State::StandbySpare; } - BMCWEB_LOG_DEBUG << "Default sw state " << swState << " to Disabled"; + BMCWEB_LOG_DEBUG("Default sw state {} to Disabled", swState); return resource::State::Disabled; } @@ -277,7 +277,7 @@ inline std::string getRedfishSwHealth(const std::string& swState) { return "OK"; } - BMCWEB_LOG_DEBUG << "Sw state " << swState << " to Warning"; + BMCWEB_LOG_DEBUG("Sw state {} to Warning", swState); return "Warning"; } @@ -297,7 +297,7 @@ inline void getSwStatus(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::shared_ptr<std::string>& swId, const std::string& dbusSvc) { - BMCWEB_LOG_DEBUG << "getSwStatus: swId " << *swId << " svc " << dbusSvc; + BMCWEB_LOG_DEBUG("getSwStatus: swId {} svc {}", *swId, dbusSvc); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, dbusSvc, @@ -331,7 +331,7 @@ inline void getSwStatus(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, return; } - BMCWEB_LOG_DEBUG << "getSwStatus: Activation " << *swInvActivation; + BMCWEB_LOG_DEBUG("getSwStatus: Activation {}", *swInvActivation); asyncResp->res.jsonValue["Status"]["State"] = getRedfishSwState(*swInvActivation); asyncResp->res.jsonValue["Status"]["Health"] = @@ -359,8 +359,8 @@ inline void const dbus::utility::MapperEndPoints& objPaths) { if (ec) { - BMCWEB_LOG_DEBUG << " error_code = " << ec - << " error msg = " << ec.message(); + BMCWEB_LOG_DEBUG(" error_code = {} error msg = {}", ec, + ec.message()); // System can exist with no updateable software, // so don't throw error here. return; diff --git a/redfish-core/include/utils/telemetry_utils.hpp b/redfish-core/include/utils/telemetry_utils.hpp index 58ab1c9d28..33e31f0af4 100644 --- a/redfish-core/include/utils/telemetry_utils.hpp +++ b/redfish-core/include/utils/telemetry_utils.hpp @@ -71,9 +71,9 @@ inline std::optional<IncorrectMetricUri> getChassisSensorNode( if (!parsed) { - BMCWEB_LOG_ERROR << "Failed to get chassis and sensor Node " - "from " - << uri; + BMCWEB_LOG_ERROR("Failed to get chassis and sensor Node " + "from {}", + uri); return std::make_optional<IncorrectMetricUri>({uri, uriIdx}); } @@ -101,9 +101,9 @@ inline std::optional<IncorrectMetricUri> getChassisSensorNode( continue; } - BMCWEB_LOG_ERROR << "Failed to get chassis and sensor Node " - "from " - << uri; + BMCWEB_LOG_ERROR("Failed to get chassis and sensor Node " + "from {}", + uri); return std::make_optional<IncorrectMetricUri>({uri, uriIdx}); } return std::nullopt; diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp index 17c9111b80..314ea85de3 100644 --- a/redfish-core/include/utils/time_utils.hpp +++ b/redfish-core/include/utils/time_utils.hpp @@ -93,14 +93,13 @@ inline std::optional<std::chrono::milliseconds> auto [ptr, ec] = std::from_chars(v.begin(), v.end(), ticks); if (ec != std::errc()) { - BMCWEB_LOG_ERROR << "Failed to convert string \"" << v - << "\" to decimal"; + BMCWEB_LOG_ERROR("Failed to convert string \"{}\" to decimal", v); return std::nullopt; } size_t charactersRead = static_cast<size_t>(ptr - v.data()); if (ptr >= v.end()) { - BMCWEB_LOG_ERROR << "Missing postfix"; + BMCWEB_LOG_ERROR("Missing postfix"); return std::nullopt; } if (*ptr == 'D') @@ -147,8 +146,7 @@ inline std::optional<std::chrono::milliseconds> } else if (stage > ProcessingStage::Milliseconds) { - BMCWEB_LOG_ERROR - << "Got unexpected information at end of parse"; + BMCWEB_LOG_ERROR("Got unexpected information at end of parse"); return std::nullopt; } else @@ -170,7 +168,7 @@ inline std::optional<std::chrono::milliseconds> } else { - BMCWEB_LOG_ERROR << "Unknown postfix " << *ptr; + BMCWEB_LOG_ERROR("Unknown postfix {}", *ptr); return std::nullopt; } diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp index cb469bd548..173de73e3e 100644 --- a/redfish-core/lib/account_service.hpp +++ b/redfish-core/lib/account_service.hpp @@ -211,8 +211,8 @@ inline bool // Both Redfish and WebUI Account Types are needed to PATCH if (redfishType ^ webUIType) { - BMCWEB_LOG_ERROR - << "Missing Redfish or WebUI Account Type to set redfish User Group"; + BMCWEB_LOG_ERROR( + "Missing Redfish or WebUI Account Type to set redfish User Group"); messages::strictAccountTypes(res, "AccountTypes"); return false; } @@ -243,8 +243,8 @@ inline void (accountTypes.cend() == std::find(accountTypes.cbegin(), accountTypes.cend(), "Redfish"))) { - BMCWEB_LOG_ERROR - << "User disabling OWN Redfish Account Type is not allowed"; + BMCWEB_LOG_ERROR( + "User disabling OWN Redfish Account Type is not allowed"); messages::strictAccountTypes(asyncResp->res, "AccountTypes"); return; } @@ -264,7 +264,7 @@ inline void updatedUserGroups, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -342,8 +342,7 @@ inline void parseLDAPConfigData(nlohmann::json& jsonResponse, roleMapArray = nlohmann::json::array(); for (const auto& obj : confData.groupRoleList) { - BMCWEB_LOG_DEBUG << "Pushing the data groupName=" - << obj.second.groupName << "\n"; + BMCWEB_LOG_DEBUG("Pushing the data groupName={}", obj.second.groupName); nlohmann::json::object_t remoteGroup; remoteGroup["RemoteGroup"] = obj.second.groupName; @@ -376,7 +375,7 @@ inline void handleRoleMapPatch( index](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -388,7 +387,7 @@ inline void handleRoleMapPatch( } else { - BMCWEB_LOG_ERROR << "Can't delete the object"; + BMCWEB_LOG_ERROR("Can't delete the object"); messages::propertyValueTypeError(asyncResp->res, thisJson, "RemoteRoleMapping/" + std::to_string(index)); @@ -419,7 +418,7 @@ inline void handleRoleMapPatch( // Update existing RoleMapping Object if (index < roleMapObjData.size()) { - BMCWEB_LOG_DEBUG << "Update Role Map Object"; + BMCWEB_LOG_DEBUG("Update Role Map Object"); // If "RemoteGroup" info is provided if (remoteGroup) { @@ -439,8 +438,8 @@ inline void handleRoleMapPatch( std::string_view( "xyz.openbmc_project.Common.Error.InvalidArgument"))) { - BMCWEB_LOG_WARNING << "DBUS response error: " - << ec; + BMCWEB_LOG_WARNING("DBUS response error: {}", + ec); messages::propertyValueIncorrect(asyncResp->res, "RemoteGroup", *remoteGroup); @@ -474,8 +473,8 @@ inline void handleRoleMapPatch( std::string_view( "xyz.openbmc_project.Common.Error.InvalidArgument"))) { - BMCWEB_LOG_WARNING << "DBUS response error: " - << ec; + BMCWEB_LOG_WARNING("DBUS response error: {}", + ec); messages::propertyValueIncorrect( asyncResp->res, "LocalRole", *localRole); return; @@ -492,8 +491,8 @@ inline void handleRoleMapPatch( // Create a new RoleMapping Object. else { - BMCWEB_LOG_DEBUG - << "setRoleMappingProperties: Creating new Object"; + BMCWEB_LOG_DEBUG( + "setRoleMappingProperties: Creating new Object"); std::string pathString = "RemoteRoleMapping/" + std::to_string(index); @@ -520,15 +519,15 @@ inline void handleRoleMapPatch( dbusObjectPath = ldapConfigObjectName; } - BMCWEB_LOG_DEBUG << "Remote Group=" << *remoteGroup - << ",LocalRole=" << *localRole; + BMCWEB_LOG_DEBUG("Remote Group={},LocalRole={}", *remoteGroup, + *localRole); crow::connections::systemBus->async_method_call( [asyncResp, serverType, localRole, remoteGroup](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -565,8 +564,8 @@ inline void getLDAPConfigData(const std::string& ldapType, const dbus::utility::MapperGetObject& resp) { if (ec || resp.empty()) { - BMCWEB_LOG_ERROR - << "DBUS response error during getting of service name: " << ec; + BMCWEB_LOG_ERROR( + "DBUS response error during getting of service name: {}", ec); LDAPConfigData empty{}; callback(false, empty, ldapType); return; @@ -582,7 +581,7 @@ inline void getLDAPConfigData(const std::string& ldapType, if (ec2) { callback(false, confData, ldapType); - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec2; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec2); return; } @@ -603,8 +602,8 @@ inline void getLDAPConfigData(const std::string& ldapType, } else { - BMCWEB_LOG_ERROR << "Can't get the DbusType for the given type=" - << ldapType; + BMCWEB_LOG_ERROR("Can't get the DbusType for the given type={}", + ldapType); callback(false, confData, ldapType); return; } @@ -808,8 +807,8 @@ inline void handleServiceAddressPatch( std::string_view( "xyz.openbmc_project.Common.Error.InvalidArgument"))) { - BMCWEB_LOG_WARNING - << "Error Occurred in updating the service address"; + BMCWEB_LOG_WARNING( + "Error Occurred in updating the service address"); messages::propertyValueIncorrect(asyncResp->res, "ServiceAddresses", serviceAddressList.front()); @@ -827,7 +826,7 @@ inline void handleServiceAddressPatch( messages::propertyValueModified(asyncResp->res, "ServiceAddresses", serviceAddressList.front()); } - BMCWEB_LOG_DEBUG << "Updated the service address"; + BMCWEB_LOG_DEBUG("Updated the service address"); }); } /** @@ -852,13 +851,13 @@ inline void const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "Error occurred in updating the username"; + BMCWEB_LOG_DEBUG("Error occurred in updating the username"); messages::internalError(asyncResp->res); return; } asyncResp->res.jsonValue[ldapServerElementName]["Authentication"] ["Username"] = username; - BMCWEB_LOG_DEBUG << "Updated the username"; + BMCWEB_LOG_DEBUG("Updated the username"); }); } @@ -883,13 +882,13 @@ inline void const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "Error occurred in updating the password"; + BMCWEB_LOG_DEBUG("Error occurred in updating the password"); messages::internalError(asyncResp->res); return; } asyncResp->res.jsonValue[ldapServerElementName]["Authentication"] ["Password"] = ""; - BMCWEB_LOG_DEBUG << "Updated the password"; + BMCWEB_LOG_DEBUG("Updated the password"); }); } @@ -916,7 +915,7 @@ inline void const sdbusplus::message_t& msg) { if (ec) { - BMCWEB_LOG_DEBUG << "Error Occurred in Updating the base DN"; + BMCWEB_LOG_DEBUG("Error Occurred in Updating the base DN"); const sd_bus_error* dbusError = msg.get_error(); if ((dbusError != nullptr) && (dbusError->name == @@ -941,7 +940,7 @@ inline void messages::propertyValueModified( asyncResp->res, "BaseDistinguishedNames", baseDNList.front()); } - BMCWEB_LOG_DEBUG << "Updated the base DN"; + BMCWEB_LOG_DEBUG("Updated the base DN"); }); } /** @@ -966,8 +965,8 @@ inline void ldapServerElementName](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "Error Occurred in Updating the " - "username attribute"; + BMCWEB_LOG_DEBUG("Error Occurred in Updating the " + "username attribute"); messages::internalError(asyncResp->res); return; } @@ -975,7 +974,7 @@ inline void auto& searchSettingsJson = serverTypeJson["LDAPService"]["SearchSettings"]; searchSettingsJson["UsernameAttribute"] = userNameAttribute; - BMCWEB_LOG_DEBUG << "Updated the user name attr."; + BMCWEB_LOG_DEBUG("Updated the user name attr."); }); } /** @@ -1000,8 +999,8 @@ inline void handleGroupNameAttrPatch( ldapServerElementName](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "Error Occurred in Updating the " - "groupname attribute"; + BMCWEB_LOG_DEBUG("Error Occurred in Updating the " + "groupname attribute"); messages::internalError(asyncResp->res); return; } @@ -1009,7 +1008,7 @@ inline void handleGroupNameAttrPatch( auto& searchSettingsJson = serverTypeJson["LDAPService"]["SearchSettings"]; searchSettingsJson["GroupsAttribute"] = groupsAttribute; - BMCWEB_LOG_DEBUG << "Updated the groupname attr"; + BMCWEB_LOG_DEBUG("Updated the groupname attr"); }); } /** @@ -1033,13 +1032,13 @@ inline void handleServiceEnablePatch( ldapServerElementName](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "Error Occurred in Updating the service enable"; + BMCWEB_LOG_DEBUG("Error Occurred in Updating the service enable"); messages::internalError(asyncResp->res); return; } asyncResp->res.jsonValue[ldapServerElementName]["ServiceEnabled"] = serviceEnabled; - BMCWEB_LOG_DEBUG << "Updated Service enable = " << serviceEnabled; + BMCWEB_LOG_DEBUG("Updated Service enable = {}", serviceEnabled); }); } @@ -1057,7 +1056,7 @@ inline void "Cookie", cookie, "SessionToken", sessionToken, "XToken", xToken, "TLS", tls)) { - BMCWEB_LOG_ERROR << "Cannot read values from AuthMethod tag"; + BMCWEB_LOG_ERROR("Cannot read values from AuthMethod tag"); return; } @@ -1334,7 +1333,7 @@ inline void updateUserProperties( // If password is invalid messages::propertyValueFormatError(asyncResp->res, *password, "Password"); - BMCWEB_LOG_ERROR << "pamUpdatePassword Failed"; + BMCWEB_LOG_ERROR("pamUpdatePassword Failed"); } else if (retval != PAM_SUCCESS) { @@ -1356,7 +1355,7 @@ inline void updateUserProperties( *enabled, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1381,7 +1380,7 @@ inline void updateUserProperties( priv, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1409,7 +1408,7 @@ inline void updateUserProperties( [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1506,8 +1505,8 @@ inline void return; } - BMCWEB_LOG_DEBUG << "Got " << propertiesList.size() - << "properties for AccountService"; + BMCWEB_LOG_DEBUG("Got {}properties for AccountService", + propertiesList.size()); const uint8_t* minPasswordLength = nullptr; const uint32_t* accountUnlockTimeout = nullptr; @@ -1737,7 +1736,7 @@ inline void handleAccountCollectionGet( if (user.empty()) { messages::internalError(asyncResp->res); - BMCWEB_LOG_ERROR << "Invalid firmware ID"; + BMCWEB_LOG_ERROR("Invalid firmware ID"); return; } @@ -1795,7 +1794,7 @@ inline void processAfterCreateUser( "xyz.openbmc_project.User.Manager", userPath, "xyz.openbmc_project.Object.Delete", "Delete"); - BMCWEB_LOG_ERROR << "pamUpdatePassword Failed"; + BMCWEB_LOG_ERROR("pamUpdatePassword Failed"); return; } @@ -1854,8 +1853,8 @@ inline void processAfterGetAllGroups( { if (!accountTypeUserGroups.empty()) { - BMCWEB_LOG_ERROR - << "Only administrator can get HostConsole access"; + BMCWEB_LOG_ERROR( + "Only administrator can get HostConsole access"); asyncResp->res.result(boost::beast::http::status::bad_request); return; } @@ -1921,7 +1920,7 @@ inline void handleAccountCollectionPost( const std::vector<std::string>& allGroupsList) { if (ec) { - BMCWEB_LOG_DEBUG << "ERROR with async_method_call"; + BMCWEB_LOG_DEBUG("ERROR with async_method_call"); messages::internalError(asyncResp->res); return; } @@ -1988,7 +1987,7 @@ inline void if (!effectiveUserPrivileges.isSupersetOf( requiredPermissionsToChangeNonSelf)) { - BMCWEB_LOG_DEBUG << "GET Account denied access"; + BMCWEB_LOG_DEBUG("GET Account denied access"); messages::insufficientPrivilege(asyncResp->res); return; } @@ -2039,7 +2038,7 @@ inline void std::get_if<bool>(&property.second); if (userEnabled == nullptr) { - BMCWEB_LOG_ERROR << "UserEnabled wasn't a bool"; + BMCWEB_LOG_ERROR("UserEnabled wasn't a bool"); messages::internalError(asyncResp->res); return; } @@ -2051,9 +2050,9 @@ inline void std::get_if<bool>(&property.second); if (userLocked == nullptr) { - BMCWEB_LOG_ERROR << "UserLockedForF" - "ailedAttempt " - "wasn't a bool"; + BMCWEB_LOG_ERROR("UserLockedForF" + "ailedAttempt " + "wasn't a bool"); messages::internalError(asyncResp->res); return; } @@ -2068,15 +2067,15 @@ inline void std::get_if<std::string>(&property.second); if (userPrivPtr == nullptr) { - BMCWEB_LOG_ERROR << "UserPrivilege wasn't a " - "string"; + BMCWEB_LOG_ERROR("UserPrivilege wasn't a " + "string"); messages::internalError(asyncResp->res); return; } std::string role = getRoleIdFromPrivilege(*userPrivPtr); if (role.empty()) { - BMCWEB_LOG_ERROR << "Invalid user role"; + BMCWEB_LOG_ERROR("Invalid user role"); messages::internalError(asyncResp->res); return; } @@ -2093,8 +2092,8 @@ inline void std::get_if<bool>(&property.second); if (userPasswordExpired == nullptr) { - BMCWEB_LOG_ERROR - << "UserPasswordExpired wasn't a bool"; + BMCWEB_LOG_ERROR( + "UserPasswordExpired wasn't a bool"); messages::internalError(asyncResp->res); return; } @@ -2108,14 +2107,14 @@ inline void &property.second); if (userGroups == nullptr) { - BMCWEB_LOG_ERROR - << "userGroups wasn't a string vector"; + BMCWEB_LOG_ERROR( + "userGroups wasn't a string vector"); messages::internalError(asyncResp->res); return; } if (!translateUserGroup(*userGroups, asyncResp->res)) { - BMCWEB_LOG_ERROR << "userGroups mapping failed"; + BMCWEB_LOG_ERROR("userGroups mapping failed"); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/aggregation_service.hpp b/redfish-core/lib/aggregation_service.hpp index 6c93613a34..be1336bf37 100644 --- a/redfish-core/lib/aggregation_service.hpp +++ b/redfish-core/lib/aggregation_service.hpp @@ -210,8 +210,8 @@ inline void handleAggregationSourceHead( "</redfish/v1/JsonSchemas/AggregationService/AggregationSource.json>; rel=describedby"); // Needed to prevent unused variable error - BMCWEB_LOG_DEBUG << "Added link header to response from " - << aggregationSourceId; + BMCWEB_LOG_DEBUG("Added link header to response from {}", + aggregationSourceId); } inline void requestRoutesAggregationSource(App& app) diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp index b358b5f68c..8cd05d6c15 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp @@ -89,7 +89,7 @@ inline void [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; + BMCWEB_LOG_ERROR("Failed to reset bios: {}", ec); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp index 87e41d5324..265a1ea4d5 100644 --- a/redfish-core/lib/cable.hpp +++ b/redfish-core/lib/cable.hpp @@ -30,7 +30,7 @@ inline void { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(resp); return; } @@ -83,7 +83,7 @@ inline void const std::string& cableObjectPath, const dbus::utility::MapperServiceMap& serviceMap) { - BMCWEB_LOG_DEBUG << "Get Properties for cable " << cableObjectPath; + BMCWEB_LOG_DEBUG("Get Properties for cable {}", cableObjectPath); for (const auto& [service, interfaces] : serviceMap) { @@ -121,7 +121,7 @@ inline void requestRoutesCable(App& app) { return; } - BMCWEB_LOG_DEBUG << "Cable Id: " << cableId; + BMCWEB_LOG_DEBUG("Cable Id: {}", cableId); constexpr std::array<std::string_view, 1> interfaces = { "xyz.openbmc_project.Inventory.Item.Cable"}; dbus::utility::getSubTree( @@ -137,7 +137,7 @@ inline void requestRoutesCable(App& app) if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp index 62704c9046..0073bc9e6a 100644 --- a/redfish-core/lib/certificate_service.hpp +++ b/redfish-core/lib/certificate_service.hpp @@ -70,7 +70,7 @@ inline std::string getCertificateFromReqBody( certificate, "CertificateType", certificateType)) { - BMCWEB_LOG_ERROR << "Required parameters are missing"; + BMCWEB_LOG_ERROR("Required parameters are missing"); messages::internalError(asyncResp->res); return {}; } @@ -111,22 +111,22 @@ class CertificateFile std::ofstream::trunc); out << certString; out.close(); - BMCWEB_LOG_DEBUG << "Creating certificate file" - << certificateFile.string(); + BMCWEB_LOG_DEBUG("Creating certificate file{}", + certificateFile.string()); } } ~CertificateFile() { if (std::filesystem::exists(certDirectory)) { - BMCWEB_LOG_DEBUG << "Removing certificate file" - << certificateFile.string(); + BMCWEB_LOG_DEBUG("Removing certificate file{}", + certificateFile.string()); std::error_code ec; std::filesystem::remove_all(certDirectory, ec); if (ec) { - BMCWEB_LOG_ERROR << "Failed to remove temp directory" - << certDirectory.string(); + BMCWEB_LOG_ERROR("Failed to remove temp directory{}", + certDirectory.string()); } } } @@ -228,7 +228,7 @@ static void const dbus::utility::MapperGetSubTreePathsResponse& certPaths) { if (ec) { - BMCWEB_LOG_ERROR << "Certificate collection query failed: " << ec; + BMCWEB_LOG_ERROR("Certificate collection query failed: {}", ec); messages::internalError(asyncResp->res); return; } @@ -241,7 +241,7 @@ static void std::string certId = objPath.filename(); if (certId.empty()) { - BMCWEB_LOG_ERROR << "Invalid certificate objPath " << certPath; + BMCWEB_LOG_ERROR("Invalid certificate objPath {}", certPath); continue; } @@ -294,8 +294,8 @@ static void getCertificateProperties( const std::string& certId, const boost::urls::url& certURL, const std::string& name) { - BMCWEB_LOG_DEBUG << "getCertificateProperties Path=" << objectPath - << " certId=" << certId << " certURl=" << certURL; + BMCWEB_LOG_DEBUG("getCertificateProperties Path={} certId={} certURl={}", + objectPath, certId, certURL); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, objectPath, certs::certPropIntf, [asyncResp, certURL, certId, @@ -303,7 +303,7 @@ static void getCertificateProperties( const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); messages::resourceNotFound(asyncResp->res, "Certificate", certId); return; } @@ -389,7 +389,7 @@ static void messages::resourceNotFound(asyncResp->res, "Certificate", id); return; } - BMCWEB_LOG_INFO << "Certificate deleted"; + BMCWEB_LOG_INFO("Certificate deleted"); asyncResp->res.result(boost::beast::http::status::no_content); }, service, objectPath, certs::objDeleteIntf, "Delete"); @@ -479,7 +479,7 @@ inline void handleReplaceCertificateAction( certificateUri, "CertificateType", certificateType)) { - BMCWEB_LOG_ERROR << "Required parameters are missing"; + BMCWEB_LOG_ERROR("Required parameters are missing"); return; } @@ -503,7 +503,7 @@ inline void handleReplaceCertificateAction( "CertificateUri"); return; } - BMCWEB_LOG_INFO << "Certificate URI to replace: " << certURI; + BMCWEB_LOG_INFO("Certificate URI to replace: {}", certURI); boost::urls::result<boost::urls::url_view> parsedUrl = boost::urls::parse_relative_ref(certURI); @@ -559,7 +559,7 @@ inline void handleReplaceCertificateAction( name](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); if (ec.value() == boost::system::linux_error::bad_request_descriptor) { @@ -570,8 +570,8 @@ inline void handleReplaceCertificateAction( return; } getCertificateProperties(asyncResp, objectPath, service, id, url, name); - BMCWEB_LOG_DEBUG << "HTTPS certificate install file=" - << certFile->getCertFilePath(); + BMCWEB_LOG_DEBUG("HTTPS certificate install file={}", + certFile->getCertFilePath()); }, service, objectPath, certs::certReplaceIntf, "Replace", certFile->getCertFilePath()); @@ -594,21 +594,20 @@ static void getCSR(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& certObjPath, const std::string& csrObjPath) { - BMCWEB_LOG_DEBUG << "getCSR CertObjectPath" << certObjPath - << " CSRObjectPath=" << csrObjPath - << " service=" << service; + BMCWEB_LOG_DEBUG("getCSR CertObjectPath{} CSRObjectPath={} service={}", + certObjPath, csrObjPath, service); crow::connections::systemBus->async_method_call( [asyncResp, certURI](const boost::system::error_code& ec, const std::string& csr) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); messages::internalError(asyncResp->res); return; } if (csr.empty()) { - BMCWEB_LOG_ERROR << "CSR read is empty"; + BMCWEB_LOG_ERROR("CSR read is empty"); messages::internalError(asyncResp->res); return; } @@ -793,16 +792,16 @@ inline void // before completion. if (ec != boost::asio::error::operation_aborted) { - BMCWEB_LOG_ERROR << "Async_wait failed " << ec; + BMCWEB_LOG_ERROR("Async_wait failed {}", ec); } return; } - BMCWEB_LOG_ERROR << "Timed out waiting for Generating CSR"; + BMCWEB_LOG_ERROR("Timed out waiting for Generating CSR"); messages::internalError(asyncResp->res); }); // create a matcher to wait on CSR object - BMCWEB_LOG_DEBUG << "create matcher with path " << objectPath; + BMCWEB_LOG_DEBUG("create matcher with path {}", objectPath); std::string match("type='signal'," "interface='org.freedesktop.DBus.ObjectManager'," "path='" + @@ -815,7 +814,7 @@ inline void timeout.cancel(); if (m.is_method_error()) { - BMCWEB_LOG_ERROR << "Dbus method error!!!"; + BMCWEB_LOG_ERROR("Dbus method error!!!"); messages::internalError(asyncResp->res); return; } @@ -824,7 +823,7 @@ inline void sdbusplus::message::object_path csrObjectPath; m.read(csrObjectPath, interfacesProperties); - BMCWEB_LOG_DEBUG << "CSR object added" << csrObjectPath.str; + BMCWEB_LOG_DEBUG("CSR object added{}", csrObjectPath.str); for (const auto& interface : interfacesProperties) { if (interface.first == "xyz.openbmc_project.Certs.CSR") @@ -839,7 +838,7 @@ inline void [asyncResp](const boost::system::error_code& ec, const std::string&) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec.message(); + BMCWEB_LOG_ERROR("DBUS response error: {}", ec.message()); messages::internalError(asyncResp->res); return; } @@ -909,7 +908,7 @@ inline void handleHTTPSCertificateCollectionPost( { return; } - BMCWEB_LOG_DEBUG << "HTTPSCertificateCollection::doPost"; + BMCWEB_LOG_DEBUG("HTTPSCertificateCollection::doPost"); asyncResp->res.jsonValue["Name"] = "HTTPS Certificate"; asyncResp->res.jsonValue["Description"] = "HTTPS Certificate"; @@ -918,7 +917,7 @@ inline void handleHTTPSCertificateCollectionPost( if (certFileBody.empty()) { - BMCWEB_LOG_ERROR << "Cannot get certificate from request body."; + BMCWEB_LOG_ERROR("Cannot get certificate from request body."); messages::unrecognizedRequestBody(asyncResp->res); return; } @@ -931,7 +930,7 @@ inline void handleHTTPSCertificateCollectionPost( const std::string& objectPath) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -943,8 +942,8 @@ inline void handleHTTPSCertificateCollectionPost( certId); getCertificateProperties(asyncResp, objectPath, certs::httpsServiceName, certId, certURL, "HTTPS Certificate"); - BMCWEB_LOG_DEBUG << "HTTPS certificate install file=" - << certFile->getCertFilePath(); + BMCWEB_LOG_DEBUG("HTTPS certificate install file={}", + certFile->getCertFilePath()); }, certs::httpsServiceName, certs::httpsObjectPath, certs::certInstallIntf, "Install", certFile->getCertFilePath()); @@ -959,7 +958,7 @@ inline void handleHTTPSCertificateGet( return; } - BMCWEB_LOG_DEBUG << "HTTPS Certificate ID=" << id; + BMCWEB_LOG_DEBUG("HTTPS Certificate ID={}", id); const boost::urls::url certURL = boost::urls::format( "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/{}", id); std::string objPath = @@ -1024,7 +1023,7 @@ inline void handleLDAPCertificateCollectionPost( if (certFileBody.empty()) { - BMCWEB_LOG_ERROR << "Cannot get certificate from request body."; + BMCWEB_LOG_ERROR("Cannot get certificate from request body."); messages::unrecognizedRequestBody(asyncResp->res); return; } @@ -1037,7 +1036,7 @@ inline void handleLDAPCertificateCollectionPost( const std::string& objectPath) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1048,8 +1047,8 @@ inline void handleLDAPCertificateCollectionPost( "/redfish/v1/AccountService/LDAP/Certificates/{}", certId); getCertificateProperties(asyncResp, objectPath, certs::ldapServiceName, certId, certURL, "LDAP Certificate"); - BMCWEB_LOG_DEBUG << "LDAP certificate install file=" - << certFile->getCertFilePath(); + BMCWEB_LOG_DEBUG("LDAP certificate install file={}", + certFile->getCertFilePath()); }, certs::ldapServiceName, certs::ldapObjectPath, certs::certInstallIntf, "Install", certFile->getCertFilePath()); @@ -1064,7 +1063,7 @@ inline void handleLDAPCertificateGet( return; } - BMCWEB_LOG_DEBUG << "LDAP Certificate ID=" << id; + BMCWEB_LOG_DEBUG("LDAP Certificate ID={}", id); const boost::urls::url certURL = boost::urls::format( "/redfish/v1/AccountService/LDAP/Certificates/{}", id); std::string objPath = @@ -1082,7 +1081,7 @@ inline void handleLDAPCertificateDelete( return; } - BMCWEB_LOG_DEBUG << "Delete LDAP Certificate ID=" << id; + BMCWEB_LOG_DEBUG("Delete LDAP Certificate ID={}", id); std::string objPath = sdbusplus::message::object_path(certs::ldapObjectPath) / id; @@ -1146,7 +1145,7 @@ inline void handleTrustStoreCertificateCollectionPost( if (certFileBody.empty()) { - BMCWEB_LOG_ERROR << "Cannot get certificate from request body."; + BMCWEB_LOG_ERROR("Cannot get certificate from request body."); messages::unrecognizedRequestBody(asyncResp->res); return; } @@ -1158,7 +1157,7 @@ inline void handleTrustStoreCertificateCollectionPost( const std::string& objectPath) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error: " << ec; + BMCWEB_LOG_ERROR("DBUS response error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1170,8 +1169,8 @@ inline void handleTrustStoreCertificateCollectionPost( getCertificateProperties(asyncResp, objectPath, certs::authorityServiceName, certId, certURL, "TrustStore Certificate"); - BMCWEB_LOG_DEBUG << "TrustStore certificate install file=" - << certFile->getCertFilePath(); + BMCWEB_LOG_DEBUG("TrustStore certificate install file={}", + certFile->getCertFilePath()); }, certs::authorityServiceName, certs::authorityObjectPath, certs::certInstallIntf, "Install", certFile->getCertFilePath()); @@ -1186,7 +1185,7 @@ inline void handleTrustStoreCertificateGet( return; } - BMCWEB_LOG_DEBUG << "Truststore Certificate ID=" << id; + BMCWEB_LOG_DEBUG("Truststore Certificate ID={}", id); const boost::urls::url certURL = boost::urls::format( "/redfish/v1/Managers/bmc/Truststore/Certificates/{}", id); std::string objPath = @@ -1204,7 +1203,7 @@ inline void handleTrustStoreCertificateDelete( return; } - BMCWEB_LOG_DEBUG << "Delete TrustStore Certificate ID=" << id; + BMCWEB_LOG_DEBUG("Delete TrustStore Certificate ID={}", id); std::string objPath = sdbusplus::message::object_path(certs::authorityObjectPath) / id; diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp index fc89d0356a..fbab894de3 100644 --- a/redfish-core/lib/chassis.hpp +++ b/redfish-core/lib/chassis.hpp @@ -62,7 +62,7 @@ inline void getStorageLink(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::vector<std::string>& storageList) { if (ec) { - BMCWEB_LOG_DEBUG << "getStorageLink got DBUS response error"; + BMCWEB_LOG_DEBUG("getStorageLink got DBUS response error"); return; } @@ -109,15 +109,15 @@ inline void getChassisState(std::shared_ptr<bmcweb::AsyncResp> asyncResp) { // Service not available, no error, just don't return // chassis state info - BMCWEB_LOG_DEBUG << "Service not available " << ec; + BMCWEB_LOG_DEBUG("Service not available {}", ec); return; } - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Chassis state: " << chassisState; + BMCWEB_LOG_DEBUG("Chassis state: {}", chassisState); // Verify Chassis State if (chassisState == "xyz.openbmc_project.State.Chassis.PowerState.On") { @@ -137,7 +137,7 @@ inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_DEBUG << "Get intrusion status by service \n"; + BMCWEB_LOG_DEBUG("Get intrusion status by service "); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, service, objPath, @@ -148,7 +148,7 @@ inline void getIntrusionByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, { // do not add err msg in redfish response, because this is not // mandatory property - BMCWEB_LOG_ERROR << "DBUS response error " << ec << "\n"; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); return; } @@ -175,7 +175,7 @@ inline void { // do not add err msg in redfish response, because this is not // mandatory property - BMCWEB_LOG_INFO << "DBUS error: no matched iface " << ec << "\n"; + BMCWEB_LOG_INFO("DBUS error: no matched iface {}", ec); return; } // Iterate over all retrieved ObjectPaths. @@ -220,7 +220,7 @@ inline void getChassisContainedBy( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); } return; @@ -231,7 +231,7 @@ inline void getChassisContainedBy( } if (upstreamChassisPaths.size() > 1) { - BMCWEB_LOG_ERROR << chassisId << " is contained by mutliple chassis"; + BMCWEB_LOG_ERROR("{} is contained by mutliple chassis", chassisId); messages::internalError(asyncResp->res); return; } @@ -241,8 +241,8 @@ inline void getChassisContainedBy( std::string upstreamChassis = upstreamChassisPath.filename(); if (upstreamChassis.empty()) { - BMCWEB_LOG_WARNING << "Malformed upstream Chassis path " - << upstreamChassisPath.str << " on " << chassisId; + BMCWEB_LOG_WARNING("Malformed upstream Chassis path {} on {}", + upstreamChassisPath.str, chassisId); return; } @@ -259,7 +259,7 @@ inline void getChassisContains( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); } return; @@ -280,9 +280,8 @@ inline void getChassisContains( std::string downstreamChassis = downstreamChassisPath.filename(); if (downstreamChassis.empty()) { - BMCWEB_LOG_WARNING << "Malformed downstream Chassis path " - << downstreamChassisPath.str << " on " - << chassisId; + BMCWEB_LOG_WARNING("Malformed downstream Chassis path {} on {}", + downstreamChassisPath.str, chassisId); continue; } nlohmann::json link; @@ -298,7 +297,7 @@ inline void const std::string& chassisId, const std::string& chassisPath) { - BMCWEB_LOG_DEBUG << "Get chassis connectivity"; + BMCWEB_LOG_DEBUG("Get chassis connectivity"); dbus::utility::getAssociationEndPoints( chassisPath + "/contained_by", @@ -333,7 +332,7 @@ inline void const std::string& property) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error for Location"; + BMCWEB_LOG_ERROR("DBUS response error for Location"); messages::internalError(asyncResp->res); return; } @@ -354,7 +353,7 @@ inline void getChassisUUID(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& chassisUUID) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error for UUID"; + BMCWEB_LOG_ERROR("DBUS response error for UUID"); messages::internalError(asyncResp->res); return; } @@ -382,7 +381,7 @@ inline void const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -424,7 +423,7 @@ inline void if (connectionNames.empty()) { - BMCWEB_LOG_ERROR << "Got 0 Connection names"; + BMCWEB_LOG_ERROR("Got 0 Connection names"); continue; } @@ -484,8 +483,8 @@ inline void const std::string& property) { if (ec2) { - BMCWEB_LOG_ERROR - << "DBus response error for AssetTag: " << ec2; + BMCWEB_LOG_ERROR( + "DBus response error for AssetTag: {}", ec2); messages::internalError(asyncResp->res); return; } @@ -502,9 +501,9 @@ inline void const bool property) { if (ec2) { - BMCWEB_LOG_ERROR - << "DBus response error for HotPluggable: " - << ec2; + BMCWEB_LOG_ERROR( + "DBus response error for HotPluggable: {}", + ec2); messages::internalError(asyncResp->res); return; } @@ -693,7 +692,7 @@ inline void const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -716,7 +715,7 @@ inline void if (connectionNames.empty()) { - BMCWEB_LOG_ERROR << "Got 0 Connection names"; + BMCWEB_LOG_ERROR("Got 0 Connection names"); continue; } @@ -793,7 +792,7 @@ inline void handleChassisPowerCycleError(const boost::system::error_code& ec, { if (eMsg.get_error() == nullptr) { - BMCWEB_LOG_ERROR << "D-Bus response error: " << ec; + BMCWEB_LOG_ERROR("D-Bus response error: {}", ec); messages::internalError(res); return; } @@ -804,13 +803,13 @@ inline void handleChassisPowerCycleError(const boost::system::error_code& ec, if (errorMessage == std::string_view("xyz.openbmc_project.State.Chassis.Error.BMCNotReady")) { - BMCWEB_LOG_DEBUG << "BMC not ready, operation not allowed right now"; + BMCWEB_LOG_DEBUG("BMC not ready, operation not allowed right now"); messages::serviceTemporarilyUnavailable(res, "10"); return; } - BMCWEB_LOG_ERROR << "Chassis Power Cycle fail " << ec - << " sdbusplus:" << errorMessage; + BMCWEB_LOG_ERROR("Chassis Power Cycle fail {} sdbusplus:{}", ec, + errorMessage); messages::internalError(res); } @@ -828,7 +827,7 @@ inline void const dbus::utility::MapperGetSubTreePathsResponse& chassisList) { if (ec) { - BMCWEB_LOG_ERROR << "[mapper] Bad D-Bus request error: " << ec; + BMCWEB_LOG_ERROR("[mapper] Bad D-Bus request error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -877,7 +876,7 @@ inline void handleChassisResetActionInfoPost( { return; } - BMCWEB_LOG_DEBUG << "Post Chassis Reset."; + BMCWEB_LOG_DEBUG("Post Chassis Reset."); std::string resetType; @@ -888,8 +887,7 @@ inline void handleChassisResetActionInfoPost( if (resetType != "PowerCycle") { - BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: " - << resetType; + BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}", resetType); messages::actionParameterNotSupported(asyncResp->res, resetType, "ResetType"); diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 36873b9108..218affef39 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -499,9 +499,9 @@ inline void extractIPV6Data(const std::string& ethifaceId, } else { - BMCWEB_LOG_ERROR - << "Got extra property: " << property.first - << " on the " << objpath.first.str << " object"; + BMCWEB_LOG_ERROR( + "Got extra property: {} on the {} object", + property.first, objpath.first.str); } } } @@ -593,9 +593,9 @@ inline void extractIPData(const std::string& ethifaceId, } else { - BMCWEB_LOG_ERROR - << "Got extra property: " << property.first - << " on the " << objpath.first.str << " object"; + BMCWEB_LOG_ERROR( + "Got extra property: {} on the {} object", + property.first, objpath.first.str); } } // Check if given address is local, or global @@ -1047,7 +1047,7 @@ inline void setDHCPEnabled(const std::string& ifaceId, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1066,7 +1066,7 @@ inline void setEthernetInterfaceBoolProperty( [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1076,7 +1076,7 @@ inline void setEthernetInterfaceBoolProperty( inline void setDHCPv4Config(const std::string& propertyName, const bool& value, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << propertyName << " = " << value; + BMCWEB_LOG_DEBUG("{} = {}", propertyName, value); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/dhcp", @@ -1084,7 +1084,7 @@ inline void setDHCPv4Config(const std::string& propertyName, const bool& value, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1191,14 +1191,14 @@ inline void handleDHCPPatch(const std::string& ifaceId, nextUseDomain = ethData.hostNameEnabled; } - BMCWEB_LOG_DEBUG << "set DHCPEnabled..."; + BMCWEB_LOG_DEBUG("set DHCPEnabled..."); setDHCPEnabled(ifaceId, "DHCPEnabled", nextv4DHCPState, nextv6DHCPState, asyncResp); - BMCWEB_LOG_DEBUG << "set DNSEnabled..."; + BMCWEB_LOG_DEBUG("set DNSEnabled..."); setDHCPv4Config("DNSEnabled", nextDNS, asyncResp); - BMCWEB_LOG_DEBUG << "set NTPEnabled..."; + BMCWEB_LOG_DEBUG("set NTPEnabled..."); setDHCPv4Config("NTPEnabled", nextNTP, asyncResp); - BMCWEB_LOG_DEBUG << "set HostNameEnabled..."; + BMCWEB_LOG_DEBUG("set HostNameEnabled..."); setDHCPv4Config("HostNameEnabled", nextUseDomain, asyncResp); } @@ -1707,7 +1707,7 @@ inline void afterDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "DBus error: " << dbusError->name; + BMCWEB_LOG_DEBUG("DBus error: {}", dbusError->name); if (std::string_view("org.freedesktop.DBus.Error.UnknownObject") == dbusError->name) @@ -1741,7 +1741,7 @@ inline void afterVlanCreate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "DBus error: " << dbusError->name; + BMCWEB_LOG_DEBUG("DBus error: {}", dbusError->name); if (std::string_view( "xyz.openbmc_project.Common.Error.ResourceNotFound") == @@ -1856,7 +1856,7 @@ inline void requestEthernetInterfacesRoutes(App& app) "Links/RelatedInterfaces/0/@odata.id"); return; } - BMCWEB_LOG_INFO << "Parent Interface URI: " << parentInterfaceUri; + BMCWEB_LOG_INFO("Parent Interface URI: {}", parentInterfaceUri); boost::urls::result<boost::urls::url_view> parsedUri = boost::urls::parse_relative_ref(parentInterfaceUri); diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp index 4919dece59..35e3a1cfb9 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -198,7 +198,7 @@ inline void doSubscriptionCollection( return; } - BMCWEB_LOG_ERROR << "D-Bus response error on GetManagedObjects " << ec; + BMCWEB_LOG_ERROR("D-Bus response error on GetManagedObjects {}", ec); messages::internalError(asyncResp->res); return; } @@ -209,7 +209,7 @@ inline void doSubscriptionCollection( const std::string snmpId = path.filename(); if (snmpId.empty()) { - BMCWEB_LOG_ERROR << "The SNMP client ID is wrong"; + BMCWEB_LOG_ERROR("The SNMP client ID is wrong"); messages::internalError(asyncResp->res); return; } @@ -324,8 +324,7 @@ inline void requestRoutesEventDestinationCollection(App& app) if (!crow::utility::validateAndSplitUrl(destUrl, urlProto, host, port, path)) { - BMCWEB_LOG_WARNING - << "Failed to validate and split destination url"; + BMCWEB_LOG_WARNING("Failed to validate and split destination url"); messages::propertyValueFormatError(asyncResp->res, destUrl, "Destination"); return; diff --git a/redfish-core/lib/eventservice_sse.hpp b/redfish-core/lib/eventservice_sse.hpp index 864383c201..4ad29a6707 100644 --- a/redfish-core/lib/eventservice_sse.hpp +++ b/redfish-core/lib/eventservice_sse.hpp @@ -13,7 +13,7 @@ inline void createSubscription(crow::sse_socket::Connection& conn) if ((manager.getNumberOfSubscriptions() >= maxNoOfSubscriptions) || manager.getNumberOfSSESubscriptions() >= maxNoOfSSESubscriptions) { - BMCWEB_LOG_WARNING << "Max SSE subscriptions reached"; + BMCWEB_LOG_WARNING("Max SSE subscriptions reached"); conn.close("Max SSE subscriptions reached"); return; } diff --git a/redfish-core/lib/fabric_adapters.hpp b/redfish-core/lib/fabric_adapters.hpp index d3119d3404..2a85f42d2c 100644 --- a/redfish-core/lib/fabric_adapters.hpp +++ b/redfish-core/lib/fabric_adapters.hpp @@ -33,7 +33,7 @@ inline void handleAdapterError(const boost::system::error_code& ec, return; } - BMCWEB_LOG_ERROR << "DBus method call failed with error " << ec.value(); + BMCWEB_LOG_ERROR("DBus method call failed with error {}", ec.value()); messages::internalError(res); } @@ -50,7 +50,7 @@ inline void getFabricAdapterLocation( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Location"; + BMCWEB_LOG_ERROR("DBUS response error for Location"); messages::internalError(asyncResp->res); } return; @@ -76,7 +76,7 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Properties"; + BMCWEB_LOG_ERROR("DBUS response error for Properties"); messages::internalError(asyncResp->res); } return; @@ -133,7 +133,7 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for State"; + BMCWEB_LOG_ERROR("DBUS response error for State"); messages::internalError(asyncResp->res); } return; @@ -160,7 +160,7 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Health"; + BMCWEB_LOG_ERROR("DBUS response error for Health"); messages::internalError(asyncResp->res); } return; @@ -240,7 +240,7 @@ inline void getValidFabricAdapterPath( return; } } - BMCWEB_LOG_WARNING << "Adapter not found"; + BMCWEB_LOG_WARNING("Adapter not found"); messages::resourceNotFound(asyncResp->res, "FabricAdapter", adapterId); }); } diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp index 76805315d3..3a7e2e2510 100644 --- a/redfish-core/lib/fan.hpp +++ b/redfish-core/lib/fan.hpp @@ -68,9 +68,9 @@ inline void getFanPaths( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR - << "DBUS response error for getAssociatedSubTreePaths " - << ec.value(); + BMCWEB_LOG_ERROR( + "DBUS response error for getAssociatedSubTreePaths {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -185,8 +185,8 @@ static inline void handleFanPath( const dbus::utility::MapperGetObject& object) { if (ec || object.empty()) { - BMCWEB_LOG_ERROR << "DBUS response error on getDbusObject " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error on getDbusObject {}", + ec.value()); messages::internalError(asyncResp->res); return; } @@ -195,7 +195,7 @@ static inline void handleFanPath( return; } - BMCWEB_LOG_WARNING << "Fan not found " << fanId; + BMCWEB_LOG_WARNING("Fan not found {}", fanId); messages::resourceNotFound(asyncResp->res, "Fan", fanId); } @@ -239,8 +239,8 @@ inline void getFanHealth(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Health " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Health {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -264,8 +264,8 @@ inline void getFanState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for State " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for State {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -291,8 +291,8 @@ inline void getFanAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Properties" - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Properties{}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -348,8 +348,8 @@ inline void getFanLocation(const std::shared_ptr<bmcweb::AsyncResp>& aResp, { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Location" - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Location{}", + ec.value()); messages::internalError(aResp->res); } return; diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp index c5249f202e..55f79bc4bc 100644 --- a/redfish-core/lib/health.hpp +++ b/redfish-core/lib/health.hpp @@ -114,8 +114,8 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> std::get_if<std::vector<std::string>>(&value); if (endpoints == nullptr) { - BMCWEB_LOG_ERROR << "Illegal association at " - << path.str; + BMCWEB_LOG_ERROR("Illegal association at {}", + path.str); continue; } bool containsChild = false; diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp index 72d02b9f5b..0a8936d1d7 100644 --- a/redfish-core/lib/hypervisor_system.hpp +++ b/redfish-core/lib/hypervisor_system.hpp @@ -34,7 +34,7 @@ namespace redfish inline void getHypervisorState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get hypervisor state information."; + BMCWEB_LOG_DEBUG("Get hypervisor state information."); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, "xyz.openbmc_project.State.Hypervisor", "/xyz/openbmc_project/state/hypervisor0", @@ -43,13 +43,13 @@ inline void const std::string& hostState) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); // This is an optional D-Bus object so just return if // error occurs return; } - BMCWEB_LOG_DEBUG << "Hypervisor state: " << hostState; + BMCWEB_LOG_DEBUG("Hypervisor state: {}", hostState); // Verify Host State if (hostState == "xyz.openbmc_project.State.Host.HostState.Running") { @@ -106,7 +106,7 @@ inline void inline void getHypervisorActions(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get hypervisor actions."; + BMCWEB_LOG_DEBUG("Get hypervisor actions."); constexpr std::array<std::string_view, 1> interfaces = { "xyz.openbmc_project.State.Host"}; dbus::utility::getDbusObject( @@ -117,7 +117,7 @@ inline void objInfo) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); // This is an optional D-Bus object so just return if // error occurs return; @@ -259,9 +259,9 @@ inline bool extractHypervisorInterfaceData( } else { - BMCWEB_LOG_ERROR - << "Got extra property: " << property.first - << " on the " << objpath.first.str << " object"; + BMCWEB_LOG_ERROR( + "Got extra property: {} on the {} object", + property.first, objpath.first.str); } } } @@ -330,7 +330,7 @@ void getHypervisorIfaceData(const std::string& ethIfaceId, ipv4Data); if (!found) { - BMCWEB_LOG_INFO << "Hypervisor Interface not found"; + BMCWEB_LOG_INFO("Hypervisor Interface not found"); } callback(found, ethData, ipv4Data); }); @@ -349,8 +349,8 @@ inline void setHypervisorIPv4Address( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& ethIfaceId, const std::string& ipv4Address) { - BMCWEB_LOG_DEBUG << "Setting the Hypervisor IPaddress : " << ipv4Address - << " on Iface: " << ethIfaceId; + BMCWEB_LOG_DEBUG("Setting the Hypervisor IPaddress : {} on Iface: {}", + ipv4Address, ethIfaceId); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Settings", "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId + "/ipv4/addr0", @@ -358,10 +358,10 @@ inline void setHypervisorIPv4Address( [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); return; } - BMCWEB_LOG_DEBUG << "Hypervisor IPaddress is Set"; + BMCWEB_LOG_DEBUG("Hypervisor IPaddress is Set"); }); } @@ -378,8 +378,8 @@ inline void setHypervisorIPv4Subnet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& ethIfaceId, const uint8_t subnet) { - BMCWEB_LOG_DEBUG << "Setting the Hypervisor subnet : " << subnet - << " on Iface: " << ethIfaceId; + BMCWEB_LOG_DEBUG("Setting the Hypervisor subnet : {} on Iface: {}", subnet, + ethIfaceId); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -388,10 +388,10 @@ inline void [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); return; } - BMCWEB_LOG_DEBUG << "SubnetMask is Set"; + BMCWEB_LOG_DEBUG("SubnetMask is Set"); }); } @@ -408,8 +408,8 @@ inline void setHypervisorIPv4Gateway( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& gateway) { - BMCWEB_LOG_DEBUG - << "Setting the DefaultGateway to the last configured gateway"; + BMCWEB_LOG_DEBUG( + "Setting the DefaultGateway to the last configured gateway"); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -418,10 +418,10 @@ inline void setHypervisorIPv4Gateway( gateway, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); return; } - BMCWEB_LOG_DEBUG << "Default Gateway is Set"; + BMCWEB_LOG_DEBUG("Default Gateway is Set"); }); } @@ -515,7 +515,7 @@ inline void setDHCPEnabled(const std::string& ifaceId, bool ipv4DHCPEnabled, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -542,11 +542,11 @@ inline void setDHCPEnabled(const std::string& ifaceId, bool ipv4DHCPEnabled, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Hypervisor IPaddress Origin is Set"; + BMCWEB_LOG_DEBUG("Hypervisor IPaddress Origin is Set"); }); } @@ -637,8 +637,8 @@ inline void handleHypervisorIPv4StaticPatch( return; } - BMCWEB_LOG_DEBUG << "Calling createHypervisorIPv4 on : " << ifaceId - << "," << *address; + BMCWEB_LOG_DEBUG("Calling createHypervisorIPv4 on : {},{}", ifaceId, + *address); createHypervisorIPv4(ifaceId, prefixLength, *gateway, *address, asyncResp); // Set the DHCPEnabled to false since the Static IPv4 is set @@ -786,7 +786,7 @@ inline void handleHypervisorSystemGet( messages::resourceNotFound(asyncResp->res, "System", "hypervisor"); return; } - BMCWEB_LOG_DEBUG << "Hypervisor is available"; + BMCWEB_LOG_DEBUG("Hypervisor is available"); asyncResp->res.jsonValue["@odata.type"] = "#ComputerSystem.v1_6_0.ComputerSystem"; @@ -888,8 +888,8 @@ inline void handleHypervisorEthernetInterfacePatch( if ((ipv4Json.is_null()) && (translateDhcpEnabledToBool(ethData.dhcpEnabled, true))) { - BMCWEB_LOG_INFO << "Ignoring the delete on ipv4StaticAddresses " - "as the interface is DHCP enabled"; + BMCWEB_LOG_INFO("Ignoring the delete on ipv4StaticAddresses " + "as the interface is DHCP enabled"); } else { @@ -929,7 +929,7 @@ inline void handleHypervisorResetActionGet( objInfo) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); // No hypervisor objects found by mapper if (ec.value() == boost::system::errc::io_error) @@ -1012,7 +1012,7 @@ inline void handleHypervisorSystemResetPost( [asyncResp, resetType](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); if (ec.value() == boost::asio::error::invalid_argument) { messages::actionParameterNotSupported(asyncResp->res, diff --git a/redfish-core/lib/led.hpp b/redfish-core/lib/led.hpp index 53df1db83b..f36a319677 100644 --- a/redfish-core/lib/led.hpp +++ b/redfish-core/lib/led.hpp @@ -35,7 +35,7 @@ namespace redfish inline void getIndicatorLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get led groups"; + BMCWEB_LOG_DEBUG("Get led groups"); sdbusplus::asio::getProperty<bool>( *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager", "/xyz/openbmc_project/led/groups/enclosure_identify_blink", @@ -45,8 +45,8 @@ inline void // proceed to get enclosure_identify state. if (ec == boost::system::errc::invalid_argument) { - BMCWEB_LOG_DEBUG - << "Get identity blinking LED failed, missmatch in property type"; + BMCWEB_LOG_DEBUG( + "Get identity blinking LED failed, missmatch in property type"); messages::internalError(asyncResp->res); return; } @@ -67,8 +67,8 @@ inline void const bool ledOn) { if (ec2 == boost::system::errc::invalid_argument) { - BMCWEB_LOG_DEBUG - << "Get enclosure identity led failed, missmatch in property type"; + BMCWEB_LOG_DEBUG( + "Get enclosure identity led failed, missmatch in property type"); messages::internalError(asyncResp->res); return; } @@ -103,7 +103,7 @@ inline void setIndicatorLedState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& ledState) { - BMCWEB_LOG_DEBUG << "Set led groups"; + BMCWEB_LOG_DEBUG("Set led groups"); bool ledOn = false; bool ledBlinkng = false; @@ -146,7 +146,7 @@ inline void [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -165,7 +165,7 @@ inline void inline void getLocationIndicatorActive( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get LocationIndicatorActive"; + BMCWEB_LOG_DEBUG("Get LocationIndicatorActive"); sdbusplus::asio::getProperty<bool>( *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager", "/xyz/openbmc_project/led/groups/enclosure_identify_blink", @@ -175,8 +175,8 @@ inline void getLocationIndicatorActive( // proceed to get enclosure_identify state. if (ec == boost::system::errc::invalid_argument) { - BMCWEB_LOG_DEBUG - << "Get identity blinking LED failed, missmatch in property type"; + BMCWEB_LOG_DEBUG( + "Get identity blinking LED failed, missmatch in property type"); messages::internalError(asyncResp->res); return; } @@ -197,8 +197,8 @@ inline void getLocationIndicatorActive( const bool ledOn) { if (ec2 == boost::system::errc::invalid_argument) { - BMCWEB_LOG_DEBUG - << "Get enclosure identity led failed, missmatch in property type"; + BMCWEB_LOG_DEBUG( + "Get enclosure identity led failed, missmatch in property type"); messages::internalError(asyncResp->res); return; } @@ -224,7 +224,7 @@ inline void getLocationIndicatorActive( inline void setLocationIndicatorActive( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const bool ledState) { - BMCWEB_LOG_DEBUG << "Set LocationIndicatorActive"; + BMCWEB_LOG_DEBUG("Set LocationIndicatorActive"); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager", @@ -244,7 +244,7 @@ inline void setLocationIndicatorActive( [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 72930cc79f..9cb1fe0580 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -159,8 +159,7 @@ inline static bool getEntryTimestamp(sd_journal* journal, ret = sd_journal_get_realtime_usec(journal, ×tamp); if (ret < 0) { - BMCWEB_LOG_ERROR << "Failed to read entry timestamp: " - << strerror(-ret); + BMCWEB_LOG_ERROR("Failed to read entry timestamp: {}", strerror(-ret)); return false; } entryTimestamp = redfish::time_utils::getDateTimeUintUs(timestamp); @@ -183,8 +182,7 @@ inline static bool getUniqueEntryID(sd_journal* journal, std::string& entryID, ret = sd_journal_get_realtime_usec(journal, &curTs); if (ret < 0) { - BMCWEB_LOG_ERROR << "Failed to read entry timestamp: " - << strerror(-ret); + BMCWEB_LOG_ERROR("Failed to read entry timestamp: {}", strerror(-ret)); return false; } // If the timestamp isn't unique, increment the index @@ -448,8 +446,8 @@ static std::string getDumpEntriesPath(const std::string& dumpType) } else { - BMCWEB_LOG_ERROR << "getDumpEntriesPath() invalid dump type: " - << dumpType; + BMCWEB_LOG_ERROR("getDumpEntriesPath() invalid dump type: {}", + dumpType); } // Returns empty string on error @@ -475,7 +473,7 @@ inline void const dbus::utility::ManagedObjectType& objects) { if (ec) { - BMCWEB_LOG_ERROR << "DumpEntry resp_handler got error " << ec; + BMCWEB_LOG_ERROR("DumpEntry resp_handler got error {}", ec); messages::internalError(asyncResp->res); return; } @@ -592,7 +590,7 @@ inline void const dbus::utility::ManagedObjectType& resp) { if (ec) { - BMCWEB_LOG_ERROR << "DumpEntry resp_handler got error " << ec; + BMCWEB_LOG_ERROR("DumpEntry resp_handler got error {}", ec); messages::internalError(asyncResp->res); return; } @@ -665,7 +663,7 @@ inline void } if (!foundDumpEntry) { - BMCWEB_LOG_WARNING << "Can't find Dump Entry " << entryID; + BMCWEB_LOG_WARNING("Can't find Dump Entry {}", entryID); messages::resourceNotFound(asyncResp->res, dumpType + " dump", entryID); return; @@ -679,7 +677,7 @@ inline void deleteDumpEntry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { auto respHandler = [asyncResp, entryID](const boost::system::error_code& ec) { - BMCWEB_LOG_DEBUG << "Dump Entry doDelete callback: Done"; + BMCWEB_LOG_DEBUG("Dump Entry doDelete callback: Done"); if (ec) { if (ec.value() == EBADR) @@ -687,8 +685,9 @@ inline void deleteDumpEntry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, messages::resourceNotFound(asyncResp->res, "LogEntry", entryID); return; } - BMCWEB_LOG_ERROR << "Dump (DBus) doDelete respHandler got error " - << ec << " entryID=" << entryID; + BMCWEB_LOG_ERROR( + "Dump (DBus) doDelete respHandler got error {} entryID={}", ec, + entryID); messages::internalError(asyncResp->res); return; } @@ -728,7 +727,7 @@ inline DumpCreationProgress const std::string* value = std::get_if<std::string>(&val); if (value == nullptr) { - BMCWEB_LOG_ERROR << "Status property value is null"; + BMCWEB_LOG_ERROR("Status property value is null"); return DumpCreationProgress::DUMP_CREATE_FAILED; } return mapDbusStatusToDumpProgress(*value); @@ -762,7 +761,7 @@ inline void createDumpTaskCallback( if (dumpEntryPath.empty()) { - BMCWEB_LOG_ERROR << "Invalid dump type received"; + BMCWEB_LOG_ERROR("Invalid dump type received"); messages::internalError(asyncResp->res); return; } @@ -774,8 +773,8 @@ inline void createDumpTaskCallback( const std::string& introspectXml) { if (ec) { - BMCWEB_LOG_ERROR << "Introspect call failed with error: " - << ec.message(); + BMCWEB_LOG_ERROR("Introspect call failed with error: {}", + ec.message()); messages::internalError(asyncResp->res); return; } @@ -790,7 +789,7 @@ inline void createDumpTaskCallback( tinyxml2::XMLNode* pRoot = doc.FirstChildElement("node"); if (pRoot == nullptr) { - BMCWEB_LOG_ERROR << "XML document failed to parse"; + BMCWEB_LOG_ERROR("XML document failed to parse"); messages::internalError(asyncResp->res); return; } @@ -822,8 +821,8 @@ inline void createDumpTaskCallback( const std::shared_ptr<task::TaskData>& taskData) { if (ec2) { - BMCWEB_LOG_ERROR << createdObjPath.str - << ": Error in creating dump"; + BMCWEB_LOG_ERROR("{}: Error in creating dump", + createdObjPath.str); taskData->messages.emplace_back(messages::internalError()); taskData->state = "Cancelled"; return task::completed; @@ -839,16 +838,16 @@ inline void createDumpTaskCallback( getDumpCompletionStatus(values); if (dumpStatus == DumpCreationProgress::DUMP_CREATE_FAILED) { - BMCWEB_LOG_ERROR << createdObjPath.str - << ": Error in creating dump"; + BMCWEB_LOG_ERROR("{}: Error in creating dump", + createdObjPath.str); taskData->state = "Cancelled"; return task::completed; } if (dumpStatus == DumpCreationProgress::DUMP_CREATE_INPROGRESS) { - BMCWEB_LOG_DEBUG << createdObjPath.str - << ": Dump creation task is in progress"; + BMCWEB_LOG_DEBUG("{}: Dump creation task is in progress", + createdObjPath.str); return !task::completed; } } @@ -864,8 +863,8 @@ inline void createDumpTaskCallback( taskData->payload->httpHeaders.emplace_back(std::move(headerLoc)); - BMCWEB_LOG_DEBUG << createdObjPath.str - << ": Dump creation task completed"; + BMCWEB_LOG_DEBUG("{}: Dump creation task completed", + createdObjPath.str); taskData->state = "Completed"; return task::completed; }, @@ -907,8 +906,8 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { if (!oemDiagnosticDataType || !diagnosticDataType) { - BMCWEB_LOG_ERROR - << "CreateDump action parameter 'DiagnosticDataType'/'OEMDiagnosticDataType' value not found!"; + BMCWEB_LOG_ERROR( + "CreateDump action parameter 'DiagnosticDataType'/'OEMDiagnosticDataType' value not found!"); messages::actionParameterMissing( asyncResp->res, "CollectDiagnosticData", "DiagnosticDataType & OEMDiagnosticDataType"); @@ -917,7 +916,7 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, if ((*oemDiagnosticDataType != "System") || (*diagnosticDataType != "OEM")) { - BMCWEB_LOG_ERROR << "Wrong parameter values passed"; + BMCWEB_LOG_ERROR("Wrong parameter values passed"); messages::internalError(asyncResp->res); return; } @@ -927,16 +926,16 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { if (!diagnosticDataType) { - BMCWEB_LOG_ERROR - << "CreateDump action parameter 'DiagnosticDataType' not found!"; + BMCWEB_LOG_ERROR( + "CreateDump action parameter 'DiagnosticDataType' not found!"); messages::actionParameterMissing( asyncResp->res, "CollectDiagnosticData", "DiagnosticDataType"); return; } if (*diagnosticDataType != "Manager") { - BMCWEB_LOG_ERROR - << "Wrong parameter value passed for 'DiagnosticDataType'"; + BMCWEB_LOG_ERROR( + "Wrong parameter value passed for 'DiagnosticDataType'"); messages::internalError(asyncResp->res); return; } @@ -944,7 +943,7 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } else { - BMCWEB_LOG_ERROR << "CreateDump failed. Unknown dump type"; + BMCWEB_LOG_ERROR("CreateDump failed. Unknown dump type"); messages::internalError(asyncResp->res); return; } @@ -969,7 +968,7 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const sdbusplus::message::object_path& objPath) mutable { if (ec) { - BMCWEB_LOG_ERROR << "CreateDump resp_handler got error " << ec; + BMCWEB_LOG_ERROR("CreateDump resp_handler got error {}", ec); const sd_bus_error* dbusError = msg.get_error(); if (dbusError == nullptr) { @@ -977,8 +976,8 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, return; } - BMCWEB_LOG_ERROR << "CreateDump DBus error: " << dbusError->name - << " and error msg: " << dbusError->message; + BMCWEB_LOG_ERROR("CreateDump DBus error: {} and error msg: {}", + dbusError->name, dbusError->message); if (std::string_view( "xyz.openbmc_project.Common.Error.NotAllowed") == dbusError->name) @@ -1010,7 +1009,7 @@ inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Dump Created. Path: " << objPath.str; + BMCWEB_LOG_DEBUG("Dump Created. Path: {}", objPath.str); createDumpTaskCallback(std::move(payload), asyncResp, objPath); }, "xyz.openbmc_project.Dump.Manager", @@ -1029,7 +1028,7 @@ inline void clearDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "clearDump resp_handler got error " << ec; + BMCWEB_LOG_ERROR("clearDump resp_handler got error {}", ec); messages::internalError(asyncResp->res); return; } @@ -1148,7 +1147,7 @@ inline void requestRoutesSystemLogServiceCollection(App& app) subtreePath) { if (ec) { - BMCWEB_LOG_ERROR << ec; + BMCWEB_LOG_ERROR("{}", ec); return; } @@ -1252,7 +1251,7 @@ inline void requestRoutesJournalEventLogClear(App& app) [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Failed to reload rsyslog: " << ec; + BMCWEB_LOG_ERROR("Failed to reload rsyslog: {}", ec); messages::internalError(asyncResp->res); return; } @@ -1309,7 +1308,7 @@ static LogParseError logEntryIter++; if (message == nullptr) { - BMCWEB_LOG_WARNING << "Log entry not found in registry: " << logEntry; + BMCWEB_LOG_WARNING("Log entry not found in registry: {}", logEntry); return LogParseError::messageIdNotInRegistry; } @@ -1584,8 +1583,8 @@ inline void requestRoutesDBusEventLogEntryCollection(App& app) if (ec) { // TODO Handle for specific error code - BMCWEB_LOG_ERROR - << "getLogEntriesIfaceData resp_handler got error " << ec; + BMCWEB_LOG_ERROR( + "getLogEntriesIfaceData resp_handler got error {}", ec); messages::internalError(asyncResp->res); return; } @@ -1781,8 +1780,8 @@ inline void requestRoutesDBusEventLogEntry(App& app) } if (ec) { - BMCWEB_LOG_ERROR - << "EventLogEntry (DBus) resp_handler got error " << ec; + BMCWEB_LOG_ERROR( + "EventLogEntry (DBus) resp_handler got error {}", ec); messages::internalError(asyncResp->res); return; } @@ -1883,7 +1882,7 @@ inline void requestRoutesDBusEventLogEntry(App& app) { return; } - BMCWEB_LOG_DEBUG << "Set Resolved"; + BMCWEB_LOG_DEBUG("Set Resolved"); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Logging", @@ -1892,7 +1891,7 @@ inline void requestRoutesDBusEventLogEntry(App& app) [asyncResp, entryId](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -1924,7 +1923,7 @@ inline void requestRoutesDBusEventLogEntry(App& app) systemName); return; } - BMCWEB_LOG_DEBUG << "Do delete single event entries."; + BMCWEB_LOG_DEBUG("Do delete single event entries."); std::string entryID = param; @@ -1933,7 +1932,7 @@ inline void requestRoutesDBusEventLogEntry(App& app) // Process response from Logging service. auto respHandler = [asyncResp, entryID](const boost::system::error_code& ec) { - BMCWEB_LOG_DEBUG << "EventLogEntry (DBus) doDelete callback: Done"; + BMCWEB_LOG_DEBUG("EventLogEntry (DBus) doDelete callback: Done"); if (ec) { if (ec.value() == EBADR) @@ -1943,9 +1942,9 @@ inline void requestRoutesDBusEventLogEntry(App& app) return; } // TODO Handle for specific error code - BMCWEB_LOG_ERROR - << "EventLogEntry (DBus) doDelete respHandler got error " - << ec; + BMCWEB_LOG_ERROR( + "EventLogEntry (DBus) doDelete respHandler got error {}", + ec); asyncResp->res.result( boost::beast::http::status::internal_server_error); return; @@ -2011,7 +2010,7 @@ inline void requestRoutesDBusEventLogEntryDownload(App& app) } if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -2035,8 +2034,8 @@ inline void requestRoutesDBusEventLogEntryDownload(App& app) constexpr int maxFileSize = 65536; if (size > maxFileSize) { - BMCWEB_LOG_ERROR << "File size exceeds maximum allowed size of " - << maxFileSize; + BMCWEB_LOG_ERROR("File size exceeds maximum allowed size of {}", + maxFileSize); messages::internalError(asyncResp->res); return; } @@ -2080,7 +2079,7 @@ inline bool std::filesystem::directory_iterator logPath(hostLoggerFilePath, ec); if (ec) { - BMCWEB_LOG_ERROR << ec.message(); + BMCWEB_LOG_ERROR("{}", ec.message()); return false; } for (const std::filesystem::directory_entry& it : logPath) @@ -2113,7 +2112,7 @@ inline bool getHostLoggerEntries( { if (!logFile.gzGetLines(it.string(), skip, top, logEntries, logCount)) { - BMCWEB_LOG_ERROR << "fail to expose host logs"; + BMCWEB_LOG_ERROR("fail to expose host logs"); return false; } } @@ -2230,7 +2229,7 @@ inline void requestRoutesSystemHostLoggerCollection(App& app) std::vector<std::filesystem::path> hostLoggerFiles; if (!getHostLoggerFiles(hostLoggerFolderPath, hostLoggerFiles)) { - BMCWEB_LOG_ERROR << "fail to get host log file path"; + BMCWEB_LOG_ERROR("fail to get host log file path"); return; } // If we weren't provided top and skip limits, use the defaults. @@ -2316,7 +2315,7 @@ inline void requestRoutesSystemHostLoggerLogEntry(App& app) std::vector<std::filesystem::path> hostLoggerFiles; if (!getHostLoggerFiles(hostLoggerFolderPath, hostLoggerFiles)) { - BMCWEB_LOG_ERROR << "fail to get host log file path"; + BMCWEB_LOG_ERROR("fail to get host log file path"); return; } @@ -2384,9 +2383,9 @@ inline void handleBMCLogServicesCollectionGet( const dbus::utility::MapperGetSubTreePathsResponse& subTreePaths) { if (ec) { - BMCWEB_LOG_ERROR - << "handleBMCLogServicesCollectionGet respHandler got error " - << ec; + BMCWEB_LOG_ERROR( + "handleBMCLogServicesCollectionGet respHandler got error {}", + ec); // Assume that getting an error simply means there are no dump // LogServices. Return without adding any error response. return; @@ -2471,8 +2470,8 @@ static int ret = getJournalMetadata(journal, "SYSLOG_IDENTIFIER", syslogID); if (ret < 0) { - BMCWEB_LOG_ERROR << "Failed to read SYSLOG_IDENTIFIER field: " - << strerror(-ret); + BMCWEB_LOG_ERROR("Failed to read SYSLOG_IDENTIFIER field: {}", + strerror(-ret)); } if (!syslogID.empty()) { @@ -2483,7 +2482,7 @@ static int ret = getJournalMetadata(journal, "MESSAGE", msg); if (ret < 0) { - BMCWEB_LOG_ERROR << "Failed to read MESSAGE field: " << strerror(-ret); + BMCWEB_LOG_ERROR("Failed to read MESSAGE field: {}", strerror(-ret)); return 1; } message += std::string(msg); @@ -2493,7 +2492,7 @@ static int ret = getJournalMetadata(journal, "PRIORITY", 10, severity); if (ret < 0) { - BMCWEB_LOG_ERROR << "Failed to read PRIORITY field: " << strerror(-ret); + BMCWEB_LOG_ERROR("Failed to read PRIORITY field: {}", strerror(-ret)); } // Get the Created time from the timestamp @@ -2559,7 +2558,7 @@ inline void requestRoutesBMCJournalLogEntryCollection(App& app) int ret = sd_journal_open(&journalTmp, SD_JOURNAL_LOCAL_ONLY); if (ret < 0) { - BMCWEB_LOG_ERROR << "failed to open journal: " << strerror(-ret); + BMCWEB_LOG_ERROR("failed to open journal: {}", strerror(-ret)); messages::internalError(asyncResp->res); return; } @@ -2630,7 +2629,7 @@ inline void requestRoutesBMCJournalLogEntry(App& app) int ret = sd_journal_open(&journalTmp, SD_JOURNAL_LOCAL_ONLY); if (ret < 0) { - BMCWEB_LOG_ERROR << "failed to open journal: " << strerror(-ret); + BMCWEB_LOG_ERROR("failed to open journal: {}", strerror(-ret)); messages::internalError(asyncResp->res); return; } @@ -2644,8 +2643,8 @@ inline void requestRoutesBMCJournalLogEntry(App& app) ret = sd_journal_seek_realtime_usec(journal.get(), ts); if (ret < 0) { - BMCWEB_LOG_ERROR << "failed to seek to an entry in journal" - << strerror(-ret); + BMCWEB_LOG_ERROR("failed to seek to an entry in journal{}", + strerror(-ret)); messages::internalError(asyncResp->res); return; } @@ -2705,8 +2704,8 @@ inline void } else { - BMCWEB_LOG_ERROR << "getDumpServiceInfo() invalid dump type: " - << dumpType; + BMCWEB_LOG_ERROR("getDumpServiceInfo() invalid dump type: {}", + dumpType); messages::internalError(asyncResp->res); return; } @@ -2741,8 +2740,7 @@ inline void const dbus::utility::MapperGetSubTreePathsResponse& subTreePaths) { if (ec) { - BMCWEB_LOG_ERROR << "getDumpServiceInfo respHandler got error " - << ec; + BMCWEB_LOG_ERROR("getDumpServiceInfo respHandler got error {}", ec); // Assume that getting an error simply means there are no dump // LogServices. Return without adding any error response. return; @@ -3212,7 +3210,7 @@ static void const dbus::utility::DBusPropertiesMap& params) { if (ec) { - BMCWEB_LOG_DEBUG << "failed to get log ec: " << ec.message(); + BMCWEB_LOG_DEBUG("failed to get log ec: {}", ec.message()); if (ec.value() == boost::system::linux_error::bad_request_descriptor) { @@ -3317,8 +3315,8 @@ inline void requestRoutesCrashdumpEntryCollection(App& app) if (ec.value() != boost::system::errc::no_such_file_or_directory) { - BMCWEB_LOG_DEBUG << "failed to get entries ec: " - << ec.message(); + BMCWEB_LOG_DEBUG("failed to get entries ec: {}", + ec.message()); messages::internalError(asyncResp->res); return; } @@ -3424,7 +3422,7 @@ inline void requestRoutesCrashdumpFile(App& app) resp) { if (ec) { - BMCWEB_LOG_DEBUG << "failed to get log ec: " << ec.message(); + BMCWEB_LOG_DEBUG("failed to get log ec: {}", ec.message()); messages::internalError(asyncResp->res); return; } @@ -3536,8 +3534,8 @@ inline void requestRoutesCrashdumpCollect(App& app) if (diagnosticDataType != "OEM") { - BMCWEB_LOG_ERROR - << "Only OEM DiagnosticDataType supported for Crashdump"; + BMCWEB_LOG_ERROR( + "Only OEM DiagnosticDataType supported for Crashdump"); messages::actionParameterValueFormatError( asyncResp->res, diagnosticDataType, "DiagnosticDataType", "CollectDiagnosticData"); @@ -3570,8 +3568,8 @@ inline void requestRoutesCrashdumpCollect(App& app) } else { - BMCWEB_LOG_ERROR << "Unsupported OEMDiagnosticDataType: " - << oemDiagnosticDataType; + BMCWEB_LOG_ERROR("Unsupported OEMDiagnosticDataType: {}", + oemDiagnosticDataType); messages::actionParameterValueFormatError( asyncResp->res, oemDiagnosticDataType, "OEMDiagnosticDataType", "CollectDiagnosticData"); @@ -3660,15 +3658,15 @@ inline void requestRoutesDBusLogServiceActionsClear(App& app) systemName); return; } - BMCWEB_LOG_DEBUG << "Do delete all entries."; + BMCWEB_LOG_DEBUG("Do delete all entries."); // Process response from Logging service. auto respHandler = [asyncResp](const boost::system::error_code& ec) { - BMCWEB_LOG_DEBUG << "doClearLog resp_handler callback: Done"; + BMCWEB_LOG_DEBUG("doClearLog resp_handler callback: Done"); if (ec) { // TODO Handle for specific error code - BMCWEB_LOG_ERROR << "doClearLog resp_handler got error " << ec; + BMCWEB_LOG_ERROR("doClearLog resp_handler got error {}", ec); asyncResp->res.result( boost::beast::http::status::internal_server_error); return; @@ -3766,7 +3764,7 @@ inline void requestRoutesPostCodesClear(App& app) systemName); return; } - BMCWEB_LOG_DEBUG << "Do delete all postcodes entries."; + BMCWEB_LOG_DEBUG("Do delete all postcodes entries."); // Make call to post-code service to request clear all crow::connections::systemBus->async_method_call( @@ -3774,8 +3772,8 @@ inline void requestRoutesPostCodesClear(App& app) if (ec) { // TODO Handle for specific error code - BMCWEB_LOG_ERROR << "doClearPostCodes resp_handler got error " - << ec; + BMCWEB_LOG_ERROR("doClearPostCodes resp_handler got error {}", + ec); asyncResp->res.result( boost::beast::http::status::internal_server_error); messages::internalError(asyncResp->res); @@ -3982,7 +3980,7 @@ static void postcode) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS POST CODE PostCode response error"; + BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error"); messages::internalError(asyncResp->res); return; } @@ -4018,7 +4016,7 @@ static void postcode) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS POST CODE PostCode response error"; + BMCWEB_LOG_DEBUG("DBUS POST CODE PostCode response error"); messages::internalError(asyncResp->res); return; } @@ -4075,7 +4073,7 @@ static void const uint16_t bootCount) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -4188,7 +4186,7 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app) } if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -4196,7 +4194,7 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app) size_t value = static_cast<size_t>(currentValue) - 1; if (value == std::string::npos || postcodes.size() < currentValue) { - BMCWEB_LOG_WARNING << "Wrong currentValue value"; + BMCWEB_LOG_WARNING("Wrong currentValue value"); messages::resourceNotFound(asyncResp->res, "LogEntry", postCodeID); return; @@ -4205,7 +4203,7 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app) const auto& [tID, c] = postcodes[value]; if (c.empty()) { - BMCWEB_LOG_WARNING << "No found post code data"; + BMCWEB_LOG_WARNING("No found post code data"); messages::resourceNotFound(asyncResp->res, "LogEntry", postCodeID); return; diff --git a/redfish-core/lib/manager_diagnostic_data.hpp b/redfish-core/lib/manager_diagnostic_data.hpp index ec742310c3..4dedc3fd3a 100644 --- a/redfish-core/lib/manager_diagnostic_data.hpp +++ b/redfish-core/lib/manager_diagnostic_data.hpp @@ -37,7 +37,7 @@ inline void afterGetManagerStartTime( if (runTime < steady_clock::duration::zero()) { - BMCWEB_LOG_CRITICAL << "Uptime was negative????"; + BMCWEB_LOG_CRITICAL("Uptime was negative????"); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index c97ba025e8..a114d44092 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -68,7 +68,7 @@ inline void // Use "Set" method to set the property value. if (ec) { - BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; + BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -95,7 +95,7 @@ inline void // Use "Set" method to set the property value. if (ec) { - BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec; + BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -125,7 +125,7 @@ inline void requestRoutesManagerResetAction(App& app) { return; } - BMCWEB_LOG_DEBUG << "Post Manager Reset."; + BMCWEB_LOG_DEBUG("Post Manager Reset."); std::string resetType; @@ -137,18 +137,17 @@ inline void requestRoutesManagerResetAction(App& app) if (resetType == "GracefulRestart") { - BMCWEB_LOG_DEBUG << "Proceeding with " << resetType; + BMCWEB_LOG_DEBUG("Proceeding with {}", resetType); doBMCGracefulRestart(asyncResp); return; } if (resetType == "ForceRestart") { - BMCWEB_LOG_DEBUG << "Proceeding with " << resetType; + BMCWEB_LOG_DEBUG("Proceeding with {}", resetType); doBMCForceRestart(asyncResp); return; } - BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: " - << resetType; + BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}", resetType); messages::actionParameterNotSupported(asyncResp->res, resetType, "ResetType"); @@ -184,14 +183,14 @@ inline void requestRoutesManagerResetToDefaultsAction(App& app) { return; } - BMCWEB_LOG_DEBUG << "Post ResetToDefaults."; + BMCWEB_LOG_DEBUG("Post ResetToDefaults."); std::string resetType; if (!json_util::readJsonAction(req, asyncResp->res, "ResetToDefaultsType", resetType)) { - BMCWEB_LOG_DEBUG << "Missing property ResetToDefaultsType."; + BMCWEB_LOG_DEBUG("Missing property ResetToDefaultsType."); messages::actionParameterMissing(asyncResp->res, "ResetToDefaults", "ResetToDefaultsType"); @@ -200,9 +199,9 @@ inline void requestRoutesManagerResetToDefaultsAction(App& app) if (resetType != "ResetAll") { - BMCWEB_LOG_DEBUG - << "Invalid property value for ResetToDefaultsType: " - << resetType; + BMCWEB_LOG_DEBUG( + "Invalid property value for ResetToDefaultsType: {}", + resetType); messages::actionParameterNotSupported(asyncResp->res, resetType, "ResetToDefaultsType"); return; @@ -212,7 +211,7 @@ inline void requestRoutesManagerResetToDefaultsAction(App& app) [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "Failed to ResetToDefaults: " << ec; + BMCWEB_LOG_DEBUG("Failed to ResetToDefaults: {}", ec); messages::internalError(asyncResp->res); return; } @@ -294,7 +293,7 @@ inline void const dbus::utility::ManagedObjectType& managedObj) { if (ec) { - BMCWEB_LOG_ERROR << ec; + BMCWEB_LOG_ERROR("{}", ec); messages::internalError(asyncResp->res); return; } @@ -327,7 +326,7 @@ inline void { configRoot["Profile"] = currentProfile; } - BMCWEB_LOG_ERROR << "profile = " << currentProfile << " !"; + BMCWEB_LOG_ERROR("profile = {} !", currentProfile); for (const auto& pathPair : managedObj) { @@ -352,7 +351,7 @@ inline void std::get_if<std::string>(&propPair.second); if (namePtr == nullptr) { - BMCWEB_LOG_ERROR << "Pid Name Field illegal"; + BMCWEB_LOG_ERROR("Pid Name Field illegal"); messages::internalError(asyncResp->res); return; } @@ -366,15 +365,15 @@ inline void &propPair.second); if (profiles == nullptr) { - BMCWEB_LOG_ERROR << "Pid Profiles Field illegal"; + BMCWEB_LOG_ERROR("Pid Profiles Field illegal"); messages::internalError(asyncResp->res); return; } if (std::find(profiles->begin(), profiles->end(), currentProfile) == profiles->end()) { - BMCWEB_LOG_INFO - << name << " not supported in current profile"; + BMCWEB_LOG_INFO( + "{} not supported in current profile", name); continue; } } @@ -416,7 +415,7 @@ inline void { if (classPtr == nullptr) { - BMCWEB_LOG_ERROR << "Pid Class Field illegal"; + BMCWEB_LOG_ERROR("Pid Class Field illegal"); messages::internalError(asyncResp->res); return; } @@ -439,7 +438,7 @@ inline void { if (classPtr == nullptr) { - BMCWEB_LOG_ERROR << "Pid Class Field illegal"; + BMCWEB_LOG_ERROR("Pid Class Field illegal"); messages::internalError(asyncResp->res); return; } @@ -467,7 +466,7 @@ inline void } else { - BMCWEB_LOG_ERROR << "Unexpected configuration"; + BMCWEB_LOG_ERROR("Unexpected configuration"); messages::internalError(asyncResp->res); return; } @@ -492,8 +491,8 @@ inline void std::get_if<double>(&propertyPair.second); if (ptr == nullptr) { - BMCWEB_LOG_ERROR << "Field Illegal " - << propertyPair.first; + BMCWEB_LOG_ERROR("Field Illegal {}", + propertyPair.first); messages::internalError(asyncResp->res); return; } @@ -511,8 +510,8 @@ inline void if (ptr == nullptr) { - BMCWEB_LOG_ERROR << "Field Illegal " - << propertyPair.first; + BMCWEB_LOG_ERROR("Field Illegal {}", + propertyPair.first); messages::internalError(asyncResp->res); return; } @@ -529,8 +528,8 @@ inline void { if (keys->size() != values->size()) { - BMCWEB_LOG_ERROR - << "Reading and Output size don't match "; + BMCWEB_LOG_ERROR( + "Reading and Output size don't match "); messages::internalError(asyncResp->res); return; } @@ -552,8 +551,8 @@ inline void std::get_if<double>(&propertyPair.second); if (ptr == nullptr) { - BMCWEB_LOG_ERROR << "Field Illegal " - << propertyPair.first; + BMCWEB_LOG_ERROR("Field Illegal {}", + propertyPair.first); messages::internalError(asyncResp->res); return; } @@ -573,7 +572,7 @@ inline void if (inputs == nullptr) { - BMCWEB_LOG_ERROR << "Zones Pid Field Illegal"; + BMCWEB_LOG_ERROR("Zones Pid Field Illegal"); messages::internalError(asyncResp->res); return; } @@ -609,8 +608,8 @@ inline void if (inputs == nullptr) { - BMCWEB_LOG_ERROR << "Field Illegal " - << propertyPair.first; + BMCWEB_LOG_ERROR("Field Illegal {}", + propertyPair.first); messages::internalError(asyncResp->res); return; } @@ -623,8 +622,8 @@ inline void if (ptr == nullptr) { - BMCWEB_LOG_ERROR << "Field Illegal " - << propertyPair.first; + BMCWEB_LOG_ERROR("Field Illegal {}", + propertyPair.first); messages::internalError(asyncResp->res); return; } @@ -651,7 +650,7 @@ inline void } else { - BMCWEB_LOG_ERROR << "Value Illegal " << *ptr; + BMCWEB_LOG_ERROR("Value Illegal {}", *ptr); messages::internalError(asyncResp->res); return; } @@ -675,8 +674,8 @@ inline void std::get_if<double>(&propertyPair.second); if (ptr == nullptr) { - BMCWEB_LOG_ERROR << "Field Illegal " - << propertyPair.first; + BMCWEB_LOG_ERROR("Field Illegal {}", + propertyPair.first); messages::internalError(asyncResp->res); return; } @@ -703,7 +702,7 @@ inline bool { if (config.empty()) { - BMCWEB_LOG_ERROR << "Empty Zones"; + BMCWEB_LOG_ERROR("Empty Zones"); messages::propertyValueFormatError(response->res, config, "Zones"); return false; } @@ -722,8 +721,8 @@ inline bool // 0 1 2 3 4 5 6 7 8 if (!dbus::utility::getNthStringFromPath(path, 8, input)) { - BMCWEB_LOG_ERROR << "Got invalid path " << path; - BMCWEB_LOG_ERROR << "Illegal Type Zones"; + BMCWEB_LOG_ERROR("Got invalid path {}", path); + BMCWEB_LOG_ERROR("Illegal Type Zones"); messages::propertyValueFormatError(response->res, odata, "Zones"); return false; } @@ -737,7 +736,7 @@ inline const dbus::utility::ManagedObjectType::value_type* findChassis(const dbus::utility::ManagedObjectType& managedObj, const std::string& value, std::string& chassis) { - BMCWEB_LOG_DEBUG << "Find Chassis: " << value << "\n"; + BMCWEB_LOG_DEBUG("Find Chassis: {}", value); std::string escaped = value; std::replace(escaped.begin(), escaped.end(), ' ', '_'); @@ -746,7 +745,7 @@ inline const dbus::utility::ManagedObjectType::value_type* [&escaped](const auto& obj) { if (boost::algorithm::ends_with(obj.first.str, escaped)) { - BMCWEB_LOG_DEBUG << "Matched " << obj.first.str << "\n"; + BMCWEB_LOG_DEBUG("Matched {}", obj.first.str); return true; } return false; @@ -791,18 +790,18 @@ inline CreatePIDRet createPidInterface( } else { - BMCWEB_LOG_ERROR << "Illegal Type " << type; + BMCWEB_LOG_ERROR("Illegal Type {}", type); messages::propertyUnknown(response->res, type); return CreatePIDRet::fail; } - BMCWEB_LOG_DEBUG << "del " << path << " " << iface << "\n"; + BMCWEB_LOG_DEBUG("del {} {}", path, iface); // delete interface crow::connections::systemBus->async_method_call( [response, path](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Error patching " << path << ": " << ec; + BMCWEB_LOG_ERROR("Error patching {}: {}", path, ec); messages::internalError(response->res); return; } @@ -820,7 +819,7 @@ inline CreatePIDRet createPidInterface( managedItem = findChassis(managedObj, it.key(), chassis); if (managedItem == nullptr) { - BMCWEB_LOG_ERROR << "Failed to get chassis from config patch"; + BMCWEB_LOG_ERROR("Failed to get chassis from config patch"); messages::invalidObject( response->res, boost::urls::format("/redfish/v1/Chassis/{}", chassis)); @@ -862,8 +861,8 @@ inline CreatePIDRet createPidInterface( &(prop.second)); if (curProfiles == nullptr) { - BMCWEB_LOG_ERROR - << "Illegal profiles in managed object"; + BMCWEB_LOG_ERROR( + "Illegal profiles in managed object"); messages::internalError(response->res); return CreatePIDRet::fail; } @@ -883,8 +882,7 @@ inline CreatePIDRet createPidInterface( if (!ifaceFound) { - BMCWEB_LOG_ERROR - << "Failed to find interface in managed object"; + BMCWEB_LOG_ERROR("Failed to find interface in managed object"); messages::internalError(response->res); return CreatePIDRet::fail; } @@ -926,13 +924,13 @@ inline CreatePIDRet createPidInterface( std::vector<std::string> zonesStr; if (!getZonesFromJsonReq(response, *zones, zonesStr)) { - BMCWEB_LOG_ERROR << "Illegal Zones"; + BMCWEB_LOG_ERROR("Illegal Zones"); return CreatePIDRet::fail; } if (chassis.empty() && findChassis(managedObj, zonesStr[0], chassis) == nullptr) { - BMCWEB_LOG_ERROR << "Failed to get chassis from config patch"; + BMCWEB_LOG_ERROR("Failed to get chassis from config patch"); messages::invalidObject( response->res, boost::urls::format("/redfish/v1/Chassis/{}", chassis)); @@ -980,8 +978,7 @@ inline CreatePIDRet createPidInterface( } else { - BMCWEB_LOG_ERROR << "Invalid setpointoffset " - << *setpointOffset; + BMCWEB_LOG_ERROR("Invalid setpointoffset {}", *setpointOffset); messages::propertyValueNotInList(response->res, it.key(), "SetPointOffset"); return CreatePIDRet::fail; @@ -995,7 +992,7 @@ inline CreatePIDRet createPidInterface( { continue; } - BMCWEB_LOG_DEBUG << pairs.first << " = " << *pairs.second; + BMCWEB_LOG_DEBUG("{} = {}", pairs.first, *pairs.second); output.emplace_back(pairs.first, *pairs.second); } } @@ -1027,7 +1024,7 @@ inline CreatePIDRet createPidInterface( // /redfish/v1/chassis/chassis_name/ if (!dbus::utility::getNthStringFromPath(chassisId, 3, chassis)) { - BMCWEB_LOG_ERROR << "Got invalid path " << chassisId; + BMCWEB_LOG_ERROR("Got invalid path {}", chassisId); messages::invalidObject( response->res, boost::urls::format("/redfish/v1/Chassis/{}", chassisId)); @@ -1067,13 +1064,13 @@ inline CreatePIDRet createPidInterface( std::vector<std::string> zonesStrs; if (!getZonesFromJsonReq(response, *zones, zonesStrs)) { - BMCWEB_LOG_ERROR << "Illegal Zones"; + BMCWEB_LOG_ERROR("Illegal Zones"); return CreatePIDRet::fail; } if (chassis.empty() && findChassis(managedObj, zonesStrs[0], chassis) == nullptr) { - BMCWEB_LOG_ERROR << "Failed to get chassis from config patch"; + BMCWEB_LOG_ERROR("Failed to get chassis from config patch"); messages::invalidObject( response->res, boost::urls::format("/redfish/v1/Chassis/{}", chassis)); @@ -1133,7 +1130,7 @@ inline CreatePIDRet createPidInterface( } else { - BMCWEB_LOG_ERROR << "Illegal Type " << type; + BMCWEB_LOG_ERROR("Illegal Type {}", type); messages::propertyUnknown(response->res, type); return CreatePIDRet::fail; } @@ -1169,7 +1166,7 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) { if (ec) { - BMCWEB_LOG_ERROR << ec; + BMCWEB_LOG_ERROR("{}", ec); messages::internalError(self->asyncResp->res); return; } @@ -1191,7 +1188,7 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> if (subtreeLocal[0].second.size() != 1) { // invalid mapper response, should never happen - BMCWEB_LOG_ERROR << "GetPIDValues: Mapper Error"; + BMCWEB_LOG_ERROR("GetPIDValues: Mapper Error"); messages::internalError(self->asyncResp->res); return; } @@ -1206,8 +1203,8 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> const dbus::utility::DBusPropertiesMap& resp) { if (ec2) { - BMCWEB_LOG_ERROR - << "GetPIDValues: Can't get thermalModeIface " << path; + BMCWEB_LOG_ERROR( + "GetPIDValues: Can't get thermalModeIface {}", path); messages::internalError(self->asyncResp->res); return; } @@ -1227,8 +1224,8 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> if (current == nullptr || supported == nullptr) { - BMCWEB_LOG_ERROR - << "GetPIDValues: thermal mode iface invalid " << path; + BMCWEB_LOG_ERROR( + "GetPIDValues: thermal mode iface invalid {}", path); messages::internalError(self->asyncResp->res); return; } @@ -1280,8 +1277,8 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> objectMgrPaths.find(connectionGroup.first); if (findObjMgr == objectMgrPaths.end()) { - BMCWEB_LOG_DEBUG << connectionGroup.first - << "Has no Object Manager"; + BMCWEB_LOG_DEBUG("{}Has no Object Manager", + connectionGroup.first); continue; } @@ -1363,7 +1360,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> const dbus::utility::ManagedObjectType& mObj) { if (ec) { - BMCWEB_LOG_ERROR << "Error communicating to Entity Manager"; + BMCWEB_LOG_ERROR("Error communicating to Entity Manager"); messages::internalError(self->asyncResp->res); return; } @@ -1400,7 +1397,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> if (subtree[0].second.empty()) { // invalid mapper response, should never happen - BMCWEB_LOG_ERROR << "SetPIDValues: Mapper Error"; + BMCWEB_LOG_ERROR("SetPIDValues: Mapper Error"); messages::internalError(self->asyncResp->res); return; } @@ -1413,8 +1410,8 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> const dbus::utility::DBusPropertiesMap& r) { if (ec2) { - BMCWEB_LOG_ERROR - << "SetPIDValues: Can't get thermalModeIface " << path; + BMCWEB_LOG_ERROR( + "SetPIDValues: Can't get thermalModeIface {}", path); messages::internalError(self->asyncResp->res); return; } @@ -1433,8 +1430,8 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> if (current == nullptr || supported == nullptr) { - BMCWEB_LOG_ERROR - << "SetPIDValues: thermal mode iface invalid " << path; + BMCWEB_LOG_ERROR( + "SetPIDValues: thermal mode iface invalid {}", path); messages::internalError(self->asyncResp->res); return; } @@ -1468,7 +1465,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> [response](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Error patching profile" << ec; + BMCWEB_LOG_ERROR("Error patching profile{}", ec); messages::internalError(response->res); } }); @@ -1481,7 +1478,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> { continue; } - BMCWEB_LOG_DEBUG << *container; + BMCWEB_LOG_DEBUG("{}", *container); const std::string& type = containerPair.first; @@ -1491,7 +1488,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> const auto& name = it.key(); std::string dbusObjName = name; std::replace(dbusObjName.begin(), dbusObjName.end(), ' ', '_'); - BMCWEB_LOG_DEBUG << "looking for " << name; + BMCWEB_LOG_DEBUG("looking for {}", name); auto pathItr = std::find_if(managedObj.begin(), managedObj.end(), @@ -1506,7 +1503,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> // determines if we're patching entity-manager or // creating a new object bool createNewObject = (pathItr == managedObj.end()); - BMCWEB_LOG_DEBUG << "Found = " << !createNewObject; + BMCWEB_LOG_DEBUG("Found = {}", !createNewObject); std::string iface; if (!createNewObject) @@ -1565,7 +1562,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> path = pathItr->first.str; } - BMCWEB_LOG_DEBUG << "Create new = " << createNewObject << "\n"; + BMCWEB_LOG_DEBUG("Create new = {}", createNewObject); // arbitrary limit to avoid attacks constexpr const size_t controllerLimit = 500; @@ -1604,8 +1601,8 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Error patching " - << propertyName << ": " << ec; + BMCWEB_LOG_ERROR("Error patching {}: {}", + propertyName, ec); messages::internalError(response->res); return; } @@ -1617,7 +1614,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> { if (chassis.empty()) { - BMCWEB_LOG_ERROR << "Failed to get chassis from config"; + BMCWEB_LOG_ERROR("Failed to get chassis from config"); messages::internalError(response->res); return; } @@ -1634,7 +1631,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> } if (!foundChassis) { - BMCWEB_LOG_ERROR << "Failed to find chassis on dbus"; + BMCWEB_LOG_ERROR("Failed to find chassis on dbus"); messages::resourceMissingAtURI( response->res, boost::urls::format("/redfish/v1/Chassis/{}", @@ -1646,8 +1643,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> [response](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Error Adding Pid Object " - << ec; + BMCWEB_LOG_ERROR("Error Adding Pid Object {}", ec); messages::internalError(response->res); return; } @@ -1668,7 +1664,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> } catch (...) { - BMCWEB_LOG_CRITICAL << "pidSetDone threw exception"; + BMCWEB_LOG_CRITICAL("pidSetDone threw exception"); } } @@ -1696,7 +1692,7 @@ inline void getLocation(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& connectionName, const std::string& path) { - BMCWEB_LOG_DEBUG << "Get BMC manager Location data."; + BMCWEB_LOG_DEBUG("Get BMC manager Location data."); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, connectionName, path, @@ -1705,8 +1701,8 @@ inline void getLocation(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& property) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error for " - "Location"; + BMCWEB_LOG_DEBUG("DBUS response error for " + "Location"); messages::internalError(asyncResp->res); return; } @@ -1719,7 +1715,7 @@ inline void getLocation(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, inline void managerGetLastResetTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Getting Manager Last Reset Time"; + BMCWEB_LOG_DEBUG("Getting Manager Last Reset Time"); sdbusplus::asio::getProperty<uint64_t>( *crow::connections::systemBus, "xyz.openbmc_project.State.BMC", @@ -1729,7 +1725,7 @@ inline void const uint64_t lastResetTime) { if (ec) { - BMCWEB_LOG_DEBUG << "D-BUS response error " << ec; + BMCWEB_LOG_DEBUG("D-BUS response error {}", ec); return; } @@ -1761,7 +1757,7 @@ inline void { messages::propertyValueNotInList(asyncResp->res, runningFirmwareTarget, "@odata.id"); - BMCWEB_LOG_DEBUG << "Can't parse firmware ID!"; + BMCWEB_LOG_DEBUG("Can't parse firmware ID!"); return; } idPos++; @@ -1769,7 +1765,7 @@ inline void { messages::propertyValueNotInList(asyncResp->res, runningFirmwareTarget, "@odata.id"); - BMCWEB_LOG_DEBUG << "Invalid firmware ID."; + BMCWEB_LOG_DEBUG("Invalid firmware ID."); return; } std::string firmwareId = runningFirmwareTarget.substr(idPos); @@ -1783,14 +1779,14 @@ inline void const dbus::utility::ManagedObjectType& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "D-Bus response error getting objects."; + BMCWEB_LOG_DEBUG("D-Bus response error getting objects."); messages::internalError(asyncResp->res); return; } if (subtree.empty()) { - BMCWEB_LOG_DEBUG << "Can't find image!"; + BMCWEB_LOG_DEBUG("Can't find image!"); messages::internalError(asyncResp->res); return; } @@ -1824,12 +1820,12 @@ inline void { messages::propertyValueNotInList( asyncResp->res, runningFirmwareTarget, "@odata.id"); - BMCWEB_LOG_DEBUG << "Invalid firmware ID."; + BMCWEB_LOG_DEBUG("Invalid firmware ID."); return; } - BMCWEB_LOG_DEBUG << "Setting firmware version " << firmwareId - << " to priority 0."; + BMCWEB_LOG_DEBUG("Setting firmware version {} to priority 0.", + firmwareId); // Only support Immediate // An addition could be a Redfish Setting like @@ -1843,7 +1839,7 @@ inline void [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "D-Bus response error setting."; + BMCWEB_LOG_DEBUG("D-Bus response error setting."); messages::internalError(asyncResp->res); return; } @@ -1855,7 +1851,7 @@ inline void inline void setDateTime(std::shared_ptr<bmcweb::AsyncResp> asyncResp, std::string datetime) { - BMCWEB_LOG_DEBUG << "Set date time: " << datetime; + BMCWEB_LOG_DEBUG("Set date time: {}", datetime); std::optional<redfish::time_utils::usSinceEpoch> us = redfish::time_utils::dateStringToEpoch(datetime); @@ -1873,9 +1869,9 @@ inline void setDateTime(std::shared_ptr<bmcweb::AsyncResp> asyncResp, datetime{std::move(datetime)}](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "Failed to set elapsed time. " - "DBUS response error " - << ec; + BMCWEB_LOG_DEBUG("Failed to set elapsed time. " + "DBUS response error {}", + ec); messages::internalError(asyncResp->res); return; } @@ -2058,7 +2054,7 @@ inline void requestRoutesManager(App& app) [asyncResp](const boost::system::error_code& ec, double val) { if (ec) { - BMCWEB_LOG_ERROR << "Error while getting progress"; + BMCWEB_LOG_ERROR("Error while getting progress"); messages::internalError(asyncResp->res); return; } @@ -2080,26 +2076,26 @@ inline void requestRoutesManager(App& app) const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "D-Bus response error on GetSubTree " << ec; + BMCWEB_LOG_DEBUG("D-Bus response error on GetSubTree {}", ec); return; } if (subtree.empty()) { - BMCWEB_LOG_DEBUG << "Can't find bmc D-Bus object!"; + BMCWEB_LOG_DEBUG("Can't find bmc D-Bus object!"); return; } // Assume only 1 bmc D-Bus object // Throw an error if there is more than 1 if (subtree.size() > 1) { - BMCWEB_LOG_DEBUG << "Found more than 1 bmc D-Bus object!"; + BMCWEB_LOG_DEBUG("Found more than 1 bmc D-Bus object!"); messages::internalError(asyncResp->res); return; } if (subtree[0].first.empty() || subtree[0].second.size() != 1) { - BMCWEB_LOG_DEBUG << "Error getting bmc D-Bus object!"; + BMCWEB_LOG_DEBUG("Error getting bmc D-Bus object!"); messages::internalError(asyncResp->res); return; } @@ -2120,7 +2116,7 @@ inline void requestRoutesManager(App& app) propertiesList) { if (ec2) { - BMCWEB_LOG_DEBUG << "Can't get bmc asset!"; + BMCWEB_LOG_DEBUG("Can't get bmc asset!"); return; } diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp index 54b4cca590..551a5790a1 100644 --- a/redfish-core/lib/memory.hpp +++ b/redfish-core/lib/memory.hpp @@ -614,7 +614,7 @@ inline void getDimmDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, health->populate(); } - BMCWEB_LOG_DEBUG << "Get available system components."; + BMCWEB_LOG_DEBUG("Get available system components."); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, objPath, "", [dimmId, asyncResp{std::move(asyncResp)}]( @@ -622,7 +622,7 @@ inline void getDimmDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -695,7 +695,7 @@ inline void getDimmPartitionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; @@ -710,7 +710,7 @@ inline void getDimmPartitionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, inline void getDimmData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& dimmId) { - BMCWEB_LOG_DEBUG << "Get available system dimm resources."; + BMCWEB_LOG_DEBUG("Get available system dimm resources."); constexpr std::array<std::string_view, 2> dimmInterfaces = { "xyz.openbmc_project.Inventory.Item.Dimm", "xyz.openbmc_project.Inventory.Item.PersistentMemory.Partition"}; @@ -721,7 +721,7 @@ inline void getDimmData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp index 6f26d8a52a..7543186bc1 100644 --- a/redfish-core/lib/metric_report.hpp +++ b/redfish-core/lib/metric_report.hpp @@ -108,7 +108,7 @@ inline void requestRoutesMetricReport(App& app) } if (ec) { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); messages::internalError(asyncResp->res); return; } @@ -120,7 +120,7 @@ inline void requestRoutesMetricReport(App& app) const telemetry::TimestampReadings& ret) { if (ec2) { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec2; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec2); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp index e245a99862..5daaeba2d2 100644 --- a/redfish-core/lib/metric_report_definition.hpp +++ b/redfish-core/lib/metric_report_definition.hpp @@ -191,16 +191,16 @@ inline std::optional<nlohmann::json::array_t> getLinkedTriggers( if (path.parent_path() != "/xyz/openbmc_project/Telemetry/Triggers/TelemetryService") { - BMCWEB_LOG_ERROR << "Property Triggers contains invalid value: " - << path.str; + BMCWEB_LOG_ERROR("Property Triggers contains invalid value: {}", + path.str); return std::nullopt; } std::string id = path.filename(); if (id.empty()) { - BMCWEB_LOG_ERROR << "Property Triggers contains invalid value: " - << path.str; + BMCWEB_LOG_ERROR("Property Triggers contains invalid value: {}", + path.str); return std::nullopt; } nlohmann::json::object_t trigger; @@ -666,9 +666,9 @@ class AddReport auto el = uriToDbus.find(uri); if (el == uriToDbus.end()) { - BMCWEB_LOG_ERROR - << "Failed to find DBus sensor corresponding to URI " - << uri; + BMCWEB_LOG_ERROR( + "Failed to find DBus sensor corresponding to URI {}", + uri); messages::propertyValueNotInList(asyncResp->res, uri, "MetricProperties/" + std::to_string(i)); @@ -712,7 +712,7 @@ class AddReport if (ec) { messages::internalError(asyncResp->res); - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); return; } @@ -819,7 +819,7 @@ inline void } if (ec) { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); messages::internalError(asyncResp->res); return; } @@ -855,7 +855,7 @@ inline void handleMetricReportDelete( if (ec) { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); messages::internalError(asyncResp->res); return; } @@ -913,9 +913,9 @@ inline void requestRoutesMetricReportDefinitionCollection(App& app) const std::map<std::string, std::string>& uriToDbus) { if (status != boost::beast::http::status::ok) { - BMCWEB_LOG_ERROR - << "Failed to retrieve URI to dbus sensors map with err " - << static_cast<unsigned>(status); + BMCWEB_LOG_ERROR( + "Failed to retrieve URI to dbus sensors map with err {}", + static_cast<unsigned>(status)); return; } addReportReq->insert(uriToDbus); diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp index 29da308d84..83b6b66664 100644 --- a/redfish-core/lib/network_protocol.hpp +++ b/redfish-core/lib/network_protocol.hpp @@ -351,7 +351,7 @@ inline void const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " << ec.message(); + BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message()); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp index e442c8e3ae..3831e184a6 100644 --- a/redfish-core/lib/pcie.hpp +++ b/redfish-core/lib/pcie.hpp @@ -62,7 +62,7 @@ static inline void handlePCIeDevicePath( const dbus::utility::MapperGetObject& object) { if (ec || object.empty()) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -71,7 +71,7 @@ static inline void handlePCIeDevicePath( return; } - BMCWEB_LOG_WARNING << "PCIe Device not found"; + BMCWEB_LOG_WARNING("PCIe Device not found"); messages::resourceNotFound(asyncResp->res, "PCIeDevice", pcieDeviceId); } @@ -89,7 +89,7 @@ static inline void getValidPCIeDevicePath( pcieDevicePaths) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus response error on GetSubTree " << ec; + BMCWEB_LOG_ERROR("D-Bus response error on GetSubTree {}", ec); messages::internalError(asyncResp->res); return; } @@ -154,8 +154,8 @@ inline void addPCIeSlotProperties( { if (ec) { - BMCWEB_LOG_ERROR << "DBUS response error for getAllProperties" - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for getAllProperties{}", + ec.value()); messages::internalError(res); return; } @@ -177,13 +177,13 @@ inline void addPCIeSlotProperties( pcie_util::redfishPcieGenerationFromDbus(generation); if (!pcieType) { - BMCWEB_LOG_WARNING << "Unknown PCIeType: " << generation; + BMCWEB_LOG_WARNING("Unknown PCIeType: {}", generation); } else { if (*pcieType == pcie_device::PCIeTypes::Invalid) { - BMCWEB_LOG_ERROR << "Invalid PCIeType: " << generation; + BMCWEB_LOG_ERROR("Invalid PCIeType: {}", generation); messages::internalError(res); return; } @@ -199,13 +199,13 @@ inline void addPCIeSlotProperties( pcie_util::dbusSlotTypeToRf(slotType); if (!redfishSlotType) { - BMCWEB_LOG_WARNING << "Unknown PCIeSlot Type: " << slotType; + BMCWEB_LOG_WARNING("Unknown PCIeSlot Type: {}", slotType); } else { if (*redfishSlotType == pcie_slots::SlotTypes::Invalid) { - BMCWEB_LOG_ERROR << "Invalid PCIeSlot type: " << slotType; + BMCWEB_LOG_ERROR("Invalid PCIeSlot type: {}", slotType); messages::internalError(res); return; } @@ -232,17 +232,17 @@ inline void getPCIeDeviceSlotPath( // Missing association is not an error return; } - BMCWEB_LOG_ERROR - << "DBUS response error for getAssociatedSubTreePaths " - << ec.value(); + BMCWEB_LOG_ERROR( + "DBUS response error for getAssociatedSubTreePaths {}", + ec.value()); messages::internalError(asyncResp->res); return; } if (endpoints.size() > 1) { - BMCWEB_LOG_ERROR - << "PCIeDevice is associated with more than one PCIeSlot: " - << endpoints.size(); + BMCWEB_LOG_ERROR( + "PCIeDevice is associated with more than one PCIeSlot: {}", + endpoints.size()); messages::internalError(asyncResp->res); return; } @@ -250,7 +250,7 @@ inline void getPCIeDeviceSlotPath( { // If the device doesn't have an association, return without PCIe // Slot properties - BMCWEB_LOG_DEBUG << "PCIeDevice is not associated with PCIeSlot"; + BMCWEB_LOG_DEBUG("PCIeDevice is not associated with PCIeSlot"); return; } callback(endpoints[0]); @@ -265,8 +265,8 @@ inline void { if (ec || object.empty()) { - BMCWEB_LOG_ERROR << "DBUS response error for getDbusObject " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for getDbusObject {}", + ec.value()); messages::internalError(asyncResp->res); return; } @@ -306,8 +306,8 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Health " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Health {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -333,7 +333,7 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for State"; + BMCWEB_LOG_ERROR("DBUS response error for State"); messages::internalError(asyncResp->res); } return; @@ -361,8 +361,8 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Properties" - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Properties{}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -439,15 +439,15 @@ inline void addPCIeDeviceProperties( if (!redfishGenerationInUse) { - BMCWEB_LOG_WARNING << "Unknown PCIe Device Generation: " - << *generationInUse; + BMCWEB_LOG_WARNING("Unknown PCIe Device Generation: {}", + *generationInUse); } else { if (*redfishGenerationInUse == pcie_device::PCIeTypes::Invalid) { - BMCWEB_LOG_ERROR << "Invalid PCIe Device Generation: " - << *generationInUse; + BMCWEB_LOG_ERROR("Invalid PCIe Device Generation: {}", + *generationInUse); messages::internalError(asyncResp->res); return; } @@ -463,15 +463,15 @@ inline void addPCIeDeviceProperties( if (!redfishGenerationSupported) { - BMCWEB_LOG_WARNING << "Unknown PCIe Device Generation: " - << *generationSupported; + BMCWEB_LOG_WARNING("Unknown PCIe Device Generation: {}", + *generationSupported); } else { if (*redfishGenerationSupported == pcie_device::PCIeTypes::Invalid) { - BMCWEB_LOG_ERROR << "Invalid PCIe Device Generation: " - << *generationSupported; + BMCWEB_LOG_ERROR("Invalid PCIe Device Generation: {}", + *generationSupported); messages::internalError(asyncResp->res); return; } @@ -515,7 +515,7 @@ inline void getPCIeDeviceProperties( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Properties"; + BMCWEB_LOG_ERROR("DBUS response error for Properties"); messages::internalError(asyncResp->res); } return; diff --git a/redfish-core/lib/pcie_slots.hpp b/redfish-core/lib/pcie_slots.hpp index 4412c41ed4..92ae576c9a 100644 --- a/redfish-core/lib/pcie_slots.hpp +++ b/redfish-core/lib/pcie_slots.hpp @@ -29,7 +29,7 @@ inline void { if (ec) { - BMCWEB_LOG_ERROR << "Can't get PCIeSlot properties!"; + BMCWEB_LOG_ERROR("Can't get PCIeSlot properties!"); messages::internalError(asyncResp->res); return; } @@ -40,7 +40,7 @@ inline void slots.get_ptr<nlohmann::json::array_t*>(); if (slotsPtr == nullptr) { - BMCWEB_LOG_ERROR << "Slots key isn't an array???"; + BMCWEB_LOG_ERROR("Slots key isn't an array???"); messages::internalError(asyncResp->res); return; } @@ -69,8 +69,7 @@ inline void pcie_util::redfishPcieGenerationFromDbus(*generation); if (!pcieType) { - BMCWEB_LOG_WARNING << "Unknown PCIe Slot Generation: " - << *generation; + BMCWEB_LOG_WARNING("Unknown PCIe Slot Generation: {}", *generation); } else { @@ -94,13 +93,13 @@ inline void pcie_util::dbusSlotTypeToRf(*slotType); if (!redfishSlotType) { - BMCWEB_LOG_WARNING << "Unknown PCIe Slot Type: " << *slotType; + BMCWEB_LOG_WARNING("Unknown PCIe Slot Type: {}", *slotType); } else { if (*redfishSlotType == pcie_slots::SlotTypes::Invalid) { - BMCWEB_LOG_ERROR << "Unknown PCIe Slot Type: " << *slotType; + BMCWEB_LOG_ERROR("Unknown PCIe Slot Type: {}", *slotType); messages::internalError(asyncResp->res); return; } @@ -129,14 +128,14 @@ inline void onMapperAssociationDone( // This PCIeSlot have no chassis association. return; } - BMCWEB_LOG_ERROR << "DBUS response error"; + BMCWEB_LOG_ERROR("DBUS response error"); messages::internalError(asyncResp->res); return; } if (pcieSlotChassis.size() != 1) { - BMCWEB_LOG_ERROR << "PCIe Slot association error! "; + BMCWEB_LOG_ERROR("PCIe Slot association error! "); messages::internalError(asyncResp->res); return; } @@ -166,7 +165,7 @@ inline void { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus response error on GetSubTree " << ec; + BMCWEB_LOG_ERROR("D-Bus response error on GetSubTree {}", ec); messages::internalError(asyncResp->res); return; } @@ -176,8 +175,8 @@ inline void return; } - BMCWEB_LOG_DEBUG << "Get properties for PCIeSlots associated to chassis = " - << chassisID; + BMCWEB_LOG_DEBUG("Get properties for PCIeSlots associated to chassis = {}", + chassisID); asyncResp->res.jsonValue["@odata.type"] = "#PCIeSlots.v1_4_1.PCIeSlots"; asyncResp->res.jsonValue["Name"] = "PCIe Slot Information"; diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp index f9063b7dff..e7094ad05e 100644 --- a/redfish-core/lib/power.hpp +++ b/redfish-core/lib/power.hpp @@ -39,7 +39,7 @@ inline void setPowerCapOverride( const std::optional<std::string>& chassisPath) mutable { if (!chassisPath) { - BMCWEB_LOG_WARNING << "Don't find valid chassis path "; + BMCWEB_LOG_WARNING("Don't find valid chassis path "); messages::resourceNotFound(sensorsAsyncResp->asyncResp->res, "Chassis", sensorsAsyncResp->chassisId); return; @@ -47,7 +47,7 @@ inline void setPowerCapOverride( if (powerControlCollections.size() != 1) { - BMCWEB_LOG_WARNING << "Don't support multiple hosts at present "; + BMCWEB_LOG_WARNING("Don't support multiple hosts at present "); messages::resourceNotFound(sensorsAsyncResp->asyncResp->res, "Power", "PowerControl"); return; @@ -84,8 +84,8 @@ inline void setPowerCapOverride( if (ec) { messages::internalError(sensorsAsyncResp->asyncResp->res); - BMCWEB_LOG_ERROR << "powerCapEnable Get handler: Dbus error " - << ec; + BMCWEB_LOG_ERROR("powerCapEnable Get handler: Dbus error {}", + ec); return; } if (!powerCapEnable) @@ -93,7 +93,7 @@ inline void setPowerCapOverride( messages::actionNotSupported( sensorsAsyncResp->asyncResp->res, "Setting LimitInWatts when PowerLimit feature is disabled"); - BMCWEB_LOG_ERROR << "PowerLimit feature is disabled "; + BMCWEB_LOG_ERROR("PowerLimit feature is disabled "); return; } @@ -104,7 +104,7 @@ inline void setPowerCapOverride( [sensorsAsyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "Power Limit Set: Dbus error: " << ec2; + BMCWEB_LOG_DEBUG("Power Limit Set: Dbus error: {}", ec2); messages::internalError(sensorsAsyncResp->asyncResp->res); return; } @@ -148,8 +148,8 @@ inline void requestRoutesPower(App& app) const Mapper& chassisPaths) { if (ec2) { - BMCWEB_LOG_ERROR - << "Power Limit GetSubTreePaths handler Dbus error " << ec2; + BMCWEB_LOG_ERROR( + "Power Limit GetSubTreePaths handler Dbus error {}", ec2); return; } @@ -186,8 +186,8 @@ inline void requestRoutesPower(App& app) if (!found) { - BMCWEB_LOG_DEBUG << "Power Limit not present for " - << sensorAsyncResp->chassisId; + BMCWEB_LOG_DEBUG("Power Limit not present for {}", + sensorAsyncResp->chassisId); return; } @@ -198,8 +198,8 @@ inline void requestRoutesPower(App& app) if (ec) { messages::internalError(sensorAsyncResp->asyncResp->res); - BMCWEB_LOG_ERROR - << "Power Limit GetAll handler: Dbus error " << ec; + BMCWEB_LOG_ERROR( + "Power Limit GetAll handler: Dbus error {}", ec); return; } diff --git a/redfish-core/lib/power_supply.hpp b/redfish-core/lib/power_supply.hpp index 09f731b54e..0035b118f7 100644 --- a/redfish-core/lib/power_supply.hpp +++ b/redfish-core/lib/power_supply.hpp @@ -82,7 +82,7 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error" << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error{}", ec.value()); messages::internalError(asyncResp->res); } return; @@ -171,9 +171,9 @@ inline void getValidPowerSupplyPath( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR - << "DBUS response error for getAssociatedSubTreePaths" - << ec.value(); + BMCWEB_LOG_ERROR( + "DBUS response error for getAssociatedSubTreePaths{}", + ec.value()); messages::internalError(asyncResp->res); return; } @@ -193,7 +193,7 @@ inline void getValidPowerSupplyPath( if (!subtreePaths.empty()) { - BMCWEB_LOG_WARNING << "Power supply not found: " << powerSupplyId; + BMCWEB_LOG_WARNING("Power supply not found: {}", powerSupplyId); messages::resourceNotFound(asyncResp->res, "PowerSupplies", powerSupplyId); return; @@ -213,8 +213,8 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for State " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for State {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -239,8 +239,8 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Health " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Health {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -266,8 +266,8 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Asset " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Asset {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -331,8 +331,8 @@ inline void getPowerSupplyFirmwareVersion( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for FirmwareVersion " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for FirmwareVersion {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -354,8 +354,8 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for Location " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for Location {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -373,8 +373,8 @@ inline void handleGetEfficiencyResponse( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for DeratingFactor " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for DeratingFactor {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -402,8 +402,8 @@ inline void handlePowerSupplyAttributesSubTreeResponse( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "DBUS response error for EfficiencyPercent " - << ec.value(); + BMCWEB_LOG_ERROR("DBUS response error for EfficiencyPercent {}", + ec.value()); messages::internalError(asyncResp->res); } return; @@ -411,15 +411,15 @@ inline void handlePowerSupplyAttributesSubTreeResponse( if (subtree.empty()) { - BMCWEB_LOG_DEBUG << "Can't find Power Supply Attributes!"; + BMCWEB_LOG_DEBUG("Can't find Power Supply Attributes!"); return; } if (subtree.size() != 1) { - BMCWEB_LOG_ERROR - << "Unexpected number of paths returned by getSubTree: " - << subtree.size(); + BMCWEB_LOG_ERROR( + "Unexpected number of paths returned by getSubTree: {}", + subtree.size()); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp index 8efa78e41a..873f882462 100644 --- a/redfish-core/lib/processor.hpp +++ b/redfish-core/lib/processor.hpp @@ -59,7 +59,7 @@ inline void getProcessorUUID(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_DEBUG << "Get Processor UUID"; + BMCWEB_LOG_DEBUG("Get Processor UUID"); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, service, objPath, "xyz.openbmc_project.Common.UUID", "UUID", @@ -67,7 +67,7 @@ inline void getProcessorUUID(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const boost::system::error_code& ec, const std::string& property) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -79,7 +79,7 @@ inline void getCpuDataByInterface( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const dbus::utility::DBusInteracesMap& cpuInterfacesProperties) { - BMCWEB_LOG_DEBUG << "Get CPU resources by interface."; + BMCWEB_LOG_DEBUG("Get CPU resources by interface."); // Set the default value of state asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; @@ -223,7 +223,7 @@ inline void getCpuDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_DEBUG << "Get available system cpu resources by service."; + BMCWEB_LOG_DEBUG("Get available system cpu resources by service."); sdbusplus::message::object_path path("/xyz/openbmc_project/inventory"); dbus::utility::getManagedObjects( @@ -233,7 +233,7 @@ inline void getCpuDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::ManagedObjectType& dbusData) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -339,7 +339,7 @@ inline void { if (ec) { - BMCWEB_LOG_ERROR << "Processor Throttle getAllProperties error " << ec; + BMCWEB_LOG_ERROR("Processor Throttle getAllProperties error {}", ec); messages::internalError(asyncResp->res); return; } @@ -376,7 +376,7 @@ inline void const std::string& service, const std::string& objectPath) { - BMCWEB_LOG_DEBUG << "Get processor throttle resources"; + BMCWEB_LOG_DEBUG("Get processor throttle resources"); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, objectPath, @@ -391,7 +391,7 @@ inline void getCpuAssetData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_DEBUG << "Get Cpu Asset Data"; + BMCWEB_LOG_DEBUG("Get Cpu Asset Data"); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, objPath, "xyz.openbmc_project.Inventory.Decorator.Asset", @@ -400,7 +400,7 @@ inline void getCpuAssetData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -465,7 +465,7 @@ inline void getCpuRevisionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_DEBUG << "Get Cpu Revision Data"; + BMCWEB_LOG_DEBUG("Get Cpu Revision Data"); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, objPath, "xyz.openbmc_project.Inventory.Decorator.Revision", @@ -474,7 +474,7 @@ inline void getCpuRevisionData(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -501,8 +501,7 @@ inline void getAcceleratorDataByService( std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& acclrtrId, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_DEBUG - << "Get available system Accelerator resources by service."; + BMCWEB_LOG_DEBUG("Get available system Accelerator resources by service."); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, objPath, "", [acclrtrId, asyncResp{std::move(asyncResp)}]( @@ -510,7 +509,7 @@ inline void getAcceleratorDataByService( const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -613,7 +612,7 @@ inline void const std::string& cpuId, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_INFO << "Getting CPU operating configs for " << cpuId; + BMCWEB_LOG_INFO("Getting CPU operating configs for {}", cpuId); // First, GetAll CurrentOperatingConfig properties on the object sdbusplus::asio::getAllProperties( @@ -624,7 +623,7 @@ inline void const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " << ec.message(); + BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message()); messages::internalError(asyncResp->res); return; } @@ -685,7 +684,7 @@ inline void const BaseSpeedPrioritySettingsProperty& baseSpeedList) { if (ec2) { - BMCWEB_LOG_WARNING << "D-Bus Property Get error: " << ec2; + BMCWEB_LOG_WARNING("D-Bus Property Get error: {}", ec2); messages::internalError(asyncResp->res); return; } @@ -714,7 +713,7 @@ inline void getCpuLocationCode(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& objPath) { - BMCWEB_LOG_DEBUG << "Get Cpu Location Data"; + BMCWEB_LOG_DEBUG("Get Cpu Location Data"); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, service, objPath, "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode", @@ -722,7 +721,7 @@ inline void getCpuLocationCode(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const boost::system::error_code& ec, const std::string& property) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -744,7 +743,7 @@ inline void getCpuUniqueId(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& service, const std::string& objectPath) { - BMCWEB_LOG_DEBUG << "Get CPU UniqueIdentifier"; + BMCWEB_LOG_DEBUG("Get CPU UniqueIdentifier"); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, service, objectPath, "xyz.openbmc_project.Inventory.Decorator.UniqueIdentifier", @@ -753,7 +752,7 @@ inline void getCpuUniqueId(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id) { if (ec) { - BMCWEB_LOG_ERROR << "Failed to read cpu unique id: " << ec; + BMCWEB_LOG_ERROR("Failed to read cpu unique id: {}", ec); messages::internalError(asyncResp->res); return; } @@ -777,7 +776,7 @@ inline void getProcessorObject(const std::shared_ptr<bmcweb::AsyncResp>& resp, const std::string& processorId, Handler&& handler) { - BMCWEB_LOG_DEBUG << "Get available system processor resources."; + BMCWEB_LOG_DEBUG("Get available system processor resources."); // GetSubTree on all interfaces which provide info about a Processor constexpr std::array<std::string_view, 9> interfaces = { @@ -797,7 +796,7 @@ inline void getProcessorObject(const std::shared_ptr<bmcweb::AsyncResp>& resp, const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error: " << ec; + BMCWEB_LOG_DEBUG("DBUS response error: {}", ec); messages::internalError(resp->res); return; } @@ -921,7 +920,7 @@ inline void const dbus::utility::DBusPropertiesMap& properties) { if (ec) { - BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " << ec.message(); + BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message()); messages::internalError(asyncResp->res); return; } @@ -1022,11 +1021,11 @@ inline void { if (!ec) { - BMCWEB_LOG_DEBUG << "Set Property succeeded"; + BMCWEB_LOG_DEBUG("Set Property succeeded"); return; } - BMCWEB_LOG_DEBUG << "Set Property failed: " << ec; + BMCWEB_LOG_DEBUG("Set Property failed: {}", ec); const sd_bus_error* dbusError = msg.get_error(); if (dbusError == nullptr) @@ -1119,7 +1118,7 @@ inline void patchAppliedOperatingConfig( sdbusplus::message::object_path configPath(cpuObjectPath); configPath /= configBaseName; - BMCWEB_LOG_INFO << "Setting config to " << configPath.str; + BMCWEB_LOG_INFO("Setting config to {}", configPath.str); // Set the property, with handler to check error responses sdbusplus::asio::setProperty( @@ -1207,8 +1206,7 @@ inline void requestRoutesOperatingConfigCollection(App& app) const dbus::utility::MapperGetSubTreePathsResponse& objects) { if (ec) { - BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " - << ec.message(); + BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message()); messages::internalError(asyncResp->res); return; } @@ -1281,8 +1279,7 @@ inline void requestRoutesOperatingConfig(App& app) const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", " - << ec.message(); + BMCWEB_LOG_WARNING("D-Bus error: {}, {}", ec, ec.message()); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/redfish_util.hpp b/redfish-core/lib/redfish_util.hpp index f5c68d19bd..fad410d155 100644 --- a/redfish-core/lib/redfish_util.hpp +++ b/redfish-core/lib/redfish_util.hpp @@ -73,12 +73,12 @@ void getMainChassisId(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_ERROR << ec; + BMCWEB_LOG_ERROR("{}", ec); return; } if (subtree.empty()) { - BMCWEB_LOG_DEBUG << "Can't find chassis!"; + BMCWEB_LOG_DEBUG("Can't find chassis!"); return; } @@ -87,11 +87,11 @@ void getMainChassisId(std::shared_ptr<bmcweb::AsyncResp> asyncResp, (idPos + 1) >= subtree[0].first.size()) { messages::internalError(asyncResp->res); - BMCWEB_LOG_DEBUG << "Can't parse chassis ID!"; + BMCWEB_LOG_DEBUG("Can't parse chassis ID!"); return; } std::string chassisId = subtree[0].first.substr(idPos + 1); - BMCWEB_LOG_DEBUG << "chassisId = " << chassisId; + BMCWEB_LOG_DEBUG("chassisId = {}", chassisId); callback(chassisId, asyncResp); }); } @@ -109,7 +109,7 @@ void getPortStatusAndPath( std::vector<std::tuple<std::string, std::string, bool>> socketData; if (ec) { - BMCWEB_LOG_ERROR << ec; + BMCWEB_LOG_ERROR("{}", ec); // return error code callback(ec, socketData); return; @@ -181,10 +181,9 @@ void getPortStatusAndPath( { // Already registered as enabled or current one is not // enabled, nothing to do - BMCWEB_LOG_DEBUG - << "protocolName: " << kv.first - << ", already true or current one is false: " - << isProtocolEnabled; + BMCWEB_LOG_DEBUG( + "protocolName: {}, already true or current one is false: {}", + kv.first, isProtocolEnabled); break; } // Remove existing entry and replace with new one (below) @@ -216,7 +215,7 @@ void getPortNumber(const std::string& socketPath, CallbackFunc&& callback) const std::vector<std::tuple<std::string, std::string>>& resp) { if (ec) { - BMCWEB_LOG_ERROR << ec; + BMCWEB_LOG_ERROR("{}", ec); callback(ec, 0); return; } @@ -228,7 +227,7 @@ void getPortNumber(const std::string& socketPath, CallbackFunc&& callback) boost::system::errc::bad_message); // return error code callback(ec1, 0); - BMCWEB_LOG_ERROR << ec1; + BMCWEB_LOG_ERROR("{}", ec1); return; } const std::string& listenStream = @@ -250,7 +249,7 @@ void getPortNumber(const std::string& socketPath, CallbackFunc&& callback) } // return error code callback(ec3, 0); - BMCWEB_LOG_ERROR << ec3; + BMCWEB_LOG_ERROR("{}", ec3); } callback(ec, port); }); diff --git a/redfish-core/lib/redfish_v1.hpp b/redfish-core/lib/redfish_v1.hpp index b7a1f4cb21..a591763f57 100644 --- a/redfish-core/lib/redfish_v1.hpp +++ b/redfish-core/lib/redfish_v1.hpp @@ -39,7 +39,7 @@ inline void redfish404(App& app, const crow::Request& req, return; } - BMCWEB_LOG_WARNING << "404 on path " << path; + BMCWEB_LOG_WARNING("404 on path {}", path); std::string name = req.url().segments().back(); // Note, if we hit the wildcard route, we don't know the "type" the user was @@ -59,7 +59,7 @@ inline void redfish405(App& app, const crow::Request& req, return; } - BMCWEB_LOG_WARNING << "405 on path " << path; + BMCWEB_LOG_WARNING("405 on path {}", path); asyncResp->res.result(boost::beast::http::status::method_not_allowed); if (req.method() == boost::beast::http::verb::delete_) { diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index 1fec8680c0..4969c8fe22 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -324,7 +324,7 @@ class InventoryItem name = path.filename(); if (name.empty()) { - BMCWEB_LOG_ERROR << "Failed to find '/' in " << objectPath; + BMCWEB_LOG_ERROR("Failed to find '/' in {}", objectPath); } } @@ -355,7 +355,7 @@ void getObjectsWithConnection( const std::shared_ptr<std::set<std::string>>& sensorNames, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getObjectsWithConnection enter"; + BMCWEB_LOG_DEBUG("getObjectsWithConnection enter"); const std::string path = "/xyz/openbmc_project/sensors"; constexpr std::array<std::string_view, 1> interfaces = { "xyz.openbmc_project.Sensor.Value"}; @@ -367,26 +367,26 @@ void getObjectsWithConnection( sensorNames](const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreeResponse& subtree) { // Response handler for parsing objects subtree - BMCWEB_LOG_DEBUG << "getObjectsWithConnection resp_handler enter"; + BMCWEB_LOG_DEBUG("getObjectsWithConnection resp_handler enter"); if (ec) { messages::internalError(sensorsAsyncResp->asyncResp->res); - BMCWEB_LOG_ERROR - << "getObjectsWithConnection resp_handler: Dbus error " << ec; + BMCWEB_LOG_ERROR( + "getObjectsWithConnection resp_handler: Dbus error {}", ec); return; } - BMCWEB_LOG_DEBUG << "Found " << subtree.size() << " subtrees"; + BMCWEB_LOG_DEBUG("Found {} subtrees", subtree.size()); // Make unique list of connections only for requested sensor types and // found in the chassis std::set<std::string> connections; std::set<std::pair<std::string, std::string>> objectsWithConnection; - BMCWEB_LOG_DEBUG << "sensorNames list count: " << sensorNames->size(); + BMCWEB_LOG_DEBUG("sensorNames list count: {}", sensorNames->size()); for (const std::string& tsensor : *sensorNames) { - BMCWEB_LOG_DEBUG << "Sensor to find: " << tsensor; + BMCWEB_LOG_DEBUG("Sensor to find: {}", tsensor); } for (const std::pair< @@ -399,18 +399,18 @@ void getObjectsWithConnection( for (const std::pair<std::string, std::vector<std::string>>& objData : object.second) { - BMCWEB_LOG_DEBUG << "Adding connection: " << objData.first; + BMCWEB_LOG_DEBUG("Adding connection: {}", objData.first); connections.insert(objData.first); objectsWithConnection.insert( std::make_pair(object.first, objData.first)); } } } - BMCWEB_LOG_DEBUG << "Found " << connections.size() << " connections"; + BMCWEB_LOG_DEBUG("Found {} connections", connections.size()); callback(std::move(connections), std::move(objectsWithConnection)); - BMCWEB_LOG_DEBUG << "getObjectsWithConnection resp_handler exit"; + BMCWEB_LOG_DEBUG("getObjectsWithConnection resp_handler exit"); }); - BMCWEB_LOG_DEBUG << "getObjectsWithConnection exit"; + BMCWEB_LOG_DEBUG("getObjectsWithConnection exit"); } /** @@ -518,7 +518,7 @@ void getChassis(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::span<const std::string_view> sensorTypes, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getChassis enter"; + BMCWEB_LOG_DEBUG("getChassis enter"); constexpr std::array<std::string_view, 2> interfaces = { "xyz.openbmc_project.Inventory.Item.Board", "xyz.openbmc_project.Inventory.Item.Chassis"}; @@ -531,10 +531,10 @@ void getChassis(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, chassisSubNode{std::string(chassisSubNode)}, sensorTypes]( const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreePathsResponse& chassisPaths) { - BMCWEB_LOG_DEBUG << "getChassis respHandler enter"; + BMCWEB_LOG_DEBUG("getChassis respHandler enter"); if (ec) { - BMCWEB_LOG_ERROR << "getChassis respHandler DBUS error: " << ec; + BMCWEB_LOG_ERROR("getChassis respHandler DBUS error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -545,7 +545,7 @@ void getChassis(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string chassisName = path.filename(); if (chassisName.empty()) { - BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis; + BMCWEB_LOG_ERROR("Failed to find '/' in {}", chassis); continue; } if (chassisName == chassisIdStr) @@ -584,11 +584,11 @@ void getChassis(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::make_shared<std::set<std::string>>(); reduceSensorList(asyncResp->res, chassisSubNode, sensorTypes, &nodeSensorList, culledSensorList); - BMCWEB_LOG_DEBUG << "Finishing with " << culledSensorList->size(); + BMCWEB_LOG_DEBUG("Finishing with {}", culledSensorList->size()); callback(culledSensorList); }); }); - BMCWEB_LOG_DEBUG << "getChassis exit"; + BMCWEB_LOG_DEBUG("getChassis exit"); } /** @@ -774,8 +774,8 @@ inline void objectPropertiesToJson( sensor::ReadingType readingType = sensors::toReadingType(sensorType); if (readingType == sensor::ReadingType::Invalid) { - BMCWEB_LOG_ERROR << "Redfish cannot map reading type for " - << sensorType; + BMCWEB_LOG_ERROR("Redfish cannot map reading type for {}", + sensorType); } else { @@ -785,8 +785,8 @@ inline void objectPropertiesToJson( std::string_view readingUnits = sensors::toReadingUnits(sensorType); if (readingUnits.empty()) { - BMCWEB_LOG_ERROR << "Redfish cannot map reading unit for " - << sensorType; + BMCWEB_LOG_ERROR("Redfish cannot map reading unit for {}", + sensorType); } else { @@ -843,7 +843,7 @@ inline void objectPropertiesToJson( } else { - BMCWEB_LOG_ERROR << "Redfish cannot map object type for " << sensorName; + BMCWEB_LOG_ERROR("Redfish cannot map object type for {}", sensorName); return; } // Map of dbus interface name, dbus property name and redfish property_name @@ -928,7 +928,7 @@ inline void objectPropertiesToJson( const double* doubleValue = std::get_if<double>(&valueVariant); if (doubleValue == nullptr) { - BMCWEB_LOG_ERROR << "Got value interface that wasn't double"; + BMCWEB_LOG_ERROR("Got value interface that wasn't double"); continue; } if (!std::isfinite(*doubleValue)) @@ -940,8 +940,8 @@ inline void objectPropertiesToJson( sensorJson[key] = nullptr; continue; } - BMCWEB_LOG_WARNING << "Sensor value for " << valueName - << " was unexpectedly " << *doubleValue; + BMCWEB_LOG_WARNING("Sensor value for {} was unexpectedly {}", + valueName, *doubleValue); continue; } if (forceToInt) @@ -979,7 +979,7 @@ inline void objectInterfacesToJson( objectPropertiesToJson(sensorName, sensorType, chassisSubNode, valuesDict, sensorJson, inventoryItem); } - BMCWEB_LOG_DEBUG << "Added sensor " << sensorName; + BMCWEB_LOG_DEBUG("Added sensor {}", sensorName); } inline void populateFanRedundancy( @@ -1059,7 +1059,7 @@ inline void populateFanRedundancy( if (allowedFailures == nullptr || collection == nullptr || status == nullptr) { - BMCWEB_LOG_ERROR << "Invalid redundancy interface"; + BMCWEB_LOG_ERROR("Invalid redundancy interface"); messages::internalError( sensorsAsyncResp->asyncResp->res); return; @@ -1120,7 +1120,7 @@ inline void populateFanRedundancy( } else { - BMCWEB_LOG_ERROR << "failed to find fan in schema"; + BMCWEB_LOG_ERROR("failed to find fan in schema"); messages::internalError( sensorsAsyncResp->asyncResp->res); return; @@ -1432,13 +1432,13 @@ static void getInventoryItemsData( std::shared_ptr<std::set<std::string>> invConnections, Callback&& callback, size_t invConnectionsIndex = 0) { - BMCWEB_LOG_DEBUG << "getInventoryItemsData enter"; + BMCWEB_LOG_DEBUG("getInventoryItemsData enter"); // If no more connections left, call callback if (invConnectionsIndex >= invConnections->size()) { callback(); - BMCWEB_LOG_DEBUG << "getInventoryItemsData exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsData exit"); return; } @@ -1457,11 +1457,11 @@ static void getInventoryItemsData( callback{std::forward<Callback>(callback)}, invConnectionsIndex]( const boost::system::error_code& ec, const dbus::utility::ManagedObjectType& resp) { - BMCWEB_LOG_DEBUG << "getInventoryItemsData respHandler enter"; + BMCWEB_LOG_DEBUG("getInventoryItemsData respHandler enter"); if (ec) { - BMCWEB_LOG_ERROR - << "getInventoryItemsData respHandler DBus error " << ec; + BMCWEB_LOG_ERROR( + "getInventoryItemsData respHandler DBus error {}", ec); messages::internalError(sensorsAsyncResp->asyncResp->res); return; } @@ -1487,11 +1487,11 @@ static void getInventoryItemsData( invConnections, std::move(callback), invConnectionsIndex + 1); - BMCWEB_LOG_DEBUG << "getInventoryItemsData respHandler exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsData respHandler exit"); }); } - BMCWEB_LOG_DEBUG << "getInventoryItemsData exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsData exit"); } /** @@ -1518,7 +1518,7 @@ static void getInventoryItemsConnections( const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getInventoryItemsConnections enter"; + BMCWEB_LOG_DEBUG("getInventoryItemsConnections enter"); const std::string path = "/xyz/openbmc_project/inventory"; constexpr std::array<std::string_view, 4> interfaces = { @@ -1535,12 +1535,12 @@ static void getInventoryItemsConnections( const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreeResponse& subtree) { // Response handler for parsing output from GetSubTree - BMCWEB_LOG_DEBUG << "getInventoryItemsConnections respHandler enter"; + BMCWEB_LOG_DEBUG("getInventoryItemsConnections respHandler enter"); if (ec) { messages::internalError(sensorsAsyncResp->asyncResp->res); - BMCWEB_LOG_ERROR - << "getInventoryItemsConnections respHandler DBus error " << ec; + BMCWEB_LOG_ERROR( + "getInventoryItemsConnections respHandler DBus error {}", ec); return; } @@ -1569,9 +1569,9 @@ static void getInventoryItemsConnections( } callback(invConnections); - BMCWEB_LOG_DEBUG << "getInventoryItemsConnections respHandler exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsConnections respHandler exit"); }); - BMCWEB_LOG_DEBUG << "getInventoryItemsConnections exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsConnections exit"); } /** @@ -1600,7 +1600,7 @@ static void getInventoryItemAssociations( const std::shared_ptr<std::set<std::string>>& sensorNames, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getInventoryItemAssociations enter"; + BMCWEB_LOG_DEBUG("getInventoryItemAssociations enter"); // Call GetManagedObjects on the ObjectMapper to get all associations sdbusplus::message::object_path path("/"); @@ -1609,11 +1609,11 @@ static void getInventoryItemAssociations( [callback{std::forward<Callback>(callback)}, sensorsAsyncResp, sensorNames](const boost::system::error_code& ec, const dbus::utility::ManagedObjectType& resp) { - BMCWEB_LOG_DEBUG << "getInventoryItemAssociations respHandler enter"; + BMCWEB_LOG_DEBUG("getInventoryItemAssociations respHandler enter"); if (ec) { - BMCWEB_LOG_ERROR - << "getInventoryItemAssociations respHandler DBus error " << ec; + BMCWEB_LOG_ERROR( + "getInventoryItemAssociations respHandler DBus error {}", ec); messages::internalError(sensorsAsyncResp->asyncResp->res); return; } @@ -1713,10 +1713,10 @@ static void getInventoryItemAssociations( } } callback(inventoryItems); - BMCWEB_LOG_DEBUG << "getInventoryItemAssociations respHandler exit"; + BMCWEB_LOG_DEBUG("getInventoryItemAssociations respHandler exit"); }); - BMCWEB_LOG_DEBUG << "getInventoryItemAssociations exit"; + BMCWEB_LOG_DEBUG("getInventoryItemAssociations exit"); } /** @@ -1755,13 +1755,13 @@ void getInventoryLedData( std::shared_ptr<std::map<std::string, std::string>> ledConnections, Callback&& callback, size_t ledConnectionsIndex = 0) { - BMCWEB_LOG_DEBUG << "getInventoryLedData enter"; + BMCWEB_LOG_DEBUG("getInventoryLedData enter"); // If no more connections left, call callback if (ledConnectionsIndex >= ledConnections->size()) { callback(); - BMCWEB_LOG_DEBUG << "getInventoryLedData exit"; + BMCWEB_LOG_DEBUG("getInventoryLedData exit"); return; } @@ -1777,16 +1777,16 @@ void getInventoryLedData( [sensorsAsyncResp, inventoryItems, ledConnections, ledPath, callback{std::forward<Callback>(callback)}, ledConnectionsIndex]( const boost::system::error_code& ec, const std::string& state) { - BMCWEB_LOG_DEBUG << "getInventoryLedData respHandler enter"; + BMCWEB_LOG_DEBUG("getInventoryLedData respHandler enter"); if (ec) { - BMCWEB_LOG_ERROR - << "getInventoryLedData respHandler DBus error " << ec; + BMCWEB_LOG_ERROR( + "getInventoryLedData respHandler DBus error {}", ec); messages::internalError(sensorsAsyncResp->asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Led state: " << state; + BMCWEB_LOG_DEBUG("Led state: {}", state); // Find inventory item with this LED object path InventoryItem* inventoryItem = findInventoryItemForLed(*inventoryItems, ledPath); @@ -1816,7 +1816,7 @@ void getInventoryLedData( ledConnections, std::move(callback), ledConnectionsIndex + 1); - BMCWEB_LOG_DEBUG << "getInventoryLedData respHandler exit"; + BMCWEB_LOG_DEBUG("getInventoryLedData respHandler exit"); }; // Get the State property for the current LED @@ -1826,7 +1826,7 @@ void getInventoryLedData( std::move(respHandler)); } - BMCWEB_LOG_DEBUG << "getInventoryLedData exit"; + BMCWEB_LOG_DEBUG("getInventoryLedData exit"); } /** @@ -1857,7 +1857,7 @@ void getInventoryLeds( std::shared_ptr<std::vector<InventoryItem>> inventoryItems, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getInventoryLeds enter"; + BMCWEB_LOG_DEBUG("getInventoryLeds enter"); const std::string path = "/xyz/openbmc_project"; constexpr std::array<std::string_view, 1> interfaces = { @@ -1871,12 +1871,11 @@ void getInventoryLeds( const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreeResponse& subtree) { // Response handler for parsing output from GetSubTree - BMCWEB_LOG_DEBUG << "getInventoryLeds respHandler enter"; + BMCWEB_LOG_DEBUG("getInventoryLeds respHandler enter"); if (ec) { messages::internalError(sensorsAsyncResp->asyncResp->res); - BMCWEB_LOG_ERROR << "getInventoryLeds respHandler DBus error " - << ec; + BMCWEB_LOG_ERROR("getInventoryLeds respHandler DBus error {}", ec); return; } @@ -1898,16 +1897,15 @@ void getInventoryLeds( // Add mapping from ledPath to connection const std::string& connection = object.second.begin()->first; (*ledConnections)[ledPath] = connection; - BMCWEB_LOG_DEBUG << "Added mapping " << ledPath << " -> " - << connection; + BMCWEB_LOG_DEBUG("Added mapping {} -> {}", ledPath, connection); } } getInventoryLedData(sensorsAsyncResp, inventoryItems, ledConnections, std::move(callback)); - BMCWEB_LOG_DEBUG << "getInventoryLeds respHandler exit"; + BMCWEB_LOG_DEBUG("getInventoryLeds respHandler exit"); }); - BMCWEB_LOG_DEBUG << "getInventoryLeds exit"; + BMCWEB_LOG_DEBUG("getInventoryLeds exit"); } /** @@ -1941,11 +1939,11 @@ void getPowerSupplyAttributesData( const std::map<std::string, std::string>& psAttributesConnections, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributesData enter"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributesData enter"); if (psAttributesConnections.empty()) { - BMCWEB_LOG_DEBUG << "Can't find PowerSupplyAttributes, no connections!"; + BMCWEB_LOG_DEBUG("Can't find PowerSupplyAttributes, no connections!"); callback(inventoryItems); return; } @@ -1961,16 +1959,16 @@ void getPowerSupplyAttributesData( [sensorsAsyncResp, inventoryItems, callback{std::forward<Callback>(callback)}]( const boost::system::error_code& ec, const uint32_t value) { - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributesData respHandler enter"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributesData respHandler enter"); if (ec) { - BMCWEB_LOG_ERROR - << "getPowerSupplyAttributesData respHandler DBus error " << ec; + BMCWEB_LOG_ERROR( + "getPowerSupplyAttributesData respHandler DBus error {}", ec); messages::internalError(sensorsAsyncResp->asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "PS EfficiencyPercent value: " << value; + BMCWEB_LOG_DEBUG("PS EfficiencyPercent value: {}", value); // Store value in Power Supply Inventory Items for (InventoryItem& inventoryItem : *inventoryItems) { @@ -1981,7 +1979,7 @@ void getPowerSupplyAttributesData( } } - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributesData respHandler exit"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributesData respHandler exit"); callback(inventoryItems); }; @@ -1992,7 +1990,7 @@ void getPowerSupplyAttributesData( "xyz.openbmc_project.Control.PowerSupplyAttributes", "DeratingFactor", std::move(respHandler)); - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributesData exit"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributesData exit"); } /** @@ -2024,12 +2022,12 @@ void getPowerSupplyAttributes( std::shared_ptr<std::vector<InventoryItem>> inventoryItems, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes enter"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributes enter"); // Only need the power supply attributes when the Power Schema if (sensorsAsyncResp->chassisSubNode != sensors::node::power) { - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes exit since not Power"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributes exit since not Power"); callback(inventoryItems); return; } @@ -2045,17 +2043,17 @@ void getPowerSupplyAttributes( const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreeResponse& subtree) { // Response handler for parsing output from GetSubTree - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes respHandler enter"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributes respHandler enter"); if (ec) { messages::internalError(sensorsAsyncResp->asyncResp->res); - BMCWEB_LOG_ERROR - << "getPowerSupplyAttributes respHandler DBus error " << ec; + BMCWEB_LOG_ERROR( + "getPowerSupplyAttributes respHandler DBus error {}", ec); return; } if (subtree.empty()) { - BMCWEB_LOG_DEBUG << "Can't find Power Supply Attributes!"; + BMCWEB_LOG_DEBUG("Can't find Power Supply Attributes!"); callback(inventoryItems); return; } @@ -2067,7 +2065,7 @@ void getPowerSupplyAttributes( if (subtree[0].first.empty() || subtree[0].second.empty()) { - BMCWEB_LOG_DEBUG << "Power Supply Attributes mapper error!"; + BMCWEB_LOG_DEBUG("Power Supply Attributes mapper error!"); callback(inventoryItems); return; } @@ -2077,21 +2075,21 @@ void getPowerSupplyAttributes( if (connection.empty()) { - BMCWEB_LOG_DEBUG << "Power Supply Attributes mapper error!"; + BMCWEB_LOG_DEBUG("Power Supply Attributes mapper error!"); callback(inventoryItems); return; } psAttributesConnections[psAttributesPath] = connection; - BMCWEB_LOG_DEBUG << "Added mapping " << psAttributesPath << " -> " - << connection; + BMCWEB_LOG_DEBUG("Added mapping {} -> {}", psAttributesPath, + connection); getPowerSupplyAttributesData(sensorsAsyncResp, inventoryItems, psAttributesConnections, std::move(callback)); - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes respHandler exit"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributes respHandler exit"); }); - BMCWEB_LOG_DEBUG << "getPowerSupplyAttributes exit"; + BMCWEB_LOG_DEBUG("getPowerSupplyAttributes exit"); } /** @@ -2122,52 +2120,52 @@ static void const std::shared_ptr<std::set<std::string>> sensorNames, Callback&& callback) { - BMCWEB_LOG_DEBUG << "getInventoryItems enter"; + BMCWEB_LOG_DEBUG("getInventoryItems enter"); auto getInventoryItemAssociationsCb = [sensorsAsyncResp, callback{std::forward<Callback>(callback)}]( std::shared_ptr<std::vector<InventoryItem>> inventoryItems) { - BMCWEB_LOG_DEBUG << "getInventoryItemAssociationsCb enter"; + BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb enter"); auto getInventoryItemsConnectionsCb = [sensorsAsyncResp, inventoryItems, callback{std::forward<const Callback>(callback)}]( std::shared_ptr<std::set<std::string>> invConnections) { - BMCWEB_LOG_DEBUG << "getInventoryItemsConnectionsCb enter"; + BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb enter"); auto getInventoryItemsDataCb = [sensorsAsyncResp, inventoryItems, callback{std::move(callback)}]() { - BMCWEB_LOG_DEBUG << "getInventoryItemsDataCb enter"; + BMCWEB_LOG_DEBUG("getInventoryItemsDataCb enter"); auto getInventoryLedsCb = [sensorsAsyncResp, inventoryItems, callback{std::move(callback)}]() { - BMCWEB_LOG_DEBUG << "getInventoryLedsCb enter"; + BMCWEB_LOG_DEBUG("getInventoryLedsCb enter"); // Find Power Supply Attributes and get the data getPowerSupplyAttributes(sensorsAsyncResp, inventoryItems, std::move(callback)); - BMCWEB_LOG_DEBUG << "getInventoryLedsCb exit"; + BMCWEB_LOG_DEBUG("getInventoryLedsCb exit"); }; // Find led connections and get the data getInventoryLeds(sensorsAsyncResp, inventoryItems, std::move(getInventoryLedsCb)); - BMCWEB_LOG_DEBUG << "getInventoryItemsDataCb exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsDataCb exit"); }; // Get inventory item data from connections getInventoryItemsData(sensorsAsyncResp, inventoryItems, invConnections, std::move(getInventoryItemsDataCb)); - BMCWEB_LOG_DEBUG << "getInventoryItemsConnectionsCb exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsConnectionsCb exit"); }; // Get connections that provide inventory item data getInventoryItemsConnections(sensorsAsyncResp, inventoryItems, std::move(getInventoryItemsConnectionsCb)); - BMCWEB_LOG_DEBUG << "getInventoryItemAssociationsCb exit"; + BMCWEB_LOG_DEBUG("getInventoryItemAssociationsCb exit"); }; // Get associations from sensors to inventory items getInventoryItemAssociations(sensorsAsyncResp, sensorNames, std::move(getInventoryItemAssociationsCb)); - BMCWEB_LOG_DEBUG << "getInventoryItems exit"; + BMCWEB_LOG_DEBUG("getInventoryItems exit"); } /** @@ -2258,7 +2256,7 @@ inline void getSensorData( const std::set<std::string>& connections, const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems) { - BMCWEB_LOG_DEBUG << "getSensorData enter"; + BMCWEB_LOG_DEBUG("getSensorData enter"); // Get managed objects from all services exposing sensors for (const std::string& connection : connections) { @@ -2269,10 +2267,10 @@ inline void getSensorData( [sensorsAsyncResp, sensorNames, inventoryItems](const boost::system::error_code& ec, const dbus::utility::ManagedObjectType& resp) { - BMCWEB_LOG_DEBUG << "getManagedObjectsCb enter"; + BMCWEB_LOG_DEBUG("getManagedObjectsCb enter"); if (ec) { - BMCWEB_LOG_ERROR << "getManagedObjectsCb DBUS error: " << ec; + BMCWEB_LOG_ERROR("getManagedObjectsCb DBUS error: {}", ec); messages::internalError(sensorsAsyncResp->asyncResp->res); return; } @@ -2281,8 +2279,8 @@ inline void getSensorData( { const std::string& objPath = static_cast<const std::string&>(objDictEntry.first); - BMCWEB_LOG_DEBUG << "getManagedObjectsCb parsing object " - << objPath; + BMCWEB_LOG_DEBUG("getManagedObjectsCb parsing object {}", + objPath); std::vector<std::string> split; // Reserve space for @@ -2292,19 +2290,19 @@ inline void getSensorData( bmcweb::split(split, objPath, '/'); if (split.size() < 6) { - BMCWEB_LOG_ERROR << "Got path that isn't long enough " - << objPath; + BMCWEB_LOG_ERROR("Got path that isn't long enough {}", + objPath); continue; } // These indexes aren't intuitive, as split puts an empty // string at the beginning const std::string& sensorType = split[4]; const std::string& sensorName = split[5]; - BMCWEB_LOG_DEBUG << "sensorName " << sensorName - << " sensorType " << sensorType; + BMCWEB_LOG_DEBUG("sensorName {} sensorType {}", sensorName, + sensorType); if (sensorNames->find(objPath) == sensorNames->end()) { - BMCWEB_LOG_DEBUG << sensorName << " not in sensor list "; + BMCWEB_LOG_DEBUG("{} not in sensor list ", sensorName); continue; } @@ -2375,8 +2373,8 @@ inline void getSensorData( } else { - BMCWEB_LOG_ERROR << "Unsure how to handle sensorType " - << sensorType; + BMCWEB_LOG_ERROR("Unsure how to handle sensorType {}", + sensorType); continue; } @@ -2476,10 +2474,10 @@ inline void getSensorData( populateFanRedundancy(sensorsAsyncResp); } } - BMCWEB_LOG_DEBUG << "getManagedObjectsCb exit"; + BMCWEB_LOG_DEBUG("getManagedObjectsCb exit"); }); } - BMCWEB_LOG_DEBUG << "getSensorData exit"; + BMCWEB_LOG_DEBUG("getSensorData exit"); } inline void @@ -2488,23 +2486,23 @@ inline void { auto getConnectionCb = [sensorsAsyncResp, sensorNames]( const std::set<std::string>& connections) { - BMCWEB_LOG_DEBUG << "getConnectionCb enter"; + BMCWEB_LOG_DEBUG("getConnectionCb enter"); auto getInventoryItemsCb = [sensorsAsyncResp, sensorNames, connections](const std::shared_ptr<std::vector<InventoryItem>>& inventoryItems) { - BMCWEB_LOG_DEBUG << "getInventoryItemsCb enter"; + BMCWEB_LOG_DEBUG("getInventoryItemsCb enter"); // Get sensor data and store results in JSON getSensorData(sensorsAsyncResp, sensorNames, connections, inventoryItems); - BMCWEB_LOG_DEBUG << "getInventoryItemsCb exit"; + BMCWEB_LOG_DEBUG("getInventoryItemsCb exit"); }; // Get inventory items associated with sensors getInventoryItems(sensorsAsyncResp, sensorNames, std::move(getInventoryItemsCb)); - BMCWEB_LOG_DEBUG << "getConnectionCb exit"; + BMCWEB_LOG_DEBUG("getConnectionCb exit"); }; // Get set of connections that provide sensor values @@ -2519,13 +2517,13 @@ inline void inline void getChassisData(const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp) { - BMCWEB_LOG_DEBUG << "getChassisData enter"; + BMCWEB_LOG_DEBUG("getChassisData enter"); auto getChassisCb = [sensorsAsyncResp]( const std::shared_ptr<std::set<std::string>>& sensorNames) { - BMCWEB_LOG_DEBUG << "getChassisCb enter"; + BMCWEB_LOG_DEBUG("getChassisCb enter"); processSensorList(sensorsAsyncResp, sensorNames); - BMCWEB_LOG_DEBUG << "getChassisCb exit"; + BMCWEB_LOG_DEBUG("getChassisCb exit"); }; // SensorCollection doesn't contain the Redundancy property if (sensorsAsyncResp->chassisSubNode != sensors::node::sensors) @@ -2537,7 +2535,7 @@ inline void getChassis(sensorsAsyncResp->asyncResp, sensorsAsyncResp->chassisId, sensorsAsyncResp->chassisSubNode, sensorsAsyncResp->types, std::move(getChassisCb)); - BMCWEB_LOG_DEBUG << "getChassisData exit"; + BMCWEB_LOG_DEBUG("getChassisData exit"); } /** @@ -2601,8 +2599,8 @@ inline void setSensorsOverride( std::unordered_map<std::string, std::vector<nlohmann::json>>& allCollections) { - BMCWEB_LOG_INFO << "setSensorsOverride for subNode" - << sensorAsyncResp->chassisSubNode << "\n"; + BMCWEB_LOG_INFO("setSensorsOverride for subNode{}", + sensorAsyncResp->chassisSubNode); const char* propertyValueName = nullptr; std::unordered_map<std::string, std::pair<double, std::string>> overrideMap; @@ -2650,7 +2648,7 @@ inline void setSensorsOverride( if (!findSensorNameUsingSensorPath(sensorNameType.second, *sensorsList, *sensorNames)) { - BMCWEB_LOG_INFO << "Unable to find memberId " << item.first; + BMCWEB_LOG_INFO("Unable to find memberId {}", item.first); messages::resourceNotFound(sensorAsyncResp->asyncResp->res, item.second.second, item.first); return; @@ -2664,10 +2662,9 @@ inline void setSensorsOverride( objectsWithConnection) { if (objectsWithConnection.size() != overrideMap.size()) { - BMCWEB_LOG_INFO - << "Unable to find all objects with proper connection " - << objectsWithConnection.size() << " requested " - << overrideMap.size() << "\n"; + BMCWEB_LOG_INFO( + "Unable to find all objects with proper connection {} requested {}", + objectsWithConnection.size(), overrideMap.size()); messages::resourceNotFound(sensorAsyncResp->asyncResp->res, sensorAsyncResp->chassisSubNode == sensors::node::thermal @@ -2689,8 +2686,8 @@ inline void setSensorsOverride( const auto& iterator = overrideMap.find(sensorName); if (iterator == overrideMap.end()) { - BMCWEB_LOG_INFO << "Unable to find sensor object" - << item.first << "\n"; + BMCWEB_LOG_INFO("Unable to find sensor object{}", + item.first); messages::internalError(sensorAsyncResp->asyncResp->res); return; } @@ -2704,16 +2701,16 @@ inline void setSensorsOverride( if (ec.value() == boost::system::errc::permission_denied) { - BMCWEB_LOG_WARNING - << "Manufacturing mode is not Enabled...can't " - "Override the sensor value. "; + BMCWEB_LOG_WARNING( + "Manufacturing mode is not Enabled...can't " + "Override the sensor value. "); messages::insufficientPrivilege( sensorAsyncResp->asyncResp->res); return; } - BMCWEB_LOG_DEBUG - << "setOverrideValueStatus DBUS error: " << ec; + BMCWEB_LOG_DEBUG( + "setOverrideValueStatus DBUS error: {}", ec); messages::internalError( sensorAsyncResp->asyncResp->res); } @@ -2751,7 +2748,7 @@ inline void retrieveUriToDbusMap(const std::string& chassis, [&node](auto&& val) { return val.first == node; }); if (pathIt == sensors::paths.cend()) { - BMCWEB_LOG_ERROR << "Wrong node provided : " << node; + BMCWEB_LOG_ERROR("Wrong node provided : {}", node); mapComplete(boost::beast::http::status::bad_request, {}); return; } @@ -2776,18 +2773,18 @@ inline void getChassisCallback( std::string_view chassisId, std::string_view chassisSubNode, const std::shared_ptr<std::set<std::string>>& sensorNames) { - BMCWEB_LOG_DEBUG << "getChassisCallback enter "; + BMCWEB_LOG_DEBUG("getChassisCallback enter "); nlohmann::json& entriesArray = asyncResp->res.jsonValue["Members"]; for (const std::string& sensor : *sensorNames) { - BMCWEB_LOG_DEBUG << "Adding sensor: " << sensor; + BMCWEB_LOG_DEBUG("Adding sensor: {}", sensor); sdbusplus::message::object_path path(sensor); std::string sensorName = path.filename(); if (sensorName.empty()) { - BMCWEB_LOG_ERROR << "Invalid sensor path: " << sensor; + BMCWEB_LOG_ERROR("Invalid sensor path: {}", sensor); messages::internalError(asyncResp->res); return; } @@ -2807,7 +2804,7 @@ inline void getChassisCallback( } asyncResp->res.jsonValue["Members@odata.count"] = entriesArray.size(); - BMCWEB_LOG_DEBUG << "getChassisCallback exit"; + BMCWEB_LOG_DEBUG("getChassisCallback exit"); } inline void handleSensorCollectionGet( @@ -2834,8 +2831,8 @@ inline void handleSensorCollectionGet( /*efficientExpand=*/true); getChassisData(sensorsAsyncResp); - BMCWEB_LOG_DEBUG - << "SensorCollection doGet exit via efficient expand handler"; + BMCWEB_LOG_DEBUG( + "SensorCollection doGet exit via efficient expand handler"); return; } @@ -2858,8 +2855,8 @@ inline void } const auto& valueIface = *mapperResponse.begin(); const std::string& connectionName = valueIface.first; - BMCWEB_LOG_DEBUG << "Looking up " << connectionName; - BMCWEB_LOG_DEBUG << "Path " << sensorPath; + BMCWEB_LOG_DEBUG("Looking up {}", connectionName); + BMCWEB_LOG_DEBUG("Path {}", sensorPath); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, connectionName, sensorPath, "", @@ -2900,7 +2897,7 @@ inline void handleSensorGet(App& app, const crow::Request& req, asyncResp->res.jsonValue["@odata.id"] = boost::urls::format( "/redfish/v1/Chassis/{}/Sensors/{}", chassisId, sensorId); - BMCWEB_LOG_DEBUG << "Sensor doGet enter"; + BMCWEB_LOG_DEBUG("Sensor doGet enter"); constexpr std::array<std::string_view, 1> interfaces = { "xyz.openbmc_project.Sensor.Value"}; @@ -2913,22 +2910,22 @@ inline void handleSensorGet(App& app, const crow::Request& req, [asyncResp, sensorId, sensorPath](const boost::system::error_code& ec, const ::dbus::utility::MapperGetObject& subtree) { - BMCWEB_LOG_DEBUG << "respHandler1 enter"; + BMCWEB_LOG_DEBUG("respHandler1 enter"); if (ec == boost::system::errc::io_error) { - BMCWEB_LOG_WARNING << "Sensor not found from getSensorPaths"; + BMCWEB_LOG_WARNING("Sensor not found from getSensorPaths"); messages::resourceNotFound(asyncResp->res, sensorId, "Sensor"); return; } if (ec) { messages::internalError(asyncResp->res); - BMCWEB_LOG_ERROR << "Sensor getSensorPaths resp_handler: " - << "Dbus error " << ec; + BMCWEB_LOG_ERROR( + "Sensor getSensorPaths resp_handler: Dbus error {}", ec); return; } getSensorFromDbus(asyncResp, sensorPath, subtree); - BMCWEB_LOG_DEBUG << "respHandler1 exit"; + BMCWEB_LOG_DEBUG("respHandler1 exit"); }); } diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp index 6b60ae75fa..1f41ea8685 100644 --- a/redfish-core/lib/storage.hpp +++ b/redfish-core/lib/storage.hpp @@ -110,7 +110,7 @@ inline void afterChassisDriveCollectionSubtree( { if (ec) { - BMCWEB_LOG_ERROR << "Drive mapper call error"; + BMCWEB_LOG_ERROR("Drive mapper call error"); messages::internalError(asyncResp->res); return; } @@ -131,7 +131,7 @@ inline void afterChassisDriveCollectionSubtree( sdbusplus::message::object_path object(drive); if (object.filename().empty()) { - BMCWEB_LOG_ERROR << "Failed to find filename in " << drive; + BMCWEB_LOG_ERROR("Failed to find filename in {}", drive); return; } @@ -161,7 +161,7 @@ inline void afterSystemsStorageGetSubtree( { if (ec) { - BMCWEB_LOG_DEBUG << "requestRoutesStorage DBUS response error"; + BMCWEB_LOG_DEBUG("requestRoutesStorage DBUS response error"); messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage", storageId); return; @@ -230,7 +230,7 @@ inline void afterSubtree(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { if (ec) { - BMCWEB_LOG_DEBUG << "requestRoutesStorage DBUS response error"; + BMCWEB_LOG_DEBUG("requestRoutesStorage DBUS response error"); messages::resourceNotFound(asyncResp->res, "#Storage.v1_13_0.Storage", storageId); return; @@ -274,7 +274,7 @@ inline void { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { - BMCWEB_LOG_DEBUG << "requestRoutesStorage setUpRedfishRoute failed"; + BMCWEB_LOG_DEBUG("requestRoutesStorage setUpRedfishRoute failed"); return; } @@ -478,7 +478,7 @@ inline void if (value == nullptr) { // illegal property - BMCWEB_LOG_ERROR << "Illegal property: Type"; + BMCWEB_LOG_ERROR("Illegal property: Type"); messages::internalError(asyncResp->res); return; } @@ -487,8 +487,8 @@ inline void convertDriveType(*value); if (!mediaType) { - BMCWEB_LOG_WARNING << "UnknownDriveType Interface: " - << *value; + BMCWEB_LOG_WARNING("UnknownDriveType Interface: {}", + *value); continue; } if (*mediaType == drive::MediaType::Invalid) @@ -505,7 +505,7 @@ inline void std::get_if<uint64_t>(&property.second); if (capacity == nullptr) { - BMCWEB_LOG_ERROR << "Illegal property: Capacity"; + BMCWEB_LOG_ERROR("Illegal property: Capacity"); messages::internalError(asyncResp->res); return; } @@ -523,7 +523,7 @@ inline void std::get_if<std::string>(&property.second); if (value == nullptr) { - BMCWEB_LOG_ERROR << "Illegal property: Protocol"; + BMCWEB_LOG_ERROR("Illegal property: Protocol"); messages::internalError(asyncResp->res); return; } @@ -532,8 +532,8 @@ inline void convertDriveProtocol(*value); if (!proto) { - BMCWEB_LOG_WARNING << "Unknown DrivePrototype Interface: " - << *value; + BMCWEB_LOG_WARNING("Unknown DrivePrototype Interface: {}", + *value); continue; } if (*proto == protocol::Protocol::Invalid) @@ -549,8 +549,8 @@ inline void std::get_if<uint8_t>(&property.second); if (lifeLeft == nullptr) { - BMCWEB_LOG_ERROR - << "Illegal property: PredictedMediaLifeLeftPercent"; + BMCWEB_LOG_ERROR( + "Illegal property: PredictedMediaLifeLeftPercent"); messages::internalError(asyncResp->res); return; } @@ -566,7 +566,7 @@ inline void encryptionStatus = std::get_if<std::string>(&property.second); if (encryptionStatus == nullptr) { - BMCWEB_LOG_ERROR << "Illegal property: EncryptionStatus"; + BMCWEB_LOG_ERROR("Illegal property: EncryptionStatus"); messages::internalError(asyncResp->res); return; } @@ -576,7 +576,7 @@ inline void isLocked = std::get_if<bool>(&property.second); if (isLocked == nullptr) { - BMCWEB_LOG_ERROR << "Illegal property: Locked"; + BMCWEB_LOG_ERROR("Illegal property: Locked"); messages::internalError(asyncResp->res); return; } @@ -646,7 +646,7 @@ inline void afterGetSubtreeSystemsStorageDrive( { if (ec) { - BMCWEB_LOG_ERROR << "Drive mapper call error"; + BMCWEB_LOG_ERROR("Drive mapper call error"); messages::internalError(asyncResp->res); return; } @@ -676,8 +676,8 @@ inline void afterGetSubtreeSystemsStorageDrive( if (connectionNames.size() != 1) { - BMCWEB_LOG_ERROR << "Connection size " << connectionNames.size() - << ", not equal to 1"; + BMCWEB_LOG_ERROR("Connection size {}, not equal to 1", + connectionNames.size()); messages::internalError(asyncResp->res); return; } @@ -770,7 +770,7 @@ inline void afterChassisDriveCollectionSubtreeGet( if (connectionNames.empty()) { - BMCWEB_LOG_ERROR << "Got 0 Connection names"; + BMCWEB_LOG_ERROR("Got 0 Connection names"); continue; } @@ -787,7 +787,7 @@ inline void afterChassisDriveCollectionSubtreeGet( const dbus::utility::MapperEndPoints& resp) { if (ec3) { - BMCWEB_LOG_ERROR << "Error in chassis Drive association "; + BMCWEB_LOG_ERROR("Error in chassis Drive association "); } nlohmann::json& members = asyncResp->res.jsonValue["Members"]; // important if array is empty @@ -856,7 +856,7 @@ inline void buildDrive(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -872,7 +872,7 @@ inline void buildDrive(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, if (connectionNames.empty()) { - BMCWEB_LOG_ERROR << "Got 0 Connection names"; + BMCWEB_LOG_ERROR("Got 0 Connection names"); continue; } @@ -959,7 +959,7 @@ inline void if (connectionNames.empty()) { - BMCWEB_LOG_ERROR << "Got 0 Connection names"; + BMCWEB_LOG_ERROR("Got 0 Connection names"); continue; } @@ -999,7 +999,7 @@ inline void getStorageControllerAsset( if (ec) { // this interface isn't necessary - BMCWEB_LOG_DEBUG << "Failed to get StorageControllerAsset"; + BMCWEB_LOG_DEBUG("Failed to get StorageControllerAsset"); return; } @@ -1058,7 +1058,7 @@ inline void populateStorageController( // if we get a good return if (ec) { - BMCWEB_LOG_DEBUG << "Failed to get Present property"; + BMCWEB_LOG_DEBUG("Failed to get Present property"); return; } if (!isPresent) @@ -1086,7 +1086,7 @@ inline void getStorageControllerHandler( if (ec || subtree.empty()) { // doesn't have to be there - BMCWEB_LOG_DEBUG << "Failed to handle StorageController"; + BMCWEB_LOG_DEBUG("Failed to handle StorageController"); return; } @@ -1096,7 +1096,7 @@ inline void getStorageControllerHandler( std::string id = object.filename(); if (id.empty()) { - BMCWEB_LOG_ERROR << "Failed to find filename in " << path; + BMCWEB_LOG_ERROR("Failed to find filename in {}", path); return; } if (id != controllerId) @@ -1106,8 +1106,8 @@ inline void getStorageControllerHandler( if (interfaceDict.size() != 1) { - BMCWEB_LOG_ERROR << "Connection size " << interfaceDict.size() - << ", greater than 1"; + BMCWEB_LOG_ERROR("Connection size {}, greater than 1", + interfaceDict.size()); messages::internalError(asyncResp->res); return; } @@ -1128,7 +1128,7 @@ inline void populateStorageControllerCollection( { asyncResp->res.jsonValue["Members"] = std::move(members); asyncResp->res.jsonValue["Members@odata.count"] = 0; - BMCWEB_LOG_DEBUG << "Failed to find any StorageController"; + BMCWEB_LOG_DEBUG("Failed to find any StorageController"); return; } @@ -1137,7 +1137,7 @@ inline void populateStorageControllerCollection( std::string id = sdbusplus::message::object_path(path).filename(); if (id.empty()) { - BMCWEB_LOG_ERROR << "Failed to find filename in " << path; + BMCWEB_LOG_ERROR("Failed to find filename in {}", path); return; } nlohmann::json::object_t member; @@ -1156,15 +1156,15 @@ inline void handleSystemsStorageControllerCollectionGet( { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { - BMCWEB_LOG_DEBUG - << "Failed to setup Redfish Route for StorageController Collection"; + BMCWEB_LOG_DEBUG( + "Failed to setup Redfish Route for StorageController Collection"); return; } if (systemName != "system") { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); - BMCWEB_LOG_DEBUG << "Failed to find ComputerSystem of " << systemName; + BMCWEB_LOG_DEBUG("Failed to find ComputerSystem of {}", systemName); return; } @@ -1192,15 +1192,14 @@ inline void handleSystemsStorageControllerGet( { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { - BMCWEB_LOG_DEBUG - << "Failed to setup Redfish Route for StorageController"; + BMCWEB_LOG_DEBUG("Failed to setup Redfish Route for StorageController"); return; } if (systemName != "system") { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); - BMCWEB_LOG_DEBUG << "Failed to find ComputerSystem of " << systemName; + BMCWEB_LOG_DEBUG("Failed to find ComputerSystem of {}", systemName); return; } constexpr std::array<std::string_view, 1> interfaces = { diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index 69ef4908d1..609af7156a 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp @@ -64,7 +64,7 @@ inline void updateDimmProperties(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, bool isDimmFunctional) { - BMCWEB_LOG_DEBUG << "Dimm Functional: " << isDimmFunctional; + BMCWEB_LOG_DEBUG("Dimm Functional: {}", isDimmFunctional); // Set it as Enabled if at least one DIMM is functional // Update STATE only if previous State was DISABLED and current Dimm is @@ -93,7 +93,7 @@ inline void inline void modifyCpuFunctionalState( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, bool isCpuFunctional) { - BMCWEB_LOG_DEBUG << "Cpu Functional: " << isCpuFunctional; + BMCWEB_LOG_DEBUG("Cpu Functional: {}", isCpuFunctional); const nlohmann::json& prevProcState = asyncResp->res.jsonValue["ProcessorSummary"]["Status"]["State"]; @@ -123,7 +123,7 @@ inline void modifyCpuPresenceState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, bool isCpuPresent) { - BMCWEB_LOG_DEBUG << "Cpu Present: " << isCpuPresent; + BMCWEB_LOG_DEBUG("Cpu Present: {}", isCpuPresent); if (isCpuPresent) { @@ -144,7 +144,7 @@ inline void getProcessorProperties( const std::vector<std::pair<std::string, dbus::utility::DbusVariantType>>& properties) { - BMCWEB_LOG_DEBUG << "Got " << properties.size() << " Cpu properties."; + BMCWEB_LOG_DEBUG("Got {} Cpu properties.", properties.size()); // TODO: Get Model @@ -193,7 +193,7 @@ inline void const bool cpuPresenceCheck) { if (ec3) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec3; + BMCWEB_LOG_ERROR("DBUS response error {}", ec3); return; } modifyCpuPresenceState(asyncResp, cpuPresenceCheck); @@ -212,7 +212,7 @@ inline void const bool cpuFunctionalCheck) { if (ec3) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec3; + BMCWEB_LOG_ERROR("DBUS response error {}", ec3); return; } modifyCpuFunctionalState(asyncResp, cpuFunctionalCheck); @@ -233,7 +233,7 @@ inline void const dbus::utility::DBusPropertiesMap& properties) { if (ec2) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec2; + BMCWEB_LOG_ERROR("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -257,7 +257,7 @@ inline void [[maybe_unused]] const std::string& path, const dbus::utility::DBusPropertiesMap& properties) { - BMCWEB_LOG_DEBUG << "Got " << properties.size() << " Dimm properties."; + BMCWEB_LOG_DEBUG("Got {} Dimm properties.", properties.size()); if (properties.empty()) { @@ -272,7 +272,7 @@ inline void bool dimmState) { if (ec3) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec3; + BMCWEB_LOG_ERROR("DBUS response error {}", ec3); return; } updateDimmProperties(asyncResp, dimmState); @@ -338,7 +338,7 @@ inline void const dbus::utility::DBusPropertiesMap& properties) { if (ec2) { - BMCWEB_LOG_ERROR << "DBUS response error " << ec2; + BMCWEB_LOG_ERROR("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -358,7 +358,7 @@ inline void getComputerSystem(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::shared_ptr<HealthPopulate>& systemHealth) { - BMCWEB_LOG_DEBUG << "Get available system components."; + BMCWEB_LOG_DEBUG("Get available system components."); constexpr std::array<std::string_view, 5> interfaces = { "xyz.openbmc_project.Inventory.Decorator.Asset", "xyz.openbmc_project.Inventory.Item.Cpu", @@ -373,7 +373,7 @@ inline void const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); messages::internalError(asyncResp->res); return; } @@ -384,7 +384,7 @@ inline void object : subtree) { const std::string& path = object.first; - BMCWEB_LOG_DEBUG << "Got path: " << path; + BMCWEB_LOG_DEBUG("Got path: {}", path); const std::vector<std::pair<std::string, std::vector<std::string>>>& connectionNames = object.second; if (connectionNames.empty()) @@ -419,8 +419,7 @@ inline void if (interfaceName == "xyz.openbmc_project.Inventory.Item.Dimm") { - BMCWEB_LOG_DEBUG - << "Found Dimm, now get its properties."; + BMCWEB_LOG_DEBUG("Found Dimm, now get its properties."); getMemorySummary(asyncResp, connection.first, path); @@ -432,8 +431,7 @@ inline void else if (interfaceName == "xyz.openbmc_project.Inventory.Item.Cpu") { - BMCWEB_LOG_DEBUG - << "Found Cpu, now get its properties."; + BMCWEB_LOG_DEBUG("Found Cpu, now get its properties."); getProcessorSummary(asyncResp, connection.first, path); @@ -444,8 +442,7 @@ inline void } else if (interfaceName == "xyz.openbmc_project.Common.UUID") { - BMCWEB_LOG_DEBUG - << "Found UUID, now get its properties."; + BMCWEB_LOG_DEBUG("Found UUID, now get its properties."); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, connection.first, @@ -455,13 +452,12 @@ inline void properties) { if (ec3) { - BMCWEB_LOG_DEBUG << "DBUS response error " - << ec3; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec3); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Got " << properties.size() - << " UUID properties."; + BMCWEB_LOG_DEBUG("Got {} UUID properties.", + properties.size()); const std::string* uUID = nullptr; @@ -486,7 +482,7 @@ inline void valueStr.insert(18, 1, '-'); valueStr.insert(23, 1, '-'); } - BMCWEB_LOG_DEBUG << "UUID = " << valueStr; + BMCWEB_LOG_DEBUG("UUID = {}", valueStr); asyncResp->res.jsonValue["UUID"] = valueStr; } }); @@ -507,8 +503,8 @@ inline void // interface return; } - BMCWEB_LOG_DEBUG << "Got " << propertiesList.size() - << " properties for system"; + BMCWEB_LOG_DEBUG("Got {} properties for system", + propertiesList.size()); const std::string* partNumber = nullptr; const std::string* serialNumber = nullptr; @@ -598,7 +594,7 @@ inline void */ inline void getHostState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get host information."; + BMCWEB_LOG_DEBUG("Get host information."); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0", "xyz.openbmc_project.State.Host", @@ -611,15 +607,15 @@ inline void getHostState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { // Service not available, no error, just don't return // host state info - BMCWEB_LOG_DEBUG << "Service not available " << ec; + BMCWEB_LOG_DEBUG("Service not available {}", ec); return; } - BMCWEB_LOG_ERROR << "DBUS response error " << ec; + BMCWEB_LOG_ERROR("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Host state: " << hostState; + BMCWEB_LOG_DEBUG("Host state: {}", hostState); // Verify Host State if (hostState == "xyz.openbmc_project.State.Host.HostState.Running") { @@ -814,8 +810,7 @@ inline std::string dbusToRfBootProgress(const std::string& dbusBootProgress) } else { - BMCWEB_LOG_DEBUG << "Unsupported D-Bus BootProgress " - << dbusBootProgress; + BMCWEB_LOG_DEBUG("Unsupported D-Bus BootProgress {}", dbusBootProgress); // Just return the default } return rfBpLastState; @@ -870,9 +865,9 @@ inline int } else { - BMCWEB_LOG_DEBUG - << "Invalid property value for BootSourceOverrideTarget: " - << bootSource; + BMCWEB_LOG_DEBUG( + "Invalid property value for BootSourceOverrideTarget: {}", + bootSource); messages::propertyValueNotInList(asyncResp->res, rfSource, "BootSourceTargetOverride"); return -1; @@ -902,7 +897,7 @@ inline void getBootProgress(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) return; } - BMCWEB_LOG_DEBUG << "Boot Progress: " << bootProgressStr; + BMCWEB_LOG_DEBUG("Boot Progress: {}", bootProgressStr); asyncResp->res.jsonValue["BootProgress"]["LastState"] = dbusToRfBootProgress(bootProgressStr); @@ -927,7 +922,7 @@ inline void getBootProgressLastStateTime( const uint64_t lastStateTime) { if (ec) { - BMCWEB_LOG_DEBUG << "D-BUS response error " << ec; + BMCWEB_LOG_DEBUG("D-BUS response error {}", ec); return; } @@ -966,7 +961,7 @@ inline void return; } - BMCWEB_LOG_DEBUG << "Boot type: " << bootType; + BMCWEB_LOG_DEBUG("Boot type: {}", bootType); asyncResp->res .jsonValue["Boot"] @@ -1003,12 +998,12 @@ inline void const std::string& bootModeStr) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Boot mode: " << bootModeStr; + BMCWEB_LOG_DEBUG("Boot mode: {}", bootModeStr); asyncResp->res .jsonValue["Boot"] @@ -1047,7 +1042,7 @@ inline void const std::string& bootSourceStr) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); if (ec.value() == boost::asio::error::host_unreachable) { return; @@ -1056,7 +1051,7 @@ inline void return; } - BMCWEB_LOG_DEBUG << "Boot source: " << bootSourceStr; + BMCWEB_LOG_DEBUG("Boot source: {}", bootSourceStr); auto rfSource = dbusToRfBootSource(bootSourceStr); if (!rfSource.empty()) @@ -1101,7 +1096,7 @@ inline void processBootOverrideEnable( [asyncResp](const boost::system::error_code& ec, bool oneTimeSetting) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -1138,7 +1133,7 @@ inline void const bool bootOverrideEnable) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); if (ec.value() == boost::asio::error::host_unreachable) { return; @@ -1161,7 +1156,7 @@ inline void inline void getBootProperties(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get boot information."; + BMCWEB_LOG_DEBUG("Get boot information."); getBootOverrideSource(asyncResp); getBootOverrideType(asyncResp); @@ -1183,7 +1178,7 @@ inline void inline void getLastResetTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Getting System Last Reset Time"; + BMCWEB_LOG_DEBUG("Getting System Last Reset Time"); sdbusplus::asio::getProperty<uint64_t>( *crow::connections::systemBus, "xyz.openbmc_project.State.Chassis", @@ -1193,7 +1188,7 @@ inline void uint64_t lastResetTime) { if (ec) { - BMCWEB_LOG_DEBUG << "D-BUS response error " << ec; + BMCWEB_LOG_DEBUG("D-BUS response error {}", ec); return; } @@ -1222,7 +1217,7 @@ inline void inline void getAutomaticRebootAttempts( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get Automatic Retry policy"; + BMCWEB_LOG_DEBUG("Get Automatic Retry policy"); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, "xyz.openbmc_project.State.Host", @@ -1235,7 +1230,7 @@ inline void getAutomaticRebootAttempts( { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); } return; @@ -1279,7 +1274,7 @@ inline void getAutomaticRebootAttempts( inline void getAutomaticRetryPolicy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get Automatic Retry policy"; + BMCWEB_LOG_DEBUG("Get Automatic Retry policy"); sdbusplus::asio::getProperty<bool>( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -1291,13 +1286,13 @@ inline void { if (ec.value() != EBADR) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); } return; } - BMCWEB_LOG_DEBUG << "Auto Reboot: " << autoRebootEnabled; + BMCWEB_LOG_DEBUG("Auto Reboot: {}", autoRebootEnabled); if (autoRebootEnabled) { asyncResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] = @@ -1332,7 +1327,7 @@ inline void setAutomaticRetryAttempts( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const uint32_t retryAttempts) { - BMCWEB_LOG_DEBUG << "Set Automatic Retry Attempts."; + BMCWEB_LOG_DEBUG("Set Automatic Retry Attempts."); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0", @@ -1340,9 +1335,8 @@ inline void setAutomaticRetryAttempts( retryAttempts, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR - << "DBUS response error: Set setAutomaticRetryAttempts" - << ec; + BMCWEB_LOG_ERROR( + "DBUS response error: Set setAutomaticRetryAttempts{}", ec); messages::internalError(asyncResp->res); return; } @@ -1383,7 +1377,7 @@ inline computer_system::PowerRestorePolicyTypes inline void getPowerRestorePolicy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get power restore policy"; + BMCWEB_LOG_DEBUG("Get power restore policy"); sdbusplus::asio::getProperty<std::string>( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -1393,7 +1387,7 @@ inline void const std::string& policy) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); return; } computer_system::PowerRestorePolicyTypes restore = @@ -1418,7 +1412,7 @@ inline void inline void getStopBootOnFault(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get Stop Boot On Fault"; + BMCWEB_LOG_DEBUG("Get Stop Boot On Fault"); sdbusplus::asio::getProperty<bool>( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -1456,7 +1450,7 @@ inline void inline void getTrustedModuleRequiredToBoot( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get TPM required to boot."; + BMCWEB_LOG_DEBUG("Get TPM required to boot."); constexpr std::array<std::string_view, 1> interfaces = { "xyz.openbmc_project.Control.TPM.Policy"}; dbus::utility::getSubTree( @@ -1465,8 +1459,8 @@ inline void getTrustedModuleRequiredToBoot( const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error on TPM.Policy GetSubTree" - << ec; + BMCWEB_LOG_DEBUG("DBUS response error on TPM.Policy GetSubTree{}", + ec); // This is an optional D-Bus object so just return if // error occurs return; @@ -1481,9 +1475,9 @@ inline void getTrustedModuleRequiredToBoot( /* When there is more than one TPMEnable object... */ if (subtree.size() > 1) { - BMCWEB_LOG_DEBUG - << "DBUS response has more than 1 TPM Enable object:" - << subtree.size(); + BMCWEB_LOG_DEBUG( + "DBUS response has more than 1 TPM Enable object:{}", + subtree.size()); // Throw an internal Error and return messages::internalError(asyncResp->res); return; @@ -1493,7 +1487,7 @@ inline void getTrustedModuleRequiredToBoot( // field if (subtree[0].first.empty() || subtree[0].second.size() != 1) { - BMCWEB_LOG_DEBUG << "TPM.Policy mapper error!"; + BMCWEB_LOG_DEBUG("TPM.Policy mapper error!"); messages::internalError(asyncResp->res); return; } @@ -1509,8 +1503,8 @@ inline void getTrustedModuleRequiredToBoot( bool tpmRequired) { if (ec2) { - BMCWEB_LOG_DEBUG << "D-BUS response error on TPM.Policy Get" - << ec2; + BMCWEB_LOG_DEBUG("D-BUS response error on TPM.Policy Get{}", + ec2); messages::internalError(asyncResp->res); return; } @@ -1543,7 +1537,7 @@ inline void getTrustedModuleRequiredToBoot( inline void setTrustedModuleRequiredToBoot( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const bool tpmRequired) { - BMCWEB_LOG_DEBUG << "Set TrustedModuleRequiredToBoot."; + BMCWEB_LOG_DEBUG("Set TrustedModuleRequiredToBoot."); constexpr std::array<std::string_view, 1> interfaces = { "xyz.openbmc_project.Control.TPM.Policy"}; dbus::utility::getSubTree( @@ -1553,8 +1547,8 @@ inline void setTrustedModuleRequiredToBoot( const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error on TPM.Policy GetSubTree" - << ec; + BMCWEB_LOG_DEBUG("DBUS response error on TPM.Policy GetSubTree{}", + ec); messages::internalError(asyncResp->res); return; } @@ -1568,9 +1562,9 @@ inline void setTrustedModuleRequiredToBoot( /* When there is more than one TPMEnable object... */ if (subtree.size() > 1) { - BMCWEB_LOG_DEBUG - << "DBUS response has more than 1 TPM Enable object:" - << subtree.size(); + BMCWEB_LOG_DEBUG( + "DBUS response has more than 1 TPM Enable object:{}", + subtree.size()); // Throw an internal Error and return messages::internalError(asyncResp->res); return; @@ -1580,7 +1574,7 @@ inline void setTrustedModuleRequiredToBoot( // field if (subtree[0].first.empty() || subtree[0].second.size() != 1) { - BMCWEB_LOG_DEBUG << "TPM.Policy mapper error!"; + BMCWEB_LOG_DEBUG("TPM.Policy mapper error!"); messages::internalError(asyncResp->res); return; } @@ -1590,7 +1584,7 @@ inline void setTrustedModuleRequiredToBoot( if (serv.empty()) { - BMCWEB_LOG_DEBUG << "TPM.Policy service mapper error!"; + BMCWEB_LOG_DEBUG("TPM.Policy service mapper error!"); messages::internalError(asyncResp->res); return; } @@ -1602,13 +1596,13 @@ inline void setTrustedModuleRequiredToBoot( [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG - << "DBUS response error: Set TrustedModuleRequiredToBoot" - << ec2; + BMCWEB_LOG_DEBUG( + "DBUS response error: Set TrustedModuleRequiredToBoot{}", + ec2); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Set TrustedModuleRequiredToBoot done."; + BMCWEB_LOG_DEBUG("Set TrustedModuleRequiredToBoot done."); }); }); } @@ -1631,7 +1625,7 @@ inline void setBootType(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } // Source target specified - BMCWEB_LOG_DEBUG << "Boot type: " << *bootType; + BMCWEB_LOG_DEBUG("Boot type: {}", *bootType); // Figure out which DBUS interface and property to use if (*bootType == "Legacy") { @@ -1643,16 +1637,16 @@ inline void setBootType(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } else { - BMCWEB_LOG_DEBUG << "Invalid property value for " - "BootSourceOverrideMode: " - << *bootType; + BMCWEB_LOG_DEBUG("Invalid property value for " + "BootSourceOverrideMode: {}", + *bootType); messages::propertyValueNotInList(asyncResp->res, *bootType, "BootSourceOverrideMode"); return; } // Act on validated parameters - BMCWEB_LOG_DEBUG << "DBUS boot type: " << bootTypeStr; + BMCWEB_LOG_DEBUG("DBUS boot type: {}", bootTypeStr); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -1661,7 +1655,7 @@ inline void setBootType(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); if (ec.value() == boost::asio::error::host_unreachable) { messages::resourceNotFound(asyncResp->res, "Set", "BootType"); @@ -1670,7 +1664,7 @@ inline void setBootType(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Boot type update done."; + BMCWEB_LOG_DEBUG("Boot type update done."); }); } @@ -1690,7 +1684,7 @@ inline void setBootEnable(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, return; } // Source target specified - BMCWEB_LOG_DEBUG << "Boot enable: " << *bootEnable; + BMCWEB_LOG_DEBUG("Boot enable: {}", *bootEnable); bool bootOverrideEnable = false; bool bootOverridePersistent = false; @@ -1711,16 +1705,16 @@ inline void setBootEnable(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } else { - BMCWEB_LOG_DEBUG - << "Invalid property value for BootSourceOverrideEnabled: " - << *bootEnable; + BMCWEB_LOG_DEBUG( + "Invalid property value for BootSourceOverrideEnabled: {}", + *bootEnable); messages::propertyValueNotInList(asyncResp->res, *bootEnable, "BootSourceOverrideEnabled"); return; } // Act on validated parameters - BMCWEB_LOG_DEBUG << "DBUS boot override enable: " << bootOverrideEnable; + BMCWEB_LOG_DEBUG("DBUS boot override enable: {}", bootOverrideEnable); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -1729,11 +1723,11 @@ inline void setBootEnable(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Boot override enable update done."; + BMCWEB_LOG_DEBUG("Boot override enable update done."); }); if (!bootOverrideEnable) @@ -1743,8 +1737,8 @@ inline void setBootEnable(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, // In case boot override is enabled we need to set correct value for the // 'one_time' enable DBus interface - BMCWEB_LOG_DEBUG << "DBUS boot override persistent: " - << bootOverridePersistent; + BMCWEB_LOG_DEBUG("DBUS boot override persistent: {}", + bootOverridePersistent); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -1753,11 +1747,11 @@ inline void setBootEnable(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Boot one_time update done."; + BMCWEB_LOG_DEBUG("Boot one_time update done."); }); } @@ -1782,22 +1776,22 @@ inline void } // Source target specified - BMCWEB_LOG_DEBUG << "Boot source: " << *bootSource; + BMCWEB_LOG_DEBUG("Boot source: {}", *bootSource); // Figure out which DBUS interface and property to use if (assignBootParameters(asyncResp, *bootSource, bootSourceStr, bootModeStr) != 0) { - BMCWEB_LOG_DEBUG - << "Invalid property value for BootSourceOverrideTarget: " - << *bootSource; + BMCWEB_LOG_DEBUG( + "Invalid property value for BootSourceOverrideTarget: {}", + *bootSource); messages::propertyValueNotInList(asyncResp->res, *bootSource, "BootSourceTargetOverride"); return; } // Act on validated parameters - BMCWEB_LOG_DEBUG << "DBUS boot source: " << bootSourceStr; - BMCWEB_LOG_DEBUG << "DBUS boot mode: " << bootModeStr; + BMCWEB_LOG_DEBUG("DBUS boot source: {}", bootSourceStr); + BMCWEB_LOG_DEBUG("DBUS boot mode: {}", bootModeStr); sdbusplus::asio::setProperty( *crow::connections::systemBus, "xyz.openbmc_project.Settings", @@ -1806,11 +1800,11 @@ inline void [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Boot source update done."; + BMCWEB_LOG_DEBUG("Boot source update done."); }); sdbusplus::asio::setProperty( @@ -1820,11 +1814,11 @@ inline void [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Boot mode update done."; + BMCWEB_LOG_DEBUG("Boot mode update done."); }); } @@ -1845,7 +1839,7 @@ inline void const std::optional<std::string>& bootType, const std::optional<std::string>& bootEnable) { - BMCWEB_LOG_DEBUG << "Set boot information."; + BMCWEB_LOG_DEBUG("Set boot information."); setBootModeOrSource(asyncResp, bootSource); setBootType(asyncResp, bootType); @@ -1872,13 +1866,13 @@ inline void setAssetTag(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "D-Bus response error on GetSubTree " << ec; + BMCWEB_LOG_DEBUG("D-Bus response error on GetSubTree {}", ec); messages::internalError(asyncResp->res); return; } if (subtree.empty()) { - BMCWEB_LOG_DEBUG << "Can't find system D-Bus object!"; + BMCWEB_LOG_DEBUG("Can't find system D-Bus object!"); messages::internalError(asyncResp->res); return; } @@ -1886,13 +1880,13 @@ inline void setAssetTag(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, // Throw an error if there is more than 1 if (subtree.size() > 1) { - BMCWEB_LOG_DEBUG << "Found more than 1 system D-Bus object!"; + BMCWEB_LOG_DEBUG("Found more than 1 system D-Bus object!"); messages::internalError(asyncResp->res); return; } if (subtree[0].first.empty() || subtree[0].second.size() != 1) { - BMCWEB_LOG_DEBUG << "Asset Tag Set mapper error!"; + BMCWEB_LOG_DEBUG("Asset Tag Set mapper error!"); messages::internalError(asyncResp->res); return; } @@ -1902,7 +1896,7 @@ inline void setAssetTag(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, if (service.empty()) { - BMCWEB_LOG_DEBUG << "Asset Tag Set service mapper error!"; + BMCWEB_LOG_DEBUG("Asset Tag Set service mapper error!"); messages::internalError(asyncResp->res); return; } @@ -1913,8 +1907,8 @@ inline void setAssetTag(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, assetTag, [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "D-Bus response error on AssetTag Set " - << ec2; + BMCWEB_LOG_DEBUG("D-Bus response error on AssetTag Set {}", + ec2); messages::internalError(asyncResp->res); return; } @@ -1958,13 +1952,13 @@ inline std::optional<bool> inline void setStopBootOnFault(const std::shared_ptr<bmcweb::AsyncResp>& aResp, const std::string& stopBootOnFault) { - BMCWEB_LOG_DEBUG << "Set Stop Boot On Fault."; + BMCWEB_LOG_DEBUG("Set Stop Boot On Fault."); std::optional<bool> stopBootEnabled = validstopBootOnFault(stopBootOnFault); if (!stopBootEnabled) { - BMCWEB_LOG_DEBUG << "Invalid property value for StopBootOnFault: " - << stopBootOnFault; + BMCWEB_LOG_DEBUG("Invalid property value for StopBootOnFault: {}", + stopBootOnFault); messages::propertyValueNotInList(aResp->res, stopBootOnFault, "StopBootOnFault"); return; @@ -1999,7 +1993,7 @@ inline void setAutomaticRetry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& automaticRetryConfig) { - BMCWEB_LOG_DEBUG << "Set Automatic Retry."; + BMCWEB_LOG_DEBUG("Set Automatic Retry."); // OpenBMC only supports "Disabled" and "RetryAttempts". bool autoRebootEnabled = false; @@ -2014,8 +2008,8 @@ inline void } else { - BMCWEB_LOG_DEBUG << "Invalid property value for AutomaticRetryConfig: " - << automaticRetryConfig; + BMCWEB_LOG_DEBUG("Invalid property value for AutomaticRetryConfig: {}", + automaticRetryConfig); messages::propertyValueNotInList(asyncResp->res, automaticRetryConfig, "AutomaticRetryConfig"); return; @@ -2063,7 +2057,7 @@ inline void setPowerRestorePolicy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, std::string_view policy) { - BMCWEB_LOG_DEBUG << "Set power restore policy."; + BMCWEB_LOG_DEBUG("Set power restore policy."); std::string powerRestorePolicy = dbusPowerRestorePolicyFromRedfish(policy); @@ -2097,7 +2091,7 @@ inline void */ inline void getProvisioningStatus(std::shared_ptr<bmcweb::AsyncResp> asyncResp) { - BMCWEB_LOG_DEBUG << "Get OEM information."; + BMCWEB_LOG_DEBUG("Get OEM information."); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, "xyz.openbmc_project.PFR.Manager", "/xyz/openbmc_project/pfr", "xyz.openbmc_project.PFR.Attributes", @@ -2111,7 +2105,7 @@ inline void getProvisioningStatus(std::shared_ptr<bmcweb::AsyncResp> asyncResp) if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); // not an error, don't have to have the interface oemPFR["ProvisioningStatus"] = "NotProvisioned"; return; @@ -2132,7 +2126,7 @@ inline void getProvisioningStatus(std::shared_ptr<bmcweb::AsyncResp> asyncResp) if ((provState == nullptr) || (lockState == nullptr)) { - BMCWEB_LOG_DEBUG << "Unable to get PFR attributes."; + BMCWEB_LOG_DEBUG("Unable to get PFR attributes."); messages::internalError(asyncResp->res); return; } @@ -2191,7 +2185,7 @@ inline void else { // Any other values would be invalid - BMCWEB_LOG_DEBUG << "PowerMode value was not valid: " << modeValue; + BMCWEB_LOG_DEBUG("PowerMode value was not valid: {}", modeValue); messages::internalError(asyncResp->res); } } @@ -2205,7 +2199,7 @@ inline void */ inline void getPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get power mode."; + BMCWEB_LOG_DEBUG("Get power mode."); // Get Power Mode object path: constexpr std::array<std::string_view, 1> interfaces = { @@ -2216,8 +2210,8 @@ inline void getPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error on Power.Mode GetSubTree " - << ec; + BMCWEB_LOG_DEBUG("DBUS response error on Power.Mode GetSubTree {}", + ec); // This is an optional D-Bus object so just return if // error occurs return; @@ -2232,15 +2226,15 @@ inline void getPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { // More then one PowerMode object is not supported and is an // error - BMCWEB_LOG_DEBUG - << "Found more than 1 system D-Bus Power.Mode objects: " - << subtree.size(); + BMCWEB_LOG_DEBUG( + "Found more than 1 system D-Bus Power.Mode objects: {}", + subtree.size()); messages::internalError(asyncResp->res); return; } if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1)) { - BMCWEB_LOG_DEBUG << "Power.Mode mapper error!"; + BMCWEB_LOG_DEBUG("Power.Mode mapper error!"); messages::internalError(asyncResp->res); return; } @@ -2248,7 +2242,7 @@ inline void getPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) const std::string& service = subtree[0].second.begin()->first; if (service.empty()) { - BMCWEB_LOG_DEBUG << "Power.Mode service mapper error!"; + BMCWEB_LOG_DEBUG("Power.Mode service mapper error!"); messages::internalError(asyncResp->res); return; } @@ -2260,8 +2254,8 @@ inline void getPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) const std::string& pmode) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error on PowerMode Get: " - << ec2; + BMCWEB_LOG_DEBUG("DBUS response error on PowerMode Get: {}", + ec2); messages::internalError(asyncResp->res); return; } @@ -2269,7 +2263,7 @@ inline void getPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) asyncResp->res.jsonValue["PowerMode@Redfish.AllowableValues"] = { "Static", "MaximumPerformance", "PowerSaving"}; - BMCWEB_LOG_DEBUG << "Current power mode: " << pmode; + BMCWEB_LOG_DEBUG("Current power mode: {}", pmode); translatePowerMode(asyncResp, pmode); }); }); @@ -2322,7 +2316,7 @@ inline std::string inline void setPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& pmode) { - BMCWEB_LOG_DEBUG << "Set power mode."; + BMCWEB_LOG_DEBUG("Set power mode."); std::string powerMode = validatePowerMode(asyncResp, pmode); if (powerMode.empty()) @@ -2340,8 +2334,8 @@ inline void setPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error on Power.Mode GetSubTree " - << ec; + BMCWEB_LOG_DEBUG("DBUS response error on Power.Mode GetSubTree {}", + ec); // This is an optional D-Bus object, but user attempted to patch messages::internalError(asyncResp->res); return; @@ -2357,15 +2351,15 @@ inline void setPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, { // More then one PowerMode object is not supported and is an // error - BMCWEB_LOG_DEBUG - << "Found more than 1 system D-Bus Power.Mode objects: " - << subtree.size(); + BMCWEB_LOG_DEBUG( + "Found more than 1 system D-Bus Power.Mode objects: {}", + subtree.size()); messages::internalError(asyncResp->res); return; } if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1)) { - BMCWEB_LOG_DEBUG << "Power.Mode mapper error!"; + BMCWEB_LOG_DEBUG("Power.Mode mapper error!"); messages::internalError(asyncResp->res); return; } @@ -2373,13 +2367,12 @@ inline void setPowerMode(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& service = subtree[0].second.begin()->first; if (service.empty()) { - BMCWEB_LOG_DEBUG << "Power.Mode service mapper error!"; + BMCWEB_LOG_DEBUG("Power.Mode service mapper error!"); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "Setting power mode(" << powerMode << ") -> " - << path; + BMCWEB_LOG_DEBUG("Setting power mode({}) -> {}", powerMode, path); // Set the Power Mode property sdbusplus::asio::setProperty( @@ -2466,7 +2459,7 @@ inline std::string rfToDbusWDTTimeOutAct(const std::string& rfAction) inline void getHostWatchdogTimer(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get host watchodg"; + BMCWEB_LOG_DEBUG("Get host watchodg"); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, "xyz.openbmc_project.Watchdog", "/xyz/openbmc_project/watchdog/host0", @@ -2476,11 +2469,11 @@ inline void if (ec) { // watchdog service is stopped - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); return; } - BMCWEB_LOG_DEBUG << "Got " << properties.size() << " wdt prop."; + BMCWEB_LOG_DEBUG("Got {} wdt prop.", properties.size()); nlohmann::json& hostWatchdogTimer = asyncResp->res.jsonValue["HostWatchdogTimer"]; @@ -2534,7 +2527,7 @@ inline void const std::optional<bool> wdtEnable, const std::optional<std::string>& wdtTimeOutAction) { - BMCWEB_LOG_DEBUG << "Set host watchdog"; + BMCWEB_LOG_DEBUG("Set host watchdog"); if (wdtTimeOutAction) { @@ -2542,8 +2535,8 @@ inline void // check if TimeOut Action is Valid if (wdtTimeOutActStr.empty()) { - BMCWEB_LOG_DEBUG << "Unsupported value for TimeoutAction: " - << *wdtTimeOutAction; + BMCWEB_LOG_DEBUG("Unsupported value for TimeoutAction: {}", + *wdtTimeOutAction); messages::propertyValueNotInList(asyncResp->res, *wdtTimeOutAction, "TimeoutAction"); return; @@ -2556,7 +2549,7 @@ inline void wdtTimeOutActStr, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -2572,7 +2565,7 @@ inline void [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -2655,7 +2648,7 @@ inline bool inline void getIdlePowerSaver(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { - BMCWEB_LOG_DEBUG << "Get idle power saver parameters"; + BMCWEB_LOG_DEBUG("Get idle power saver parameters"); // Get IdlePowerSaver object path: constexpr std::array<std::string_view, 1> interfaces = { @@ -2666,9 +2659,9 @@ inline void const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG - << "DBUS response error on Power.IdlePowerSaver GetSubTree " - << ec; + BMCWEB_LOG_DEBUG( + "DBUS response error on Power.IdlePowerSaver GetSubTree {}", + ec); messages::internalError(asyncResp->res); return; } @@ -2676,22 +2669,22 @@ inline void { // This is an optional interface so just return // if there is no instance found - BMCWEB_LOG_DEBUG << "No instances found"; + BMCWEB_LOG_DEBUG("No instances found"); return; } if (subtree.size() > 1) { // More then one PowerIdlePowerSaver object is not supported and // is an error - BMCWEB_LOG_DEBUG << "Found more than 1 system D-Bus " - "Power.IdlePowerSaver objects: " - << subtree.size(); + BMCWEB_LOG_DEBUG("Found more than 1 system D-Bus " + "Power.IdlePowerSaver objects: {}", + subtree.size()); messages::internalError(asyncResp->res); return; } if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1)) { - BMCWEB_LOG_DEBUG << "Power.IdlePowerSaver mapper error!"; + BMCWEB_LOG_DEBUG("Power.IdlePowerSaver mapper error!"); messages::internalError(asyncResp->res); return; } @@ -2699,7 +2692,7 @@ inline void const std::string& service = subtree[0].second.begin()->first; if (service.empty()) { - BMCWEB_LOG_DEBUG << "Power.IdlePowerSaver service mapper error!"; + BMCWEB_LOG_DEBUG("Power.IdlePowerSaver service mapper error!"); messages::internalError(asyncResp->res); return; } @@ -2712,8 +2705,8 @@ inline void const dbus::utility::DBusPropertiesMap& properties) { if (ec2) { - BMCWEB_LOG_ERROR - << "DBUS response error on IdlePowerSaver GetAll: " << ec2; + BMCWEB_LOG_ERROR( + "DBUS response error on IdlePowerSaver GetAll: {}", ec2); messages::internalError(asyncResp->res); return; } @@ -2726,7 +2719,7 @@ inline void }); }); - BMCWEB_LOG_DEBUG << "EXIT: Get idle power saver parameters"; + BMCWEB_LOG_DEBUG("EXIT: Get idle power saver parameters"); } /** @@ -2752,7 +2745,7 @@ inline void const std::optional<uint8_t> ipsExitUtil, const std::optional<uint64_t> ipsExitTime) { - BMCWEB_LOG_DEBUG << "Set idle power saver properties"; + BMCWEB_LOG_DEBUG("Set idle power saver properties"); // Get IdlePowerSaver object path: constexpr std::array<std::string_view, 1> interfaces = { @@ -2764,9 +2757,9 @@ inline void const dbus::utility::MapperGetSubTreeResponse& subtree) { if (ec) { - BMCWEB_LOG_DEBUG - << "DBUS response error on Power.IdlePowerSaver GetSubTree " - << ec; + BMCWEB_LOG_DEBUG( + "DBUS response error on Power.IdlePowerSaver GetSubTree {}", + ec); messages::internalError(asyncResp->res); return; } @@ -2781,15 +2774,15 @@ inline void { // More then one PowerIdlePowerSaver object is not supported and // is an error - BMCWEB_LOG_DEBUG - << "Found more than 1 system D-Bus Power.IdlePowerSaver objects: " - << subtree.size(); + BMCWEB_LOG_DEBUG( + "Found more than 1 system D-Bus Power.IdlePowerSaver objects: {}", + subtree.size()); messages::internalError(asyncResp->res); return; } if ((subtree[0].first.empty()) || (subtree[0].second.size() != 1)) { - BMCWEB_LOG_DEBUG << "Power.IdlePowerSaver mapper error!"; + BMCWEB_LOG_DEBUG("Power.IdlePowerSaver mapper error!"); messages::internalError(asyncResp->res); return; } @@ -2797,7 +2790,7 @@ inline void const std::string& service = subtree[0].second.begin()->first; if (service.empty()) { - BMCWEB_LOG_DEBUG << "Power.IdlePowerSaver service mapper error!"; + BMCWEB_LOG_DEBUG("Power.IdlePowerSaver service mapper error!"); messages::internalError(asyncResp->res); return; } @@ -2813,7 +2806,7 @@ inline void *ipsEnable, [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -2828,7 +2821,7 @@ inline void [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -2845,7 +2838,7 @@ inline void [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -2860,7 +2853,7 @@ inline void [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -2877,7 +2870,7 @@ inline void [asyncResp](const boost::system::error_code& ec2) { if (ec2) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec2; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec2); messages::internalError(asyncResp->res); return; } @@ -2885,7 +2878,7 @@ inline void } }); - BMCWEB_LOG_DEBUG << "EXIT: Set idle power saver parameters"; + BMCWEB_LOG_DEBUG("EXIT: Set idle power saver parameters"); } inline void handleComputerSystemCollectionHead( @@ -2943,17 +2936,17 @@ inline void handleComputerSystemCollectionGet( auto val = asyncResp->res.jsonValue.find("Members@odata.count"); if (val == asyncResp->res.jsonValue.end()) { - BMCWEB_LOG_CRITICAL << "Count wasn't found??"; + BMCWEB_LOG_CRITICAL("Count wasn't found??"); return; } uint64_t* count = val->get_ptr<uint64_t*>(); if (count == nullptr) { - BMCWEB_LOG_CRITICAL << "Count wasn't found??"; + BMCWEB_LOG_CRITICAL("Count wasn't found??"); return; } *count = *count + 1; - BMCWEB_LOG_DEBUG << "Hypervisor is available"; + BMCWEB_LOG_DEBUG("Hypervisor is available"); nlohmann::json& ifaceArray2 = asyncResp->res.jsonValue["Members"]; nlohmann::json::object_t hypervisor; hypervisor["@odata.id"] = "/redfish/v1/Systems/hypervisor"; @@ -2976,7 +2969,7 @@ inline void doNMI(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << " Bad D-Bus request error: " << ec; + BMCWEB_LOG_ERROR(" Bad D-Bus request error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -3001,7 +2994,7 @@ inline void handleSystemActionResetError(const boost::system::error_code& ec, if (eMsg.get_error() == nullptr) { - BMCWEB_LOG_ERROR << "D-Bus response error: " << ec; + BMCWEB_LOG_ERROR("D-Bus response error: {}", ec); messages::internalError(res); return; } @@ -3015,13 +3008,13 @@ inline void handleSystemActionResetError(const boost::system::error_code& ec, (errorMessage == std::string_view("xyz.openbmc_project.State.Host.Error.BMCNotReady"))) { - BMCWEB_LOG_DEBUG << "BMC not ready, operation not allowed right now"; + BMCWEB_LOG_DEBUG("BMC not ready, operation not allowed right now"); messages::serviceTemporarilyUnavailable(res, "10"); return; } - BMCWEB_LOG_ERROR << "System Action Reset transition fail " << ec - << " sdbusplus:" << errorMessage; + BMCWEB_LOG_ERROR("System Action Reset transition fail {} sdbusplus:{}", ec, + errorMessage); messages::internalError(res); } diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp index 050b75c4db..8a5c30b769 100644 --- a/redfish-core/lib/task.hpp +++ b/redfish-core/lib/task.hpp @@ -265,7 +265,7 @@ struct TaskData : std::enable_shared_from_this<TaskData> } else { - BMCWEB_LOG_INFO << "sendTaskEvent: No events to send"; + BMCWEB_LOG_INFO("sendTaskEvent: No events to send"); } } diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp index 9cc5ccbf96..42e66c9a0e 100644 --- a/redfish-core/lib/telemetry_service.hpp +++ b/redfish-core/lib/telemetry_service.hpp @@ -48,7 +48,7 @@ inline void handleTelemetryServiceGet( } if (ec) { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/thermal_subsystem.hpp b/redfish-core/lib/thermal_subsystem.hpp index 804b849ea0..92e623eaa7 100644 --- a/redfish-core/lib/thermal_subsystem.hpp +++ b/redfish-core/lib/thermal_subsystem.hpp @@ -22,7 +22,7 @@ inline void doThermalSubsystemCollection( { if (!validChassisPath) { - BMCWEB_LOG_WARNING << "Not a valid chassis ID" << chassisId; + BMCWEB_LOG_WARNING("Not a valid chassis ID{}", chassisId); messages::resourceNotFound(asyncResp->res, "Chassis", chassisId); return; } diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp index cd1b60f438..48e348ec60 100644 --- a/redfish-core/lib/trigger.hpp +++ b/redfish-core/lib/trigger.hpp @@ -678,7 +678,7 @@ inline void afterCreateTrigger( if (ec) { messages::internalError(asyncResp->res); - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); return; } @@ -687,8 +687,8 @@ inline void afterCreateTrigger( if (!triggerId) { messages::internalError(asyncResp->res); - BMCWEB_LOG_ERROR << "Unknown data returned by " - "AddTrigger DBus method"; + BMCWEB_LOG_ERROR("Unknown data returned by " + "AddTrigger DBus method"); return; } @@ -791,8 +791,8 @@ inline std::optional<nlohmann::json> getMetricReportDefinitions( if (reportId.empty()) { { - BMCWEB_LOG_ERROR << "Property Reports contains invalid value: " - << path.str; + BMCWEB_LOG_ERROR("Property Reports contains invalid value: {}", + path.str); return std::nullopt; } } @@ -848,8 +848,8 @@ inline bool fillTrigger( getTriggerActions(*triggerActions); if (!redfishTriggerActions) { - BMCWEB_LOG_ERROR - << "Property TriggerActions is invalid in Trigger: " << id; + BMCWEB_LOG_ERROR( + "Property TriggerActions is invalid in Trigger: {}", id); return false; } json["TriggerActions"] = *redfishTriggerActions; @@ -861,8 +861,7 @@ inline bool fillTrigger( getMetricReportDefinitions(*reports); if (!linkedReports) { - BMCWEB_LOG_ERROR << "Property Reports is invalid in Trigger: " - << id; + BMCWEB_LOG_ERROR("Property Reports is invalid in Trigger: {}", id); return false; } json["Links"]["MetricReportDefinitions"] = *linkedReports; @@ -877,10 +876,9 @@ inline bool fillTrigger( if (!discreteTriggers) { - BMCWEB_LOG_ERROR - << "Property Thresholds is invalid for discrete " - "triggers in Trigger: " - << id; + BMCWEB_LOG_ERROR("Property Thresholds is invalid for discrete " + "triggers in Trigger: {}", + id); return false; } @@ -896,10 +894,9 @@ inline bool fillTrigger( if (!numericThresholds) { - BMCWEB_LOG_ERROR - << "Property Thresholds is invalid for numeric " - "thresholds in Trigger: " - << id; + BMCWEB_LOG_ERROR("Property Thresholds is invalid for numeric " + "thresholds in Trigger: {}", + id); return false; } @@ -1012,7 +1009,7 @@ inline void requestRoutesTrigger(App& app) } if (ec) { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); messages::internalError(asyncResp->res); return; } @@ -1046,7 +1043,7 @@ inline void requestRoutesTrigger(App& app) if (ec) { - BMCWEB_LOG_ERROR << "respHandler DBus error " << ec; + BMCWEB_LOG_ERROR("respHandler DBus error {}", ec); messages::internalError(asyncResp->res); return; } diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index 357c04770b..3e75425ee5 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -63,7 +63,7 @@ inline static void cleanUp() inline static void activateImage(const std::string& objPath, const std::string& service) { - BMCWEB_LOG_DEBUG << "Activate image for " << objPath << " " << service; + BMCWEB_LOG_DEBUG("Activate image for {} {}", objPath, service); sdbusplus::asio::setProperty( *crow::connections::systemBus, service, objPath, "xyz.openbmc_project.Software.Activation", "RequestedActivation", @@ -71,8 +71,8 @@ inline static void activateImage(const std::string& objPath, [](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_DEBUG << "error_code = " << ec; - BMCWEB_LOG_DEBUG << "error msg = " << ec.message(); + BMCWEB_LOG_DEBUG("error_code = {}", ec); + BMCWEB_LOG_DEBUG("error msg = {}", ec.message()); } }); } @@ -89,10 +89,10 @@ static void m.read(objPath, interfacesProperties); - BMCWEB_LOG_DEBUG << "obj path = " << objPath.str; + BMCWEB_LOG_DEBUG("obj path = {}", objPath.str); for (const auto& interface : interfacesProperties) { - BMCWEB_LOG_DEBUG << "interface = " << interface.first; + BMCWEB_LOG_DEBUG("interface = {}", interface.first); if (interface.first == "xyz.openbmc_project.Software.Activation") { @@ -108,8 +108,8 @@ static void objInfo) mutable { if (ec) { - BMCWEB_LOG_DEBUG << "error_code = " << ec; - BMCWEB_LOG_DEBUG << "error msg = " << ec.message(); + BMCWEB_LOG_DEBUG("error_code = {}", ec); + BMCWEB_LOG_DEBUG("error msg = {}", ec.message()); if (asyncResp) { messages::internalError(asyncResp->res); @@ -120,8 +120,7 @@ static void // Ensure we only got one service back if (objInfo.size() != 1) { - BMCWEB_LOG_ERROR << "Invalid Object Size " - << objInfo.size(); + BMCWEB_LOG_ERROR("Invalid Object Size {}", objInfo.size()); if (asyncResp) { messages::internalError(asyncResp->res); @@ -295,12 +294,11 @@ static void monitorForSoftwareAvailable( // expected, we were canceled before the timer completed. return; } - BMCWEB_LOG_ERROR - << "Timed out waiting for firmware object being created"; - BMCWEB_LOG_ERROR << "FW image may has already been uploaded to server"; + BMCWEB_LOG_ERROR("Timed out waiting for firmware object being created"); + BMCWEB_LOG_ERROR("FW image may has already been uploaded to server"); if (ec) { - BMCWEB_LOG_ERROR << "Async_wait failed" << ec; + BMCWEB_LOG_ERROR("Async_wait failed{}", ec); return; } if (asyncResp) @@ -310,7 +308,7 @@ static void monitorForSoftwareAvailable( }); task::Payload payload(req); auto callback = [asyncResp, payload](sdbusplus::message_t& m) mutable { - BMCWEB_LOG_DEBUG << "Match fired"; + BMCWEB_LOG_DEBUG("Match fired"); softwareInterfaceAdded(asyncResp, m, std::move(payload)); }; @@ -332,7 +330,7 @@ static void monitorForSoftwareAvailable( interfacesProperties; sdbusplus::message::object_path objPath; m.read(objPath, interfacesProperties); - BMCWEB_LOG_DEBUG << "obj path = " << objPath.str; + BMCWEB_LOG_DEBUG("obj path = {}", objPath.str); for (const std::pair<std::string, dbus::utility::DBusPropertiesMap>& interface : interfacesProperties) { @@ -423,7 +421,7 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) std::optional<std::string> transferProtocol; std::string imageURI; - BMCWEB_LOG_DEBUG << "Enter UpdateService.SimpleUpdate doPost"; + BMCWEB_LOG_DEBUG("Enter UpdateService.SimpleUpdate doPost"); // User can pass in both TransferProtocol and ImageURI parameters or // they can pass in just the ImageURI with the transfer protocol @@ -434,8 +432,7 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) if (!json_util::readJsonAction(req, asyncResp->res, "TransferProtocol", transferProtocol, "ImageURI", imageURI)) { - BMCWEB_LOG_DEBUG - << "Missing TransferProtocol or ImageURI parameter"; + BMCWEB_LOG_DEBUG("Missing TransferProtocol or ImageURI parameter"); return; } if (!transferProtocol) @@ -449,22 +446,21 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) messages::actionParameterValueTypeError( asyncResp->res, imageURI, "ImageURI", "UpdateService.SimpleUpdate"); - BMCWEB_LOG_ERROR << "ImageURI missing transfer protocol: " - << imageURI; + BMCWEB_LOG_ERROR("ImageURI missing transfer protocol: {}", + imageURI); return; } transferProtocol = imageURI.substr(0, separator); // Ensure protocol is upper case for a common comparison path // below boost::to_upper(*transferProtocol); - BMCWEB_LOG_DEBUG << "Encoded transfer protocol " - << *transferProtocol; + BMCWEB_LOG_DEBUG("Encoded transfer protocol {}", *transferProtocol); // Adjust imageURI to not have the protocol on it for parsing // below // ex. tftp://1.1.1.1/myfile.bin -> 1.1.1.1/myfile.bin imageURI = imageURI.substr(separator + 3); - BMCWEB_LOG_DEBUG << "Adjusted imageUri " << imageURI; + BMCWEB_LOG_DEBUG("Adjusted imageUri {}", imageURI); } // OpenBMC currently only supports TFTP @@ -473,8 +469,8 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) messages::actionParameterNotSupported(asyncResp->res, "TransferProtocol", "UpdateService.SimpleUpdate"); - BMCWEB_LOG_ERROR << "Request incorrect protocol parameter: " - << *transferProtocol; + BMCWEB_LOG_ERROR("Request incorrect protocol parameter: {}", + *transferProtocol); return; } @@ -486,13 +482,13 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) messages::actionParameterValueTypeError( asyncResp->res, imageURI, "ImageURI", "UpdateService.SimpleUpdate"); - BMCWEB_LOG_ERROR << "Invalid ImageURI: " << imageURI; + BMCWEB_LOG_ERROR("Invalid ImageURI: {}", imageURI); return; } std::string tftpServer = imageURI.substr(0, separator); std::string fwFile = imageURI.substr(separator + 1); - BMCWEB_LOG_DEBUG << "Server: " << tftpServer + " File: " << fwFile; + BMCWEB_LOG_DEBUG("Server: {}{}", tftpServer + " File: ", fwFile); // Setup callback for when new software detected // Give TFTP 10 minutes to complete @@ -514,19 +510,19 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) { // messages::internalError(asyncResp->res); cleanUp(); - BMCWEB_LOG_DEBUG << "error_code = " << ec; - BMCWEB_LOG_DEBUG << "error msg = " << ec.message(); + BMCWEB_LOG_DEBUG("error_code = {}", ec); + BMCWEB_LOG_DEBUG("error msg = {}", ec.message()); } else { - BMCWEB_LOG_DEBUG << "Call to DownloaViaTFTP Success"; + BMCWEB_LOG_DEBUG("Call to DownloaViaTFTP Success"); } }, "xyz.openbmc_project.Software.Download", "/xyz/openbmc_project/software", "xyz.openbmc_project.Common.TFTP", "DownloadViaTFTP", fwFile, tftpServer); - BMCWEB_LOG_DEBUG << "Exit UpdateService.SimpleUpdate doPost"; + BMCWEB_LOG_DEBUG("Exit UpdateService.SimpleUpdate doPost"); }); } @@ -534,7 +530,7 @@ inline void uploadImageFile(crow::Response& res, std::string_view body) { std::filesystem::path filepath("/tmp/images/" + bmcweb::getRandomUUID()); - BMCWEB_LOG_DEBUG << "Writing file to " << filepath; + BMCWEB_LOG_DEBUG("Writing file to {}", filepath.string()); std::ofstream out(filepath, std::ofstream::out | std::ofstream::binary | std::ofstream::trunc); // set the permission of the file to 640 @@ -566,8 +562,8 @@ inline void setApplyTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, } else { - BMCWEB_LOG_INFO - << "ApplyTime value is not in the list of acceptable values"; + BMCWEB_LOG_INFO( + "ApplyTime value is not in the list of acceptable values"); messages::propertyValueNotInList(asyncResp->res, applyTime, "ApplyTime"); return; @@ -581,7 +577,7 @@ inline void setApplyTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, applyTimeNewVal, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec; + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); messages::internalError(asyncResp->res); return; } @@ -602,10 +598,10 @@ inline void 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"); return; } - BMCWEB_LOG_INFO << "Parsing value " << it->value(); + BMCWEB_LOG_INFO("Parsing value {}", it->value()); // The construction parameters of param_list must start with `;` size_t index = it->value().find(';'); @@ -656,7 +652,7 @@ inline void if (uploadData == nullptr) { - BMCWEB_LOG_ERROR << "Upload data is NULL"; + BMCWEB_LOG_ERROR("Upload data is NULL"); messages::propertyMissing(asyncResp->res, "UpdateFile"); return; } @@ -681,7 +677,7 @@ inline void } std::string_view contentType = req.getHeaderValue("Content-Type"); - BMCWEB_LOG_DEBUG << "doPost: contentType=" << contentType; + BMCWEB_LOG_DEBUG("doPost: contentType={}", contentType); // Make sure that content type is application/octet-stream or // multipart/form-data @@ -705,8 +701,8 @@ inline void 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)); messages::internalError(asyncResp->res); return; } @@ -714,7 +710,7 @@ inline void } else { - BMCWEB_LOG_DEBUG << "Bad content type specified:" << contentType; + BMCWEB_LOG_DEBUG("Bad content type specified:{}", contentType); asyncResp->res.result(boost::beast::http::status::bad_request); } } @@ -768,7 +764,7 @@ inline void requestRoutesUpdateService(App& app) const std::string& applyTime) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + BMCWEB_LOG_DEBUG("DBUS response error {}", ec); messages::internalError(asyncResp->res); return; } @@ -799,7 +795,7 @@ inline void requestRoutesUpdateService(App& app) { return; } - BMCWEB_LOG_DEBUG << "doPatch..."; + BMCWEB_LOG_DEBUG("doPatch..."); std::optional<nlohmann::json> pushUriOptions; if (!json_util::readJsonPatch(req, asyncResp->res, "HttpPushUriOptions", @@ -890,7 +886,7 @@ inline static void } else { - BMCWEB_LOG_ERROR << "Unknown software purpose " << purpose; + BMCWEB_LOG_ERROR("Unknown software purpose {}", purpose); } } @@ -926,16 +922,16 @@ inline void if (swInvPurpose == nullptr) { - BMCWEB_LOG_DEBUG << "Can't find property \"Purpose\"!"; + BMCWEB_LOG_DEBUG("Can't find property \"Purpose\"!"); messages::internalError(asyncResp->res); return; } - BMCWEB_LOG_DEBUG << "swInvPurpose = " << *swInvPurpose; + BMCWEB_LOG_DEBUG("swInvPurpose = {}", *swInvPurpose); if (version == nullptr) { - BMCWEB_LOG_DEBUG << "Can't find property \"Version\"!"; + BMCWEB_LOG_DEBUG("Can't find property \"Version\"!"); messages::internalError(asyncResp->res); @@ -991,7 +987,7 @@ inline void requestRoutesSoftwareInventory(App& app) [asyncResp, swId](const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreeResponse& subtree) { - BMCWEB_LOG_DEBUG << "doGet callback..."; + BMCWEB_LOG_DEBUG("doGet callback..."); if (ec) { messages::internalError(asyncResp->res); @@ -1022,7 +1018,7 @@ inline void requestRoutesSoftwareInventory(App& app) } if (!found) { - BMCWEB_LOG_WARNING << "Input swID " << *swId << " not found!"; + BMCWEB_LOG_WARNING("Input swID {} not found!", *swId); messages::resourceMissingAtURI( asyncResp->res, boost::urls::format( diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp index 81af41fe72..e425cc188d 100644 --- a/redfish-core/lib/virtual_media.hpp +++ b/redfish-core/lib/virtual_media.hpp @@ -46,8 +46,7 @@ inline VmMode const std::string& resName) { std::string thisPath = itemPath.filename(); - BMCWEB_LOG_DEBUG << "Filename: " << itemPath.str - << ", ThisPath: " << thisPath; + BMCWEB_LOG_DEBUG("Filename: {}, ThisPath: {}", itemPath.str, thisPath); if (thisPath.empty()) { @@ -102,7 +101,7 @@ inline void const dbus::utility::ManagedObjectType& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); return; } @@ -117,7 +116,7 @@ inline void } } - BMCWEB_LOG_DEBUG << "Parent item not found"; + BMCWEB_LOG_DEBUG("Parent item not found"); asyncResp->res.result(boost::beast::http::status::not_found); }); } @@ -224,7 +223,7 @@ inline void const bool* activeValue = std::get_if<bool>(&value); if (activeValue == nullptr) { - BMCWEB_LOG_DEBUG << "Value Active not found"; + BMCWEB_LOG_DEBUG("Value Active not found"); return; } asyncResp->res.jsonValue["Inserted"] = *activeValue; @@ -272,7 +271,7 @@ inline void getVmResourceList(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& name) { - BMCWEB_LOG_DEBUG << "Get available Virtual Media resources."; + BMCWEB_LOG_DEBUG("Get available Virtual Media resources."); sdbusplus::message::object_path objPath( "/xyz/openbmc_project/VirtualMedia"); dbus::utility::getManagedObjects( @@ -282,7 +281,7 @@ inline void getVmResourceList(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const dbus::utility::ManagedObjectType& subtree) { if (ec) { - BMCWEB_LOG_DEBUG << "DBUS response error"; + BMCWEB_LOG_DEBUG("DBUS response error"); return; } nlohmann::json& members = asyncResp->res.jsonValue["Members"]; @@ -344,7 +343,7 @@ inline void getVmData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& service, const std::string& name, const std::string& resName) { - BMCWEB_LOG_DEBUG << "Get Virtual Media resource data."; + BMCWEB_LOG_DEBUG("Get Virtual Media resource data."); findAndParseObject(service, resName, asyncResp, std::bind_front(afterGetVmData, name)); @@ -601,7 +600,7 @@ inline void doMountVmLegacy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, if (credentials.user().size() + credentials.password().size() + 2 > secretLimit) { - BMCWEB_LOG_ERROR << "Credentials too long to handle"; + BMCWEB_LOG_ERROR("Credentials too long to handle"); messages::unrecognizedRequestBody(asyncResp->res); return; } @@ -625,7 +624,7 @@ inline void doMountVmLegacy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, [asyncResp](const boost::system::error_code& ec, std::size_t) { if (ec) { - BMCWEB_LOG_ERROR << "Failed to pass secret: " << ec; + BMCWEB_LOG_ERROR("Failed to pass secret: {}", ec); messages::internalError(asyncResp->res); } }); @@ -636,12 +635,12 @@ inline void doMountVmLegacy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, bool success) { if (ec) { - BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; + BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec); messages::internalError(asyncResp->res); } else if (!success) { - BMCWEB_LOG_ERROR << "Service responded with error"; + BMCWEB_LOG_ERROR("Service responded with error"); messages::generalError(asyncResp->res); } }, @@ -659,11 +658,11 @@ inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& resName, InsertMediaActionParams& actionParams) { - BMCWEB_LOG_DEBUG << "Validation started"; + BMCWEB_LOG_DEBUG("Validation started"); // required param imageUrl must not be empty if (!actionParams.imageUrl) { - BMCWEB_LOG_ERROR << "Request action parameter Image is empty."; + BMCWEB_LOG_ERROR("Request action parameter Image is empty."); messages::propertyValueFormatError(asyncResp->res, "<empty>", "Image"); @@ -673,8 +672,8 @@ inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, // optional param inserted must be true if ((actionParams.inserted != std::nullopt) && !*actionParams.inserted) { - BMCWEB_LOG_ERROR - << "Request action optional parameter Inserted must be true."; + BMCWEB_LOG_ERROR( + "Request action optional parameter Inserted must be true."); messages::actionParameterNotSupported(asyncResp->res, "Inserted", "InsertMedia"); @@ -686,8 +685,8 @@ inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, if ((actionParams.transferMethod != std::nullopt) && (*actionParams.transferMethod != "Stream")) { - BMCWEB_LOG_ERROR << "Request action optional parameter " - "TransferMethod must be Stream."; + BMCWEB_LOG_ERROR("Request action optional parameter " + "TransferMethod must be Stream."); messages::actionParameterNotSupported(asyncResp->res, "TransferMethod", "InsertMedia"); @@ -711,9 +710,9 @@ inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, // ImageUrl does not contain valid protocol type if (*uriTransferProtocolType == TransferProtocol::invalid) { - BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " - "contain specified protocol type from list: " - "(smb, https)."; + BMCWEB_LOG_ERROR("Request action parameter ImageUrl must " + "contain specified protocol type from list: " + "(smb, https)."); messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); @@ -723,9 +722,9 @@ inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, // transferProtocolType should contain value from list if (*paramTransferProtocolType == TransferProtocol::invalid) { - BMCWEB_LOG_ERROR << "Request action parameter TransferProtocolType " - "must be provided with value from list: " - "(CIFS, HTTPS)."; + BMCWEB_LOG_ERROR("Request action parameter TransferProtocolType " + "must be provided with value from list: " + "(CIFS, HTTPS)."); messages::propertyValueNotInList(asyncResp->res, *actionParams.transferProtocolType, @@ -737,9 +736,9 @@ inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, if ((uriTransferProtocolType == std::nullopt) && (paramTransferProtocolType == std::nullopt)) { - BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " - "contain specified protocol type or param " - "TransferProtocolType must be provided."; + BMCWEB_LOG_ERROR("Request action parameter ImageUrl must " + "contain specified protocol type or param " + "TransferProtocolType must be provided."); messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); @@ -753,10 +752,10 @@ inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, // check if protocol is the same for URI and param if (*paramTransferProtocolType != *uriTransferProtocolType) { - BMCWEB_LOG_ERROR << "Request action parameter " - "TransferProtocolType must contain the " - "same protocol type as protocol type " - "provided with param imageUrl."; + BMCWEB_LOG_ERROR("Request action parameter " + "TransferProtocolType must contain the " + "same protocol type as protocol type " + "provided with param imageUrl."); messages::actionParameterValueTypeError( asyncResp->res, *actionParams.transferProtocolType, @@ -805,7 +804,7 @@ inline void doEjectAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; + BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec); messages::internalError(asyncResp->res); return; @@ -820,7 +819,7 @@ inline void doEjectAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, [asyncResp](const boost::system::error_code& ec) { if (ec) { - BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; + BMCWEB_LOG_ERROR("Bad D-Bus request error: {}", ec); messages::internalError(asyncResp->res); return; @@ -869,14 +868,14 @@ inline void handleManagersVirtualMediaActionInsertPost( const dbus::utility::MapperGetObject& getObjectType) mutable { if (ec) { - BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; + BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec); messages::resourceNotFound(asyncResp->res, action, resName); return; } std::string service = getObjectType.begin()->first; - BMCWEB_LOG_DEBUG << "GetObjectType: " << service; + BMCWEB_LOG_DEBUG("GetObjectType: {}", service); sdbusplus::message::object_path path( "/xyz/openbmc_project/VirtualMedia"); @@ -888,8 +887,8 @@ inline void handleManagersVirtualMediaActionInsertPost( if (ec2) { // Not possible in proxy mode - BMCWEB_LOG_DEBUG << "InsertMedia not " - "allowed in proxy mode"; + BMCWEB_LOG_DEBUG("InsertMedia not " + "allowed in proxy mode"); messages::resourceNotFound(asyncResp->res, action, resName); return; @@ -904,7 +903,7 @@ inline void handleManagersVirtualMediaActionInsertPost( return; } } - BMCWEB_LOG_DEBUG << "Parent item not found"; + BMCWEB_LOG_DEBUG("Parent item not found"); messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); }); }); @@ -935,13 +934,13 @@ inline void handleManagersVirtualMediaActionEject( const dbus::utility::MapperGetObject& getObjectType) { if (ec2) { - BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec2; + BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec2); messages::internalError(asyncResp->res); return; } std::string service = getObjectType.begin()->first; - BMCWEB_LOG_DEBUG << "GetObjectType: " << service; + BMCWEB_LOG_DEBUG("GetObjectType: {}", service); sdbusplus::message::object_path path( "/xyz/openbmc_project/VirtualMedia"); @@ -952,7 +951,7 @@ inline void handleManagersVirtualMediaActionEject( const dbus::utility::ManagedObjectType& subtree) { if (ec) { - BMCWEB_LOG_ERROR << "ObjectMapper : No Service found"; + BMCWEB_LOG_ERROR("ObjectMapper : No Service found"); messages::resourceNotFound(asyncResp->res, action, resName); return; } @@ -967,7 +966,7 @@ inline void handleManagersVirtualMediaActionEject( return; } } - BMCWEB_LOG_DEBUG << "Parent item not found"; + BMCWEB_LOG_DEBUG("Parent item not found"); messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); }); }); @@ -1001,13 +1000,13 @@ inline void handleManagersVirtualMediaCollectionGet( const dbus::utility::MapperGetObject& getObjectType) { if (ec) { - BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; + BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec); messages::internalError(asyncResp->res); return; } std::string service = getObjectType.begin()->first; - BMCWEB_LOG_DEBUG << "GetObjectType: " << service; + BMCWEB_LOG_DEBUG("GetObjectType: {}", service); getVmResourceList(asyncResp, service, name); }); @@ -1036,13 +1035,13 @@ inline void const dbus::utility::MapperGetObject& getObjectType) { if (ec) { - BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; + BMCWEB_LOG_ERROR("ObjectMapper::GetObject call failed: {}", ec); messages::internalError(asyncResp->res); return; } std::string service = getObjectType.begin()->first; - BMCWEB_LOG_DEBUG << "GetObjectType: " << service; + BMCWEB_LOG_DEBUG("GetObjectType: {}", service); getVmData(asyncResp, service, name, resName); }); diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp index 85aab34530..38f10c824d 100644 --- a/redfish-core/src/error_messages.cpp +++ b/redfish-core/src/error_messages.cpp @@ -51,16 +51,15 @@ static void addMessageToErrorJson(nlohmann::json& target, auto messageIdIterator = message.find("MessageId"); if (messageIdIterator == message.end()) { - BMCWEB_LOG_CRITICAL - << "Attempt to add error message without MessageId"; + BMCWEB_LOG_CRITICAL( + "Attempt to add error message without MessageId"); return; } auto messageFieldIterator = message.find("Message"); if (messageFieldIterator == message.end()) { - BMCWEB_LOG_CRITICAL - << "Attempt to add error message without Message"; + BMCWEB_LOG_CRITICAL("Attempt to add error message without Message"); return; } error["code"] = *messageIdIterator; @@ -282,9 +281,9 @@ nlohmann::json internalError() void internalError(crow::Response& res, const std::source_location location) { - BMCWEB_LOG_CRITICAL << "Internal Error " << location.file_name() << "(" - << location.line() << ":" << location.column() << ") `" - << location.function_name() << "`: "; + BMCWEB_LOG_CRITICAL("Internal Error {}({}:{}) `{}`: ", location.file_name(), + location.line(), location.column(), + location.function_name()); res.result(boost::beast::http::status::internal_server_error); addMessageToErrorJson(res.jsonValue, internalError()); } diff --git a/scripts/replace_logs.py b/scripts/replace_logs.py new file mode 100755 index 0000000000..cc7f87ba67 --- /dev/null +++ b/scripts/replace_logs.py @@ -0,0 +1,100 @@ +#!/usr/bin/python3 +import os +import re +from subprocess import check_output + +""" +This script is intended to aid in the replacement of bmcweb log lines from +BMCWEB_LOG_CRITICAL << "foo" << arg; +to the new fmt style form +BMCWEB_LOG_CRITICAL("foo{}", arg); + +It is intended to be a 99% correct tool, and in some cases, some amount of +manual intervention is required once the conversion has been done. Some +things it doesn't handle: + +ptrs need to be wrapped in logPtr(). This script tries to do the common +cases, but can't handle every one. + +types of boost::ip::tcp::endpoint/address needs .to_string() called on it +in the args section + +arguments that were previously build by in-line operator+ construction of +strings (for example "foo" + bar), need to be formatted in the arguments +brace replacement language, (for example "foo{}", bar) + +After the script has been run, remember to reformat with clang-format + +This script will be removed Q2 2024 +""" + + +SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) + +files = check_output( + ["git", "-C", os.path.join(SCRIPT_DIR, ".."), "grep", "-l", "BMCWEB_LOG_"] +) +filenames = files.split(b"\n") + + +for filename in filenames: + if not filename: + continue + with open(filename, "r") as filehandle: + contents = filehandle.read() + + # Normalize all the log statements to a single line + new_contents = "" + replacing = False + for line in contents.splitlines(): + match = re.match(r"\s+BMCWEB_LOG_", line) + if match: + replacing = True + + if replacing and not match: + line = " " + line.lstrip() + if line.endswith(";"): + replacing = False + new_contents += line + if not replacing: + new_contents += "\n" + contents = new_contents + + new_contents = "" + for line in contents.splitlines(): + match = re.match(r"(\s+BMCWEB_LOG_[A-Z]+) <<", line) + if match: + logstring = "" + line = line.lstrip() + chevron_split = line.split("<<") + arguments = [] + for log_piece in chevron_split[1:]: + if log_piece.endswith(";"): + log_piece = log_piece[:-1] + log_piece = log_piece.strip() + if (log_piece.startswith('"') and log_piece.endswith('"')) or ( + log_piece.startswith("'") and log_piece.endswith("'") + ): + logstring += log_piece[1:-1] + else: + if log_piece == "this" or log_piece.startswith("&"): + log_piece = "logPtr({})".format(log_piece) + if log_piece == "self": + log_piece = "logPtr(self.get())" + arguments.append(log_piece) + logstring += "{}" + if logstring.endswith("\\n"): + logstring = logstring[:-2] + + arguments.insert(0, '"' + logstring + '"') + argjoin = ", ".join(arguments) + + line = match.group(1) + "(" + argjoin + ");" + new_contents += line + "\n" + + contents = new_contents + + with open(filename, "w") as filehandle: + filehandle.write(new_contents) + +print() diff --git a/src/boost_asio.cpp b/src/boost_asio.cpp index 53f2fd6945..9e9107487a 100644 --- a/src/boost_asio.cpp +++ b/src/boost_asio.cpp @@ -9,14 +9,14 @@ namespace boost { void throw_exception(const std::exception& e) { - BMCWEB_LOG_CRITICAL << "Boost exception thrown " << e.what(); + BMCWEB_LOG_CRITICAL("Boost exception thrown {}", e.what()); std::terminate(); } void throw_exception(const std::exception& e, const source_location& loc) { - BMCWEB_LOG_CRITICAL << "Boost exception thrown " << e.what() << " from " - << loc; + BMCWEB_LOG_CRITICAL("Boost exception thrown {} from {}:{}", e.what(), + loc.file_name(), loc.line()); std::terminate(); } } // namespace boost diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp index 8150f460ad..67e2aaef04 100644 --- a/src/webserver_main.cpp +++ b/src/webserver_main.cpp @@ -39,25 +39,25 @@ inline void setupSocket(crow::App& app) int listenFd = sd_listen_fds(0); if (1 == listenFd) { - BMCWEB_LOG_INFO << "attempting systemd socket activation"; + BMCWEB_LOG_INFO("attempting systemd socket activation"); if (sd_is_socket_inet(SD_LISTEN_FDS_START, AF_UNSPEC, SOCK_STREAM, 1, 0) != 0) { - BMCWEB_LOG_INFO << "Starting webserver on socket handle " - << SD_LISTEN_FDS_START; + BMCWEB_LOG_INFO("Starting webserver on socket handle {}", + SD_LISTEN_FDS_START); app.socket(SD_LISTEN_FDS_START); } else { - BMCWEB_LOG_INFO - << "bad incoming socket, starting webserver on port " - << defaultPort; + BMCWEB_LOG_INFO( + "bad incoming socket, starting webserver on port {}", + defaultPort); app.port(defaultPort); } } else { - BMCWEB_LOG_INFO << "Starting webserver on port " << defaultPort; + BMCWEB_LOG_INFO("Starting webserver on port {}", defaultPort); app.port(defaultPort); } } @@ -133,13 +133,13 @@ static int run() int rc = redfish::EventServiceManager::startEventLogMonitor(*io); if (rc != 0) { - BMCWEB_LOG_ERROR << "Redfish event handler setup failed..."; + BMCWEB_LOG_ERROR("Redfish event handler setup failed..."); return rc; } #endif #ifdef BMCWEB_ENABLE_SSL - BMCWEB_LOG_INFO << "Start Hostname Monitor Service..."; + BMCWEB_LOG_INFO("Start Hostname Monitor Service..."); crow::hostname_monitor::registerHostnameSignal(); #endif @@ -161,12 +161,12 @@ int main(int /*argc*/, char** /*argv*/) } catch (const std::exception& e) { - BMCWEB_LOG_CRITICAL << "Threw exception to main: " << e.what(); + BMCWEB_LOG_CRITICAL("Threw exception to main: {}", e.what()); return -1; } catch (...) { - BMCWEB_LOG_CRITICAL << "Threw exception to main"; + BMCWEB_LOG_CRITICAL("Threw exception to main"); return -1; } } |