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/worldserver | |
| parent | b6820a706f46f18b9652fcd9806e4bec8805d29d (diff) | |
Core/Logging: Switch from fmt::sprintf to fmt::format (c++20 standard compatible api)
Diffstat (limited to 'src/server/worldserver')
| -rw-r--r-- | src/server/worldserver/Main.cpp | 38 | ||||
| -rw-r--r-- | src/server/worldserver/RemoteAccess/RASession.cpp | 14 | ||||
| -rw-r--r-- | src/server/worldserver/TCSoap/TCSoap.cpp | 14 |
3 files changed, 33 insertions, 33 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index cf2b09491d8..cad929fa67f 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -205,18 +205,18 @@ extern int main(int argc, char** argv) Trinity::Banner::Show("worldserver-daemon", [](char const* text) { - TC_LOG_INFO("server.worldserver", "%s", text); + TC_LOG_INFO("server.worldserver", "{}", text); }, []() { - TC_LOG_INFO("server.worldserver", "Using configuration file %s.", sConfigMgr->GetFilename().c_str()); - TC_LOG_INFO("server.worldserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION)); - TC_LOG_INFO("server.worldserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); + TC_LOG_INFO("server.worldserver", "Using configuration file {}.", sConfigMgr->GetFilename()); + TC_LOG_INFO("server.worldserver", "Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION)); + TC_LOG_INFO("server.worldserver", "Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); } ); for (std::string const& key : overriddenKeys) - TC_LOG_INFO("server.worldserver", "Configuration field '%s' was overridden with environment variable.", key.c_str()); + TC_LOG_INFO("server.worldserver", "Configuration field '{}' was overridden with environment variable.", key); OpenSSLCrypto::threadsSetup(boost::dll::program_location().remove_filename()); @@ -232,10 +232,10 @@ extern int main(int argc, char** argv) if (!pidFile.empty()) { if (uint32 pid = CreatePIDFile(pidFile)) - TC_LOG_INFO("server.worldserver", "Daemon PID: %u\n", pid); + TC_LOG_INFO("server.worldserver", "Daemon PID: {}\n", pid); else { - TC_LOG_ERROR("server.worldserver", "Cannot create PID file %s.\n", pidFile.c_str()); + TC_LOG_ERROR("server.worldserver", "Cannot create PID file {}.\n", pidFile); return 1; } } @@ -272,7 +272,7 @@ extern int main(int argc, char** argv) return 0; // Set server offline (not connectable) - LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, realm.Id.Realm); + LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | {} WHERE id = '{}'", REALM_FLAG_OFFLINE, realm.Id.Realm); sRealmList->Initialize(*ioContext, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 10)); @@ -368,7 +368,7 @@ extern int main(int argc, char** argv) }); // Set server online (allow connecting now) - LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~%u, population = 0 WHERE id = '%u'", REALM_FLAG_OFFLINE, realm.Id.Realm); + LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag & ~{}, population = 0 WHERE id = '{}'", REALM_FLAG_OFFLINE, realm.Id.Realm); realm.PopulationLevel = 0.0f; realm.Flags = RealmFlags(realm.Flags & ~uint32(REALM_FLAG_OFFLINE)); @@ -378,12 +378,12 @@ extern int main(int argc, char** argv) { freezeDetector = std::make_shared<FreezeDetector>(*ioContext, coreStuckTime * 1000); FreezeDetector::Start(freezeDetector); - TC_LOG_INFO("server.worldserver", "Starting up anti-freeze thread (%u seconds max stuck time)...", coreStuckTime); + TC_LOG_INFO("server.worldserver", "Starting up anti-freeze thread ({} seconds max stuck time)...", coreStuckTime); } sScriptMgr->OnStartup(); - TC_LOG_INFO("server.worldserver", "%s (worldserver-daemon) ready...", GitRevision::GetFullVersion()); + TC_LOG_INFO("server.worldserver", "{} (worldserver-daemon) ready...", GitRevision::GetFullVersion()); // Launch CliRunnable thread std::shared_ptr<std::thread> cliThread; @@ -411,7 +411,7 @@ extern int main(int argc, char** argv) sScriptMgr->OnShutdown(); // set server offline - LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, realm.Id.Realm); + LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = flag | {} WHERE id = '{}'", REALM_FLAG_OFFLINE, realm.Id.Realm); TC_LOG_INFO("server.worldserver", "Halting process..."); @@ -442,7 +442,7 @@ void ShutdownCLIThread(std::thread* cliThread) if (!numCharsWritten) errorBuffer = "Unknown error"; - TC_LOG_DEBUG("server.worldserver", "Error cancelling I/O of CliThread, error code %u, detail: %s", uint32(errorCode), errorBuffer); + TC_LOG_DEBUG("server.worldserver", "Error cancelling I/O of CliThread, error code {}, detail: {}", uint32(errorCode), errorBuffer); if (numCharsWritten) LocalFree((LPSTR)errorBuffer); @@ -514,7 +514,7 @@ void WorldUpdateLoop() { uint32 sleepTime = minUpdateDiff - diff; if (sleepTime >= halfMaxCoreStuckTime) - TC_LOG_ERROR("server.worldserver", "WorldUpdateLoop() waiting for %u ms with MaxCoreStuckTime set to %u ms", sleepTime, maxCoreStuckTime); + TC_LOG_ERROR("server.worldserver", "WorldUpdateLoop() waiting for {} ms with MaxCoreStuckTime set to {} ms", sleepTime, maxCoreStuckTime); // sleep until enough time passes that we can update all timers std::this_thread::sleep_for(Milliseconds(sleepTime)); continue; @@ -564,7 +564,7 @@ void FreezeDetector::Handler(std::weak_ptr<FreezeDetector> freezeDetectorRef, bo uint32 msTimeDiff = getMSTimeDiff(freezeDetector->_lastChangeMsTime, curtime); if (msTimeDiff > freezeDetector->_maxCoreStuckTimeInMs) { - TC_LOG_ERROR("server.worldserver", "World Thread hangs for %u ms, forcing a crash!", msTimeDiff); + TC_LOG_ERROR("server.worldserver", "World Thread hangs for {} ms, forcing a crash!", msTimeDiff); ABORT_MSG("World Thread hangs for %u ms, forcing a crash!", msTimeDiff); } } @@ -639,17 +639,17 @@ bool StartDB() return false; } - TC_LOG_INFO("server.worldserver", "Realm running as realm ID %u", realm.Id.Realm); + TC_LOG_INFO("server.worldserver", "Realm running as realm ID {}", realm.Id.Realm); ///- Clean the database before starting ClearOnlineAccounts(); ///- Insert version info into DB - WorldDatabase.PExecute("UPDATE version SET core_version = '%s', core_revision = '%s'", GitRevision::GetFullVersion(), GitRevision::GetHash()); // One-time query + WorldDatabase.PExecute("UPDATE version SET core_version = '{}', core_revision = '{}'", GitRevision::GetFullVersion(), GitRevision::GetHash()); // One-time query sWorld->LoadDBVersion(); - TC_LOG_INFO("server.worldserver", "Using World DB: %s", sWorld->GetDBVersion()); + TC_LOG_INFO("server.worldserver", "Using World DB: {}", sWorld->GetDBVersion()); return true; } @@ -666,7 +666,7 @@ void StopDB() void ClearOnlineAccounts() { // Reset online status for all accounts with characters on the current realm - LoginDatabase.DirectPExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = %d)", realm.Id.Realm); + LoginDatabase.DirectPExecute("UPDATE account SET online = 0 WHERE online > 0 AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = {})", realm.Id.Realm); // Reset online status for all characters CharacterDatabase.DirectExecute("UPDATE characters SET online = 0 WHERE online <> 0"); diff --git a/src/server/worldserver/RemoteAccess/RASession.cpp b/src/server/worldserver/RemoteAccess/RASession.cpp index 8e32177fdc4..09075a1f282 100644 --- a/src/server/worldserver/RemoteAccess/RASession.cpp +++ b/src/server/worldserver/RemoteAccess/RASession.cpp @@ -56,7 +56,7 @@ void RASession::Start() if (username.empty()) return; - TC_LOG_INFO("commands.ra", "Accepting RA connection from user %s (IP: %s)", username.c_str(), GetRemoteIpAddress().c_str()); + TC_LOG_INFO("commands.ra", "Accepting RA connection from user {} (IP: {})", username, GetRemoteIpAddress()); Send("Password: "); @@ -71,7 +71,7 @@ void RASession::Start() return; } - TC_LOG_INFO("commands.ra", "User %s (IP: %s) authenticated correctly to RA", username.c_str(), GetRemoteIpAddress().c_str()); + TC_LOG_INFO("commands.ra", "User {} (IP: {}) authenticated correctly to RA", username, GetRemoteIpAddress()); // Authentication successful, send the motd for (std::string const& line : sWorld->GetMotd()) @@ -132,7 +132,7 @@ bool RASession::CheckAccessLevel(const std::string& user) if (!result) { - TC_LOG_INFO("commands.ra", "User %s does not exist in database", user.c_str()); + TC_LOG_INFO("commands.ra", "User {} does not exist in database", user); return false; } @@ -140,12 +140,12 @@ bool RASession::CheckAccessLevel(const std::string& user) if (fields[1].GetUInt8() < sConfigMgr->GetIntDefault("Ra.MinLevel", SEC_ADMINISTRATOR)) { - TC_LOG_INFO("commands.ra", "User %s has no privilege to login", user.c_str()); + TC_LOG_INFO("commands.ra", "User {} has no privilege to login", user); return false; } else if (fields[2].GetInt32() != -1) { - TC_LOG_INFO("commands.ra", "User %s has to be assigned on all realms (with RealmID = '-1')", user.c_str()); + TC_LOG_INFO("commands.ra", "User {} has to be assigned on all realms (with RealmID = '-1')", user); return false; } @@ -173,7 +173,7 @@ bool RASession::CheckPassword(const std::string& user, const std::string& pass) return true; } - TC_LOG_INFO("commands.ra", "Wrong password for user: %s", user.c_str()); + TC_LOG_INFO("commands.ra", "Wrong password for user: {}", user); return false; } @@ -182,7 +182,7 @@ bool RASession::ProcessCommand(std::string& command) if (command.length() == 0) return true; - TC_LOG_INFO("commands.ra", "Received command: %s", command.c_str()); + TC_LOG_INFO("commands.ra", "Received command: {}", command); // handle quit, exit and logout commands to terminate connection if (command == "quit" || command == "exit" || command == "logout") diff --git a/src/server/worldserver/TCSoap/TCSoap.cpp b/src/server/worldserver/TCSoap/TCSoap.cpp index 9aa31b159e8..40955b21dbe 100644 --- a/src/server/worldserver/TCSoap/TCSoap.cpp +++ b/src/server/worldserver/TCSoap/TCSoap.cpp @@ -40,18 +40,18 @@ void TCSoapThread(const std::string& host, uint16 port) soap.send_timeout = 5; if (!soap_valid_socket(soap_bind(&soap, host.c_str(), port, 100))) { - TC_LOG_ERROR("network.soap", "Couldn't bind to %s:%d", host.c_str(), port); + TC_LOG_ERROR("network.soap", "Couldn't bind to {}:{}", host, port); exit(-1); } - TC_LOG_INFO("network.soap", "Bound to http://%s:%d", host.c_str(), port); + TC_LOG_INFO("network.soap", "Bound to http://{}:{}", host, port); while (!World::IsStopped()) { if (!soap_valid_socket(soap_accept(&soap))) continue; // ran into an accept timeout - TC_LOG_DEBUG("network.soap", "Accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); + TC_LOG_DEBUG("network.soap", "Accepted connection from IP={}.{}.{}.{}", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); struct soap* thread_soap = soap_copy(&soap);// make a safe copy process_message(thread_soap); } @@ -87,26 +87,26 @@ int ns1__executeCommand(soap* soap, char* command, char** result) uint32 accountId = AccountMgr::GetId(soap->userid); if (!accountId) { - TC_LOG_INFO("network.soap", "Client used invalid username '%s'", soap->userid); + TC_LOG_INFO("network.soap", "Client used invalid username '{}'", soap->userid); return 401; } if (!AccountMgr::CheckPassword(accountId, soap->passwd)) { - TC_LOG_INFO("network.soap", "Invalid password for account '%s'", soap->userid); + TC_LOG_INFO("network.soap", "Invalid password for account '{}'", soap->userid); return 401; } if (AccountMgr::GetSecurity(accountId, realm.Id.Realm) < SEC_ADMINISTRATOR) { - TC_LOG_INFO("network.soap", "%s's gmlevel is too low", soap->userid); + TC_LOG_INFO("network.soap", "{}'s gmlevel is too low", soap->userid); return 403; } if (!command || !*command) return soap_sender_fault(soap, "Command can not be empty", "The supplied command was an empty string"); - TC_LOG_INFO("network.soap", "Received command '%s'", command); + TC_LOG_INFO("network.soap", "Received command '{}'", command); SOAPCommand connection; // commands are executed in the world thread. We have to wait for them to be completed |
