From d791afae1dfcfaf592326f787755ca32d629e4d3 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 8 Jan 2023 21:16:53 +0100 Subject: Core/Logging: Switch from fmt::sprintf to fmt::format (c++20 standard compatible api) --- src/server/bnetserver/REST/LoginRESTService.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/server/bnetserver/REST/LoginRESTService.cpp') diff --git a/src/server/bnetserver/REST/LoginRESTService.cpp b/src/server/bnetserver/REST/LoginRESTService.cpp index 0833f5e73fd..5267b2bd761 100644 --- a/src/server/bnetserver/REST/LoginRESTService.cpp +++ b/src/server/bnetserver/REST/LoginRESTService.cpp @@ -76,7 +76,7 @@ bool LoginRESTService::Start(Trinity::Asio::IoContext* ioContext) _port = sConfigMgr->GetIntDefault("LoginREST.Port", 8081); if (_port < 0 || _port > 0xFFFF) { - TC_LOG_ERROR("server.rest", "Specified login service port (%d) out of allowed range (1-65535), defaulting to 8081", _port); + TC_LOG_ERROR("server.rest", "Specified login service port ({}) out of allowed range (1-65535), defaulting to 8081", _port); _port = 8081; } @@ -86,7 +86,7 @@ bool LoginRESTService::Start(Trinity::Asio::IoContext* ioContext) Optional externalAddress = resolver.Resolve(boost::asio::ip::tcp::v4(), configuredAddress, std::to_string(_port)); if (!externalAddress) { - TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.ExternalAddress %s", configuredAddress.c_str()); + TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.ExternalAddress {}", configuredAddress); return false; } @@ -96,7 +96,7 @@ bool LoginRESTService::Start(Trinity::Asio::IoContext* ioContext) Optional localAddress = resolver.Resolve(boost::asio::ip::tcp::v4(), configuredAddress, std::to_string(_port)); if (!localAddress) { - TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.LocalAddress %s", configuredAddress.c_str()); + TC_LOG_ERROR("server.rest", "Could not resolve LoginREST.LocalAddress {}", configuredAddress); return false; } @@ -158,11 +158,11 @@ void LoginRESTService::Run() soapServer.send_timeout = 5; if (!soap_valid_socket(soap_bind(&soapServer, _bindIP.c_str(), _port, 100))) { - TC_LOG_ERROR("server.rest", "Couldn't bind to %s:%d", _bindIP.c_str(), _port); + TC_LOG_ERROR("server.rest", "Couldn't bind to {}:{}", _bindIP, _port); return; } - TC_LOG_INFO("server.rest", "Login service bound to http://%s:%d", _bindIP.c_str(), _port); + TC_LOG_INFO("server.rest", "Login service bound to http://{}:{}", _bindIP, _port); http_post_handlers handlers[] = { @@ -195,11 +195,11 @@ void LoginRESTService::Run() std::shared_ptr soapClient = std::make_shared(soapServer); if (soap_ssl_accept(soapClient->GetClient()) != SOAP_OK) { - TC_LOG_DEBUG("server.rest", "Failed SSL handshake from IP=%s", boost::asio::ip::address_v4(soapClient->GetClient()->ip).to_string().c_str()); + TC_LOG_DEBUG("server.rest", "Failed SSL handshake from IP={}", boost::asio::ip::address_v4(soapClient->GetClient()->ip).to_string()); continue; } - TC_LOG_DEBUG("server.rest", "Accepted connection from IP=%s", boost::asio::ip::address_v4(soapClient->GetClient()->ip).to_string().c_str()); + TC_LOG_DEBUG("server.rest", "Accepted connection from IP={}", boost::asio::ip::address_v4(soapClient->GetClient()->ip).to_string()); Trinity::Asio::post(*_ioContext, [soapClient]() { @@ -217,8 +217,8 @@ void LoginRESTService::Run() int32 LoginRESTService::HandleHttpRequest(soap* soapClient, char const* method, HttpMethodHandlerMap const& handlers) { - TC_LOG_DEBUG("server.rest", "[%s:%d] Handling %s request path=\"%s\"", - boost::asio::ip::address_v4(soapClient->ip).to_string().c_str(), soapClient->port, method, soapClient->path); + TC_LOG_DEBUG("server.rest", "[{}:{}] Handling {} request path=\"{}\"", + boost::asio::ip::address_v4(soapClient->ip).to_string(), soapClient->port, method, soapClient->path); size_t pathLength = strlen(soapClient->path); if (char const* queryPart = strchr(soapClient->path, '?')) @@ -299,7 +299,7 @@ int32 LoginRESTService::HandleGetGameAccounts(std::shared_ptr requ int32 LoginRESTService::HandleGetPortal(std::shared_ptr request) { boost::asio::ip::tcp::endpoint const& endpoint = GetAddressForClient(boost::asio::ip::address_v4(request->GetClient()->ip)); - std::string response = Trinity::StringFormat("%s:%d", endpoint.address().to_string().c_str(), sConfigMgr->GetIntDefault("BattlenetPort", 1119)); + std::string response = Trinity::StringFormat("{}:{}", endpoint.address().to_string(), sConfigMgr->GetIntDefault("BattlenetPort", 1119)); soap_response(request->GetClient(), SOAP_FILE); soap_send_raw(request->GetClient(), response.c_str(), response.length()); @@ -384,7 +384,7 @@ int32 LoginRESTService::HandlePostLogin(std::shared_ptr request) uint32 maxWrongPassword = uint32(sConfigMgr->GetIntDefault("WrongPass.MaxCount", 0)); if (sConfigMgr->GetBoolDefault("WrongPass.Logging", false)) - TC_LOG_DEBUG("server.rest", "[%s, Account %s, Id %u] Attempted to connect with wrong password!", ip_address.c_str(), login.c_str(), accountId); + TC_LOG_DEBUG("server.rest", "[{}, Account {}, Id {}] Attempted to connect with wrong password!", ip_address, login, accountId); if (maxWrongPassword) { @@ -395,7 +395,7 @@ int32 LoginRESTService::HandlePostLogin(std::shared_ptr request) ++failedLogins; - TC_LOG_DEBUG("server.rest", "MaxWrongPass : %u, failed_login : %u", maxWrongPassword, accountId); + TC_LOG_DEBUG("server.rest", "MaxWrongPass : {}, failed_login : {}", maxWrongPassword, accountId); if (failedLogins >= maxWrongPassword) { -- cgit v1.2.3