mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
refactor(Core/Logging): switch to fmt style for LOG_ (#10366)
* feat(Core/Common): add support fmt style for ASSERT and ABORT * correct CheckCompactArrayMaskOverflow * 1 * Update src/server/game/Spells/Spell.cpp * rework logging * add fmt replace logs * logging * FMT_LOG_ * settings * fix startup * 1 * 2 * 3 * 4 * 5 * fmt::print * to fmt
This commit is contained in:
@@ -61,7 +61,7 @@ void BanExpiryHandler(std::weak_ptr<Acore::Asio::DeadlineTimer> banExpiryCheckTi
|
||||
/// Print out the usage string for this program on the console.
|
||||
void usage(const char* prog)
|
||||
{
|
||||
LOG_INFO("server.authserver", "Usage: \n %s [<options>]\n"
|
||||
LOG_INFO("server.authserver", "Usage: \n {} [<options>]\n"
|
||||
" -c config_file use config_file as configuration file\n\r", prog);
|
||||
}
|
||||
|
||||
@@ -103,13 +103,13 @@ int main(int argc, char** argv)
|
||||
Acore::Banner::Show("authserver",
|
||||
[](std::string_view text)
|
||||
{
|
||||
FMT_LOG_INFO("server.authserver", text);
|
||||
LOG_INFO("server.authserver", text);
|
||||
},
|
||||
[]()
|
||||
{
|
||||
FMT_LOG_INFO("server.authserver", "> Using configuration file {}", sConfigMgr->GetFilename());
|
||||
FMT_LOG_INFO("server.authserver", "> Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
FMT_LOG_INFO("server.authserver", "> Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
LOG_INFO("server.authserver", "> Using configuration file {}", sConfigMgr->GetFilename());
|
||||
LOG_INFO("server.authserver", "> Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
LOG_INFO("server.authserver", "> Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
});
|
||||
|
||||
// authserver PID file creation
|
||||
@@ -117,10 +117,10 @@ int main(int argc, char** argv)
|
||||
if (!pidFile.empty())
|
||||
{
|
||||
if (uint32 pid = CreatePIDFile(pidFile))
|
||||
LOG_INFO("server.authserver", "Daemon PID: %u\n", pid); // outError for red color in console
|
||||
LOG_INFO("server.authserver", "Daemon PID: {}\n", pid); // outError for red color in console
|
||||
else
|
||||
{
|
||||
LOG_ERROR("server.authserver", "Cannot create PID file %s (possible error: permission)\n", pidFile.c_str());
|
||||
LOG_ERROR("server.authserver", "Cannot create PID file {} (possible error: permission)\n", pidFile);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ AuthSession::AuthSession(tcp::socket&& socket) :
|
||||
void AuthSession::Start()
|
||||
{
|
||||
std::string ip_address = GetRemoteIpAddress().to_string();
|
||||
LOG_TRACE("session", "Accepted connection from %s", ip_address.c_str());
|
||||
LOG_TRACE("session", "Accepted connection from {}", ip_address);
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_INFO);
|
||||
stmt->setString(0, ip_address);
|
||||
@@ -210,7 +210,7 @@ void AuthSession::CheckIpCallback(PreparedQueryResult result)
|
||||
pkt << uint8(0x00);
|
||||
pkt << uint8(WOW_FAIL_BANNED);
|
||||
SendPacket(pkt);
|
||||
LOG_DEBUG("session", "[AuthSession::CheckIpCallback] Banned ip '%s:%d' tries to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort());
|
||||
LOG_DEBUG("session", "[AuthSession::CheckIpCallback] Banned ip '{}:{}' tries to login!", GetRemoteIpAddress().to_string(), GetRemotePort());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ bool AuthSession::HandleLogonChallenge()
|
||||
return false;
|
||||
|
||||
std::string login((char const*)challenge->I, challenge->I_len);
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] '%s'", login.c_str());
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] '{}'", login);
|
||||
|
||||
_build = challenge->build;
|
||||
_expversion = uint8(AuthHelper::IsPostBCAcceptedClientBuild(_build) ? POST_BC_EXP_FLAG : (AuthHelper::IsPreBCAcceptedClientBuild(_build) ? PRE_BC_EXP_FLAG : NO_VALID_EXP_FLAG));
|
||||
@@ -339,7 +339,7 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
|
||||
// If the IP is 'locked', check that the player comes indeed from the correct IP address
|
||||
if (_accountInfo.IsLockedToIP)
|
||||
{
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is locked to IP - '%s' is logging in from '%s'", _accountInfo.Login.c_str(), _accountInfo.LastIP.c_str(), ipAddress.c_str());
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is locked to IP - '{}' is logging in from '{}'", _accountInfo.Login, _accountInfo.LastIP, ipAddress);
|
||||
if (_accountInfo.LastIP != ipAddress)
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_LOCKED_ENFORCED);
|
||||
@@ -352,12 +352,12 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
|
||||
if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(ipAddress))
|
||||
_ipCountry = location->CountryCode;
|
||||
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is not locked to ip", _accountInfo.Login.c_str());
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is not locked to ip", _accountInfo.Login);
|
||||
if (_accountInfo.LockCountry.empty() || _accountInfo.LockCountry == "00")
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is not locked to country", _accountInfo.Login.c_str());
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is not locked to country", _accountInfo.Login);
|
||||
else if (!_ipCountry.empty())
|
||||
{
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _accountInfo.Login.c_str(), _accountInfo.LockCountry.c_str(), _ipCountry.c_str());
|
||||
LOG_DEBUG("server.authserver", "[AuthChallenge] Account '{}' is locked to country: '{}' Player country is '{}'", _accountInfo.Login, _accountInfo.LockCountry, _ipCountry);
|
||||
if (_ipCountry != _accountInfo.LockCountry)
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_UNLOCKABLE_LOCK);
|
||||
@@ -374,14 +374,14 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_BANNED);
|
||||
SendPacket(pkt);
|
||||
LOG_INFO("server.authserver.banned", "'%s:%d' [AuthChallenge] Banned account %s tried to login!", ipAddress.c_str(), port, _accountInfo.Login.c_str());
|
||||
LOG_INFO("server.authserver.banned", "'{}:{}' [AuthChallenge] Banned account {} tried to login!", ipAddress, port, _accountInfo.Login);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_SUSPENDED);
|
||||
SendPacket(pkt);
|
||||
LOG_INFO("server.authserver.banned", "'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", ipAddress.c_str(), port, _accountInfo.Login.c_str());
|
||||
LOG_INFO("server.authserver.banned", "'{}:{}' [AuthChallenge] Temporarily banned account {} tried to login!", ipAddress, port, _accountInfo.Login);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
|
||||
if (!success)
|
||||
{
|
||||
pkt << uint8(WOW_FAIL_DB_BUSY);
|
||||
LOG_ERROR("server.authserver", "[AuthChallenge] Account '%s' has invalid ciphertext for TOTP token key stored", _accountInfo.Login.c_str());
|
||||
LOG_ERROR("server.authserver", "[AuthChallenge] Account '{}' has invalid ciphertext for TOTP token key stored", _accountInfo.Login);
|
||||
SendPacket(pkt);
|
||||
return;
|
||||
}
|
||||
@@ -444,8 +444,8 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
|
||||
if (securityFlags & 0x04) // Security token input
|
||||
pkt << uint8(1);
|
||||
|
||||
LOG_DEBUG("server.authserver", "'%s:%d' [AuthChallenge] account %s is using '%s' locale (%u)",
|
||||
ipAddress.c_str(), port, _accountInfo.Login.c_str(), _localizationName.c_str(), GetLocaleByName(_localizationName));
|
||||
LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] account {} is using '{}' locale ({})",
|
||||
ipAddress, port, _accountInfo.Login, _localizationName, GetLocaleByName(_localizationName));
|
||||
|
||||
_status = STATUS_LOGON_PROOF;
|
||||
}
|
||||
@@ -511,7 +511,7 @@ bool AuthSession::HandleLogonProof()
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_DEBUG("server.authserver", "'%s:%d' User '%s' successfully authenticated", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountInfo.Login.c_str());
|
||||
LOG_DEBUG("server.authserver", "'{}:{}' User '{}' successfully authenticated", GetRemoteIpAddress().to_string(), GetRemotePort(), _accountInfo.Login);
|
||||
|
||||
// Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
|
||||
// No SQL injection (escaped user name) and IP address as received by socket
|
||||
@@ -565,8 +565,8 @@ bool AuthSession::HandleLogonProof()
|
||||
packet << uint16(0); // LoginFlags, 1 has account message
|
||||
SendPacket(packet);
|
||||
|
||||
LOG_INFO("server.authserver.hack", "'%s:%d' [AuthChallenge] account %s tried to login with invalid password!",
|
||||
GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountInfo.Login.c_str());
|
||||
LOG_INFO("server.authserver.hack", "'{}:{}' [AuthChallenge] account {} tried to login with invalid password!",
|
||||
GetRemoteIpAddress().to_string(), GetRemotePort(), _accountInfo.Login);
|
||||
|
||||
uint32 MaxWrongPassCount = sConfigMgr->GetOption<int32>("WrongPass.MaxCount", 0);
|
||||
|
||||
@@ -600,8 +600,8 @@ bool AuthSession::HandleLogonProof()
|
||||
stmt->setUInt32(1, WrongPassBanTime);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
LOG_DEBUG("server.authserver", "'%s:%d' [AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
|
||||
GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountInfo.Login.c_str(), WrongPassBanTime, _accountInfo.FailedLogins);
|
||||
LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] account {} got banned for '{}' seconds because it failed to authenticate '{}' times",
|
||||
GetRemoteIpAddress().to_string(), GetRemotePort(), _accountInfo.Login, WrongPassBanTime, _accountInfo.FailedLogins);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -610,8 +610,8 @@ bool AuthSession::HandleLogonProof()
|
||||
stmt->setUInt32(1, WrongPassBanTime);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
LOG_DEBUG("server.authserver", "'%s:%d' [AuthChallenge] IP got banned for '%u' seconds because account %s failed to authenticate '%u' times",
|
||||
GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), WrongPassBanTime, _accountInfo.Login.c_str(), _accountInfo.FailedLogins);
|
||||
LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] IP got banned for '{}' seconds because account {} failed to authenticate '{}' times",
|
||||
GetRemoteIpAddress().to_string(), GetRemotePort(), WrongPassBanTime, _accountInfo.Login, _accountInfo.FailedLogins);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,7 +629,7 @@ bool AuthSession::HandleReconnectChallenge()
|
||||
return false;
|
||||
|
||||
std::string login((char const*)challenge->I, challenge->I_len);
|
||||
LOG_DEBUG("server.authserver", "[ReconnectChallenge] '%s'", login.c_str());
|
||||
LOG_DEBUG("server.authserver", "[ReconnectChallenge] '{}'", login);
|
||||
|
||||
_build = challenge->build;
|
||||
_expversion = uint8(AuthHelper::IsPostBCAcceptedClientBuild(_build) ? POST_BC_EXP_FLAG : (AuthHelper::IsPreBCAcceptedClientBuild(_build) ? PRE_BC_EXP_FLAG : NO_VALID_EXP_FLAG));
|
||||
@@ -723,8 +723,8 @@ bool AuthSession::HandleReconnectProof()
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("server.authserver.hack", "'%s:%d' [ERROR] user %s tried to login, but session is invalid.", GetRemoteIpAddress().to_string().c_str(),
|
||||
GetRemotePort(), _accountInfo.Login.c_str());
|
||||
LOG_ERROR("server.authserver.hack", "'{}:{}' [ERROR] user {} tried to login, but session is invalid.", GetRemoteIpAddress().to_string(),
|
||||
GetRemotePort(), _accountInfo.Login);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user