diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-01-08 21:16:53 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-01-08 21:16:53 +0100 |
| commit | d791afae1dfcfaf592326f787755ca32d629e4d3 (patch) | |
| tree | 54dc9916ede5800e110a2f0edff91530811fbdb8 /src/server/bnetserver | |
| parent | b6820a706f46f18b9652fcd9806e4bec8805d29d (diff) | |
Core/Logging: Switch from fmt::sprintf to fmt::format (c++20 standard compatible api)
Diffstat (limited to 'src/server/bnetserver')
| -rw-r--r-- | src/server/bnetserver/Main.cpp | 16 | ||||
| -rw-r--r-- | src/server/bnetserver/REST/LoginRESTService.cpp | 24 | ||||
| -rw-r--r-- | src/server/bnetserver/Server/Session.cpp | 38 | ||||
| -rw-r--r-- | src/server/bnetserver/Server/SslContext.cpp | 2 | ||||
| -rw-r--r-- | src/server/bnetserver/Services/ServiceDispatcher.cpp | 2 |
5 files changed, 41 insertions, 41 deletions
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index c8c414aeacd..00fd64b3dd8 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -123,18 +123,18 @@ int main(int argc, char** argv) Trinity::Banner::Show("bnetserver", [](char const* text) { - TC_LOG_INFO("server.bnetserver", "%s", text); + TC_LOG_INFO("server.bnetserver", "{}", text); }, []() { - TC_LOG_INFO("server.bnetserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str()); - TC_LOG_INFO("server.bnetserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION)); - TC_LOG_INFO("server.bnetserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); + TC_LOG_INFO("server.bnetserver", "Using configuration file {}.", sConfigMgr->GetFilename()); + TC_LOG_INFO("server.bnetserver", "Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION)); + TC_LOG_INFO("server.bnetserver", "Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); } ); for (std::string const& key : overriddenKeys) - TC_LOG_INFO("server.authserver", "Configuration field '%s' was overridden with environment variable.", key.c_str()); + TC_LOG_INFO("server.authserver", "Configuration field '{}' was overridden with environment variable.", key); OpenSSLCrypto::threadsSetup(boost::dll::program_location().remove_filename()); @@ -145,10 +145,10 @@ int main(int argc, char** argv) if (!pidFile.empty()) { if (uint32 pid = CreatePIDFile(pidFile)) - TC_LOG_INFO("server.bnetserver", "Daemon PID: %u\n", pid); + TC_LOG_INFO("server.bnetserver", "Daemon PID: {}\n", pid); else { - TC_LOG_ERROR("server.bnetserver", "Cannot create PID file %s.\n", pidFile.c_str()); + TC_LOG_ERROR("server.bnetserver", "Cannot create PID file {}.\n", pidFile); return 1; } } @@ -179,7 +179,7 @@ int main(int argc, char** argv) int32 bnport = sConfigMgr->GetIntDefault("BattlenetPort", 1119); if (bnport < 0 || bnport > 0xFFFF) { - TC_LOG_ERROR("server.bnetserver", "Specified battle.net port (%d) out of allowed range (1-65535)", bnport); + TC_LOG_ERROR("server.bnetserver", "Specified battle.net port ({}) out of allowed range (1-65535)", bnport); return 1; } 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<boost::asio::ip::tcp::endpoint> 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<boost::asio::ip::tcp::endpoint> 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<AsyncRequest> soapClient = std::make_shared<AsyncRequest>(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<AsyncRequest> requ int32 LoginRESTService::HandleGetPortal(std::shared_ptr<AsyncRequest> 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<AsyncRequest> 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<AsyncRequest> 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) { diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp index 995f1bbd7b9..5e43d97ae1d 100644 --- a/src/server/bnetserver/Server/Session.cpp +++ b/src/server/bnetserver/Server/Session.cpp @@ -87,7 +87,7 @@ void Battlenet::Session::AsyncHandshake() void Battlenet::Session::Start() { std::string ip_address = GetRemoteIpAddress().to_string(); - TC_LOG_TRACE("session", "%s Accepted connection", GetClientInfo().c_str()); + TC_LOG_TRACE("session", "{} Accepted connection", GetClientInfo()); // Verify that this IP is not in the ip_banned table LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS)); @@ -113,7 +113,7 @@ void Battlenet::Session::CheckIpCallback(PreparedQueryResult result) if (banned) { - TC_LOG_DEBUG("session", "%s tries to log in using banned IP!", GetClientInfo().c_str()); + TC_LOG_DEBUG("session", "{} tries to log in using banned IP!", GetClientInfo()); CloseSocket(); return; } @@ -209,19 +209,19 @@ uint32 Battlenet::Session::HandleLogon(authentication::v1::LogonRequest const* l { if (logonRequest->program() != "WoW") { - TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] %s attempted to log in with game other than WoW (using %s)!", GetClientInfo().c_str(), logonRequest->program().c_str()); + TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] {} attempted to log in with game other than WoW (using {})!", GetClientInfo(), logonRequest->program()); return ERROR_BAD_PROGRAM; } if (logonRequest->platform() != "Win" && logonRequest->platform() != "Wn64" && logonRequest->platform() != "Mc64") { - TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] %s attempted to log in from an unsupported platform (using %s)!", GetClientInfo().c_str(), logonRequest->platform().c_str()); + TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] {} attempted to log in from an unsupported platform (using {})!", GetClientInfo(), logonRequest->platform()); return ERROR_BAD_PLATFORM; } if (!IsValidLocale(GetLocaleByName(logonRequest->locale()))) { - TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] %s attempted to log in with unsupported locale (using %s)!", GetClientInfo().c_str(), logonRequest->locale().c_str()); + TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] {} attempted to log in with unsupported locale (using {})!", GetClientInfo(), logonRequest->locale()); return ERROR_BAD_LOCALE; } @@ -236,7 +236,7 @@ uint32 Battlenet::Session::HandleLogon(authentication::v1::LogonRequest const* l challenge::v1::ChallengeExternalRequest externalChallenge; externalChallenge.set_payload_type("web_auth_url"); - externalChallenge.set_payload(Trinity::StringFormat("https://%s:%u/bnetserver/login/", endpoint.address().to_string().c_str(), endpoint.port())); + externalChallenge.set_payload(Trinity::StringFormat("https://{}:{}/bnetserver/login/", endpoint.address().to_string(), endpoint.port())); Service<challenge::v1::ChallengeListener>(this).OnExternalChallenge(&externalChallenge); return ERROR_OK; } @@ -258,8 +258,8 @@ uint32 Battlenet::Session::HandleGenerateWebCredentials(authentication::v1::Gene { auto asPrintable = [](char c) { return std::isprint(c) ? c : ' '; }; - TC_LOG_DEBUG("session", "[Battlenet::HandleGenerateWebCredentials] %s attempted to generate web cretentials with game other than WoW (using %c%c%c%c)!", - GetClientInfo().c_str(), asPrintable((request->program() >> 24) & 0xFF), asPrintable((request->program() >> 16) & 0xFF), + TC_LOG_DEBUG("session", "[Battlenet::HandleGenerateWebCredentials] {} attempted to generate web cretentials with game other than WoW (using %c%c%c%c)!", + GetClientInfo(), asPrintable((request->program() >> 24) & 0xFF), asPrintable((request->program() >> 16) & 0xFF), asPrintable((request->program() >> 8) & 0xFF), asPrintable(request->program() & 0xFF)); return ERROR_BAD_PROGRAM; } @@ -356,8 +356,8 @@ uint32 Battlenet::Session::VerifyWebCredentials(std::string const& webCredential // If the IP is 'locked', check that the player comes indeed from the correct IP address if (_accountInfo->IsLockedToIP) { - TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '%s' is locked to IP - '%s' is logging in from '%s'", - _accountInfo->Login.c_str(), _accountInfo->LastIP.c_str(), ip_address.c_str()); + TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '{}' is locked to IP - '{}' is logging in from '{}'", + _accountInfo->Login, _accountInfo->LastIP, ip_address); if (_accountInfo->LastIP != ip_address) { @@ -370,13 +370,13 @@ uint32 Battlenet::Session::VerifyWebCredentials(std::string const& webCredential if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(ip_address)) _ipCountry = location->CountryCode; - TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '%s' is not locked to ip", _accountInfo->Login.c_str()); + TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '{}' is not locked to ip", _accountInfo->Login); if (_accountInfo->LockCountry.empty() || _accountInfo->LockCountry == "00") - TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '%s' is not locked to country", _accountInfo->Login.c_str()); + TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '{}' is not locked to country", _accountInfo->Login); else if (!_accountInfo->LockCountry.empty() && !_ipCountry.empty()) { - TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '%s' is locked to country: '%s' Player country is '%s'", - _accountInfo->Login.c_str(), _accountInfo->LockCountry.c_str(), _ipCountry.c_str()); + TC_LOG_DEBUG("session", "[Session::HandleVerifyWebCredentials] Account '{}' is locked to country: '{}' Player country is '{}'", + _accountInfo->Login, _accountInfo->LockCountry, _ipCountry); if (_ipCountry != _accountInfo->LockCountry) { @@ -391,13 +391,13 @@ uint32 Battlenet::Session::VerifyWebCredentials(std::string const& webCredential { if (_accountInfo->IsPermanenetlyBanned) { - TC_LOG_DEBUG("session", "%s [Session::HandleVerifyWebCredentials] Banned account %s tried to login!", GetClientInfo().c_str(), _accountInfo->Login.c_str()); + TC_LOG_DEBUG("session", "{} [Session::HandleVerifyWebCredentials] Banned account {} tried to login!", GetClientInfo(), _accountInfo->Login); asyncContinuation(&asyncContinuationService, ERROR_GAME_ACCOUNT_BANNED, &response); return; } else { - TC_LOG_DEBUG("session", "%s [Session::HandleVerifyWebCredentials] Temporarily banned account %s tried to login!", GetClientInfo().c_str(), _accountInfo->Login.c_str()); + TC_LOG_DEBUG("session", "{} [Session::HandleVerifyWebCredentials] Temporarily banned account {} tried to login!", GetClientInfo(), _accountInfo->Login); asyncContinuation(&asyncContinuationService, ERROR_GAME_ACCOUNT_SUSPENDED, &response); return; } @@ -518,14 +518,14 @@ uint32 Battlenet::Session::HandleProcessClientRequest(game_utilities::v1::Client if (!command) { - TC_LOG_ERROR("session.rpc", "%s sent ClientRequest with no command.", GetClientInfo().c_str()); + TC_LOG_ERROR("session.rpc", "{} sent ClientRequest with no command.", GetClientInfo()); return ERROR_RPC_MALFORMED_REQUEST; } auto itr = ClientRequestHandlers.find(removeSuffix(command->name())); if (itr == ClientRequestHandlers.end()) { - TC_LOG_ERROR("session.rpc", "%s sent ClientRequest with unknown command %s.", GetClientInfo().c_str(), removeSuffix(command->name()).c_str()); + TC_LOG_ERROR("session.rpc", "{} sent ClientRequest with unknown command {}.", GetClientInfo(), removeSuffix(command->name())); return ERROR_RPC_NOT_IMPLEMENTED; } @@ -695,7 +695,7 @@ void Battlenet::Session::HandshakeHandler(boost::system::error_code const& error { if (error) { - TC_LOG_ERROR("session", "%s SSL Handshake failed %s", GetClientInfo().c_str(), error.message().c_str()); + TC_LOG_ERROR("session", "{} SSL Handshake failed {}", GetClientInfo(), error.message()); CloseSocket(); return; } diff --git a/src/server/bnetserver/Server/SslContext.cpp b/src/server/bnetserver/Server/SslContext.cpp index 8a448c28834..d40698ef9f6 100644 --- a/src/server/bnetserver/Server/SslContext.cpp +++ b/src/server/bnetserver/Server/SslContext.cpp @@ -26,7 +26,7 @@ bool Battlenet::SslContext::Initialize() #define LOAD_CHECK(fn) do { fn; \ if (err) \ { \ - TC_LOG_ERROR("server.ssl", #fn " failed: %s", err.message().c_str()); \ + TC_LOG_ERROR("server.ssl", #fn " failed: {}", err.message()); \ return false; \ } } while (0) diff --git a/src/server/bnetserver/Services/ServiceDispatcher.cpp b/src/server/bnetserver/Services/ServiceDispatcher.cpp index 7408c2350fa..4751577c973 100644 --- a/src/server/bnetserver/Services/ServiceDispatcher.cpp +++ b/src/server/bnetserver/Services/ServiceDispatcher.cpp @@ -39,7 +39,7 @@ void Battlenet::ServiceDispatcher::Dispatch(Session* session, uint32 serviceHash if (itr != _dispatchers.end()) itr->second(session, token, methodId, std::move(buffer)); else - TC_LOG_DEBUG("session.rpc", "%s tried to call invalid service 0x%X", session->GetClientInfo().c_str(), serviceHash); + TC_LOG_DEBUG("session.rpc", "{} tried to call invalid service 0x{:X}", session->GetClientInfo(), serviceHash); } Battlenet::ServiceDispatcher& Battlenet::ServiceDispatcher::Instance() |
