mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +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:
@@ -69,7 +69,7 @@ void WorldSocket::CheckIpCallback(PreparedQueryResult result)
|
||||
if (banned)
|
||||
{
|
||||
SendAuthResponseError(AUTH_REJECT);
|
||||
LOG_ERROR("network", "WorldSocket::CheckIpCallback: Sent Auth Response (IP %s banned).", GetRemoteIpAddress().to_string().c_str());
|
||||
LOG_ERROR("network", "WorldSocket::CheckIpCallback: Sent Auth Response (IP {} banned).", GetRemoteIpAddress().to_string());
|
||||
DelayedCloseSocket();
|
||||
return;
|
||||
}
|
||||
@@ -223,8 +223,8 @@ bool WorldSocket::ReadHeaderHandler()
|
||||
|
||||
if (!header->IsValidSize() || !header->IsValidOpcode())
|
||||
{
|
||||
LOG_ERROR("network", "WorldSocket::ReadHeaderHandler(): client %s sent malformed packet (size: %hu, cmd: %u)",
|
||||
GetRemoteIpAddress().to_string().c_str(), header->size, header->cmd);
|
||||
LOG_ERROR("network", "WorldSocket::ReadHeaderHandler(): client {} sent malformed packet (size: {}, cmd: {})",
|
||||
GetRemoteIpAddress().to_string(), header->size, header->cmd);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
|
||||
catch (ByteBufferException const&)
|
||||
{
|
||||
}
|
||||
LOG_ERROR("network", "WorldSocket::ReadDataHandler(): client %s sent malformed CMSG_PING", GetRemoteIpAddress().to_string().c_str());
|
||||
LOG_ERROR("network", "WorldSocket::ReadDataHandler(): client {} sent malformed CMSG_PING", GetRemoteIpAddress().to_string());
|
||||
return ReadDataHandlerResult::Error;
|
||||
}
|
||||
case CMSG_AUTH_SESSION:
|
||||
@@ -337,7 +337,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
|
||||
{
|
||||
// locking just to safely log offending user is probably overkill but we are disconnecting him anyway
|
||||
if (sessionGuard.try_lock())
|
||||
LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from %s", _worldSession->GetPlayerInfo().c_str());
|
||||
LOG_ERROR("network", "WorldSocket::ProcessIncoming: received duplicate CMSG_AUTH_SESSION from {}", _worldSession->GetPlayerInfo());
|
||||
return ReadDataHandlerResult::Error;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
|
||||
}
|
||||
catch (ByteBufferException const&) { }
|
||||
|
||||
LOG_ERROR("network", "WorldSocket::ReadDataHandler(): client %s sent malformed CMSG_AUTH_SESSION", GetRemoteIpAddress().to_string().c_str());
|
||||
LOG_ERROR("network", "WorldSocket::ReadDataHandler(): client {} sent malformed CMSG_AUTH_SESSION", GetRemoteIpAddress().to_string());
|
||||
return ReadDataHandlerResult::Error;
|
||||
}
|
||||
case CMSG_KEEP_ALIVE: // todo: handle this packet in the same way of CMSG_TIME_SYNC_RESP
|
||||
@@ -371,7 +371,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
|
||||
|
||||
if (!_worldSession)
|
||||
{
|
||||
LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = %u", uint32(opcode));
|
||||
LOG_ERROR("network.opcode", "ProcessIncoming: Client not authed opcode = {}", uint32(opcode));
|
||||
delete packetToQueue;
|
||||
return ReadDataHandlerResult::Error;
|
||||
}
|
||||
@@ -379,7 +379,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
|
||||
OpcodeHandler const* handler = opcodeTable[opcode];
|
||||
if (!handler)
|
||||
{
|
||||
LOG_ERROR("network.opcode", "No defined handler for opcode %s sent by %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet.GetOpcode())).c_str(), _worldSession->GetPlayerInfo().c_str());
|
||||
LOG_ERROR("network.opcode", "No defined handler for opcode {} sent by {}", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet.GetOpcode())), _worldSession->GetPlayerInfo());
|
||||
delete packetToQueue;
|
||||
return ReadDataHandlerResult::Error;
|
||||
}
|
||||
@@ -397,18 +397,18 @@ void WorldSocket::LogOpcodeText(OpcodeClient opcode, std::unique_lock<std::mutex
|
||||
{
|
||||
if (!guard)
|
||||
{
|
||||
LOG_TRACE("network.opcode", "C->S: %s %s", GetRemoteIpAddress().to_string().c_str(), GetOpcodeNameForLogging(opcode).c_str());
|
||||
LOG_TRACE("network.opcode", "C->S: {} {}", GetRemoteIpAddress().to_string(), GetOpcodeNameForLogging(opcode));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_TRACE("network.opcode", "C->S: %s %s", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()).c_str(),
|
||||
GetOpcodeNameForLogging(opcode).c_str());
|
||||
LOG_TRACE("network.opcode", "C->S: {} {}", (_worldSession ? _worldSession->GetPlayerInfo() : GetRemoteIpAddress().to_string()),
|
||||
GetOpcodeNameForLogging(opcode));
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSocket::SendPacketAndLogOpcode(WorldPacket const& packet)
|
||||
{
|
||||
LOG_TRACE("network.opcode", "S->C: %s %s", GetRemoteIpAddress().to_string().c_str(), GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet.GetOpcode())).c_str());
|
||||
LOG_TRACE("network.opcode", "S->C: {} {}", GetRemoteIpAddress().to_string(), GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet.GetOpcode())));
|
||||
SendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
if (sWorld->IsClosed())
|
||||
{
|
||||
SendAuthResponseError(AUTH_REJECT);
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: World closed, denying client (%s).", GetRemoteIpAddress().to_string().c_str());
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: World closed, denying client ({}).", GetRemoteIpAddress().to_string());
|
||||
DelayedCloseSocket();
|
||||
return;
|
||||
}
|
||||
@@ -490,8 +490,8 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
if (authSession->RealmID != realm.Id.Realm)
|
||||
{
|
||||
SendAuthResponseError(REALM_LIST_REALM_NOT_FOUND);
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client %s requested connecting with realm id %u but this realm has id %u set in config.",
|
||||
GetRemoteIpAddress().to_string().c_str(), authSession->RealmID, realm.Id.Realm);
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client {} requested connecting with realm id {} but this realm has id {} set in config.",
|
||||
GetRemoteIpAddress().to_string(), authSession->RealmID, realm.Id.Realm);
|
||||
DelayedCloseSocket();
|
||||
return;
|
||||
}
|
||||
@@ -501,7 +501,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
if (wardenActive && account.OS != "Win" && account.OS != "OSX")
|
||||
{
|
||||
SendAuthResponseError(AUTH_REJECT);
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client %s attempted to log in using invalid client OS (%s).", address.c_str(), account.OS.c_str());
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: Client {} attempted to log in using invalid client OS ({}).", address, account.OS);
|
||||
DelayedCloseSocket();
|
||||
return;
|
||||
}
|
||||
@@ -520,7 +520,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
if (sha.GetDigest() != authSession->Digest)
|
||||
{
|
||||
SendAuthResponseError(AUTH_FAILED);
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: Authentication failed for account: %u ('%s') address: %s", account.Id, authSession->Account.c_str(), address.c_str());
|
||||
LOG_ERROR("network", "WorldSocket::HandleAuthSession: Authentication failed for account: {} ('{}') address: {}", account.Id, authSession->Account, address);
|
||||
DelayedCloseSocket();
|
||||
return;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
if (account.LastIP != address)
|
||||
{
|
||||
SendAuthResponseError(AUTH_FAILED);
|
||||
LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs. Original IP: %s, new IP: %s).", account.LastIP.c_str(), address.c_str());
|
||||
LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs. Original IP: {}, new IP: {}).", account.LastIP, address);
|
||||
// We could log on hook only instead of an additional db log, however action logger is config based. Better keep DB logging as well
|
||||
sScriptMgr->OnFailedAccountLogin(account.Id);
|
||||
DelayedCloseSocket();
|
||||
@@ -546,7 +546,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
if (account.LockCountry != _ipCountry)
|
||||
{
|
||||
SendAuthResponseError(AUTH_FAILED);
|
||||
LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account country differs. Original country: %s, new country: %s).", account.LockCountry.c_str(), _ipCountry.c_str());
|
||||
LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Sent Auth Response (Account country differs. Original country: {}, new country: {}).", account.LockCountry, _ipCountry);
|
||||
// We could log on hook only instead of an additional db log, however action logger is config based. Better keep DB logging as well
|
||||
sScriptMgr->OnFailedAccountLogin(account.Id);
|
||||
DelayedCloseSocket();
|
||||
@@ -576,7 +576,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
|
||||
// Check locked state for server
|
||||
AccountTypes allowedAccountType = sWorld->GetPlayerSecurityLimit();
|
||||
LOG_DEBUG("network", "Allowed Level: %u Player Level %u", allowedAccountType, account.Security);
|
||||
LOG_DEBUG("network", "Allowed Level: {} Player Level {}", allowedAccountType, account.Security);
|
||||
if (allowedAccountType > SEC_PLAYER && account.Security < allowedAccountType)
|
||||
{
|
||||
SendAuthResponseError(AUTH_UNAVAILABLE);
|
||||
@@ -586,7 +586,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", authSession->Account.c_str(), address.c_str());
|
||||
LOG_DEBUG("network", "WorldSocket::HandleAuthSession: Client '{}' authenticated successfully from {}.", authSession->Account, address);
|
||||
|
||||
// Update the last_ip in the database as it was successful for login
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP);
|
||||
@@ -660,8 +660,8 @@ bool WorldSocket::HandlePing(WorldPacket& recvPacket)
|
||||
|
||||
if (_worldSession && AccountMgr::IsPlayerAccount(_worldSession->GetSecurity()))
|
||||
{
|
||||
LOG_ERROR("network", "WorldSocket::HandlePing: %s kicked for over-speed pings (address: %s)",
|
||||
_worldSession->GetPlayerInfo().c_str(), GetRemoteIpAddress().to_string().c_str());
|
||||
LOG_ERROR("network", "WorldSocket::HandlePing: {} kicked for over-speed pings (address: {})",
|
||||
_worldSession->GetPlayerInfo(), GetRemoteIpAddress().to_string());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -680,7 +680,7 @@ bool WorldSocket::HandlePing(WorldPacket& recvPacket)
|
||||
_worldSession->SetLatency(latency);
|
||||
else
|
||||
{
|
||||
LOG_ERROR("network", "WorldSocket::HandlePing: peer sent CMSG_PING, but is not authenticated or got recently kicked, address = %s", GetRemoteIpAddress().to_string().c_str());
|
||||
LOG_ERROR("network", "WorldSocket::HandlePing: peer sent CMSG_PING, but is not authenticated or got recently kicked, address = {}", GetRemoteIpAddress().to_string());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user