aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-10-12 15:34:01 +0200
committerShauren <shauren.trinity@gmail.com>2014-10-12 15:34:01 +0200
commit7679ecd7b3f9cff718023bee80eb6558fdf17b6e (patch)
treef0ffdfc94a0aa3b1067fa35c580facc7f6f2c72f
parentc2a39ce36ab41f56cce6f9b31de7835c5f90bd82 (diff)
Core/Battle.net: Improved logging - use separate filters instead of throwing everything to one logger
-rw-r--r--src/server/bnetserver/Packets/FriendsPackets.cpp12
-rw-r--r--src/server/bnetserver/Packets/FriendsPackets.h1
-rw-r--r--src/server/bnetserver/Packets/WoWRealmPackets.cpp14
-rw-r--r--src/server/bnetserver/Packets/WoWRealmPackets.h2
-rw-r--r--src/server/bnetserver/Realms/RealmList.cpp20
-rw-r--r--src/server/bnetserver/Server/Session.cpp55
-rw-r--r--src/server/bnetserver/Server/Session.h5
-rw-r--r--src/server/bnetserver/bnetserver.conf.dist3
8 files changed, 66 insertions, 46 deletions
diff --git a/src/server/bnetserver/Packets/FriendsPackets.cpp b/src/server/bnetserver/Packets/FriendsPackets.cpp
index 7a4bd7dd64f..ec7078f9b02 100644
--- a/src/server/bnetserver/Packets/FriendsPackets.cpp
+++ b/src/server/bnetserver/Packets/FriendsPackets.cpp
@@ -117,10 +117,10 @@ void Battlenet::Friends::RealIdFriendInvite::Read()
}
_stream.Read<uint8>(1);
-
+
if (_stream.Read<uint8>(1))
Message = _stream.ReadString(9);
-
+
_stream.Read<uint32>(32);
}
@@ -129,12 +129,6 @@ std::string Battlenet::Friends::RealIdFriendInvite::ToString() const
return "Battlenet::Friends::RealIdFriendInvite Mail: " + Email + " Message: " + Message;
}
-void Battlenet::Friends::RealIdFriendInvite::CallHandler(Session* session)
-{
- FriendInviteResult* result = new FriendInviteResult();
- session->AsyncWrite(result);
-}
-
std::string Battlenet::Friends::FriendInviteResult::ToString() const
{
return "Battlenet::Friends::RealIdFriendInviteResult";
@@ -150,7 +144,7 @@ void Battlenet::Friends::FriendInviteResult::Write()
_stream.WriteString("Testing2", 8);
}
_stream.Write(5, 32);
-
+
_stream.Write(0, 0xC); // Ignored
_stream.Write(1, 16);
diff --git a/src/server/bnetserver/Packets/FriendsPackets.h b/src/server/bnetserver/Packets/FriendsPackets.h
index a35b02e616d..692ab5a860b 100644
--- a/src/server/bnetserver/Packets/FriendsPackets.h
+++ b/src/server/bnetserver/Packets/FriendsPackets.h
@@ -139,7 +139,6 @@ namespace Battlenet
void Read() override;
std::string ToString() const override;
- void CallHandler(Session* session) override;
std::string Email;
std::string Message;
diff --git a/src/server/bnetserver/Packets/WoWRealmPackets.cpp b/src/server/bnetserver/Packets/WoWRealmPackets.cpp
index 4d11dd0a11f..beeeb14895c 100644
--- a/src/server/bnetserver/Packets/WoWRealmPackets.cpp
+++ b/src/server/bnetserver/Packets/WoWRealmPackets.cpp
@@ -128,11 +128,17 @@ void Battlenet::WoWRealm::ListUpdate::Write()
std::string Battlenet::WoWRealm::ListUpdate::ToString() const
{
std::ostringstream stream;
- stream << "Battlenet::WoWRealm::ListUpdate Timezone " << Timezone << " Population " << Population << " Lock " << uint32(Lock) << " Type " << Type << " Name " << Name
- << " Flags " << uint32(Flags) << " Region " << uint32(Id.Region) << " Battlegroup " << uint32(Id.Battlegroup) << " Index " << Id.Index;
+ stream << "Battlenet::WoWRealm::ListUpdate";
+ if (UpdateState == UPDATE)
+ {
+ stream << " Timezone: " << Timezone << " Population: " << Population << " Lock: " << uint32(Lock) << " Type: " << Type << " Name: " << Name
+ << " Flags: " << uint32(Flags) << " Region: " << uint32(Id.Region) << " Battlegroup: " << uint32(Id.Battlegroup) << " Index: " << Id.Index;
- if (!Version.empty())
- stream << " Version " << Version;
+ if (!Version.empty())
+ stream << " Version: " << Version;
+ }
+ else
+ stream << " Delete realm [Region: " << uint32(Id.Region) << " Battlegroup : " << uint32(Id.Battlegroup) << " Index : " << Id.Index << "]";
return stream.str().c_str();
}
diff --git a/src/server/bnetserver/Packets/WoWRealmPackets.h b/src/server/bnetserver/Packets/WoWRealmPackets.h
index fe211d6fea4..403ca71279f 100644
--- a/src/server/bnetserver/Packets/WoWRealmPackets.h
+++ b/src/server/bnetserver/Packets/WoWRealmPackets.h
@@ -163,7 +163,7 @@ namespace Battlenet
};
JoinResponseV2() : ServerPacket(PacketHeader(SMSG_JOIN_RESPONSE_V2, WOWREALM)),
- ServerSeed(0), Response(SUCCESS), ResponseCode(26)
+ Response(SUCCESS), ResponseCode(26), ServerSeed(0)
{
}
diff --git a/src/server/bnetserver/Realms/RealmList.cpp b/src/server/bnetserver/Realms/RealmList.cpp
index 8d6edb12b5c..2bf93e12cb3 100644
--- a/src/server/bnetserver/Realms/RealmList.cpp
+++ b/src/server/bnetserver/Realms/RealmList.cpp
@@ -97,7 +97,6 @@ void RealmList::UpdateRealm(Battlenet::RealmId const& id, const std::string& nam
Realm& realm = _realms[id];
realm.Keep = true;
- realm.Updated = false;
realm.Id = id;
UpdateField(realm.Name, name, realm.Updated);
@@ -117,7 +116,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
if (error)
return;
- TC_LOG_INFO("server.bnetserver", "Updating Realm List...");
+ TC_LOG_DEBUG("realmlist", "Updating Realm List...");
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_REALMLIST);
PreparedQueryResult result = LoginDatabase.Query(stmt);
@@ -139,7 +138,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
boost::asio::ip::tcp::resolver::iterator endPoint = _resolver->resolve(externalAddressQuery, ec);
if (endPoint == end || ec)
{
- TC_LOG_ERROR("server.bnetserver", "Could not resolve address %s", fields[2].GetString().c_str());
+ TC_LOG_ERROR("realmlist", "Could not resolve address %s", fields[2].GetString().c_str());
continue;
}
@@ -149,7 +148,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
endPoint = _resolver->resolve(localAddressQuery, ec);
if (endPoint == end || ec)
{
- TC_LOG_ERROR("server.bnetserver", "Could not resolve address %s", fields[3].GetString().c_str());
+ TC_LOG_ERROR("realmlist", "Could not resolve address %s", fields[3].GetString().c_str());
continue;
}
@@ -159,7 +158,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
endPoint = _resolver->resolve(localSubmaskQuery, ec);
if (endPoint == end || ec)
{
- TC_LOG_ERROR("server.bnetserver", "Could not resolve address %s", fields[4].GetString().c_str());
+ TC_LOG_ERROR("realmlist", "Could not resolve address %s", fields[4].GetString().c_str());
continue;
}
@@ -181,11 +180,11 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
UpdateRealm(id, name, externalAddress, localAddress, localSubmask, port, icon, flag, timezone,
(allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop);
- //TC_LOG_INFO("server.bnetserver", "Added realm \"%s\" at %s:%u.", name.c_str(), m_realms[id].ExternalAddress.to_string().c_str(), port);
+ TC_LOG_TRACE("realmlist", "Realm \"%s\" at %s:%u.", name.c_str(), externalAddress.to_string().c_str(), port);
}
catch (std::exception& ex)
{
- TC_LOG_ERROR("server.bnetserver", "Realmlist::UpdateRealms has thrown an exception: %s", ex.what());
+ TC_LOG_ERROR("realmlist", "Realmlist::UpdateRealms has thrown an exception: %s", ex.what());
ASSERT(false);
}
}
@@ -195,12 +194,15 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
std::vector<Realm const*> updatedRealms;
std::vector<Battlenet::RealmId> deletedRealms;
- for (RealmMap::value_type const& pair : _realms)
+ for (RealmMap::value_type& pair : _realms)
{
if (pair.second.Updated)
updatedRealms.push_back(&pair.second);
- if (!pair.second.Keep)
+ else if (!pair.second.Keep)
deletedRealms.push_back(pair.first);
+
+ pair.second.Updated = false;
+ pair.second.Keep = false;
}
for (Battlenet::RealmId const& deleted : deletedRealms)
diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp
index 42d5b6a5a06..fa678165cf3 100644
--- a/src/server/bnetserver/Server/Session.cpp
+++ b/src/server/bnetserver/Server/Session.cpp
@@ -64,7 +64,6 @@ Battlenet::Session::Session(tcp::socket&& socket) : Socket(std::move(socket)), _
Battlenet::Session::~Session()
{
sSessionMgr.RemoveSession(this);
- TC_LOG_TRACE("server.battlenet", "Battlenet::Session::OnClose");
}
void Battlenet::Session::_SetVSFields(std::string const& pstr)
@@ -91,7 +90,7 @@ void Battlenet::Session::_SetVSFields(std::string const& pstr)
void Battlenet::Session::LogUnhandledPacket(ClientPacket const& packet)
{
- TC_LOG_DEBUG("server.battlenet", "Battlenet::Session::LogUnhandledPacket %s", packet.ToString().c_str());
+ TC_LOG_DEBUG("session.packets", "%s Received unhandled packet %s", GetClientInfo().c_str(), packet.ToString().c_str());
}
void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const& logonRequest)
@@ -107,7 +106,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(LOGIN_BANNED);
AsyncWrite(logonResponse);
- TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Banned ip '%s:%d' tries to login!", ip_address.c_str(), GetRemotePort());
+ TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Banned ip '%s:%d' tries to login!", ip_address.c_str(), GetRemotePort());
return;
}
@@ -184,7 +183,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
// If the IP is 'locked', check that the player comes indeed from the correct IP address
if (fields[2].GetUInt8() == 1) // if ip is locked
{
- TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Account '%s' is locked to IP - '%s' is logging in from '%s'", _accountName.c_str(), fields[4].GetCString(), ip_address.c_str());
+ TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is locked to IP - '%s' is logging in from '%s'", _accountName.c_str(), fields[4].GetCString(), ip_address.c_str());
if (strcmp(fields[4].GetCString(), ip_address.c_str()) != 0)
{
@@ -196,10 +195,10 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
}
else
{
- TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Account '%s' is not locked to ip", _accountName.c_str());
+ TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is not locked to ip", _accountName.c_str());
std::string accountCountry = fields[3].GetString();
if (accountCountry.empty() || accountCountry == "00")
- TC_LOG_DEBUG("server.battlenet", "[Battlenet::LogonRequest] Account '%s' is not locked to country", _accountName.c_str());
+ TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is not locked to country", _accountName.c_str());
else if (!accountCountry.empty())
{
uint32 ip = inet_addr(ip_address.c_str());
@@ -210,7 +209,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
if (PreparedQueryResult sessionCountryQuery = LoginDatabase.Query(stmt))
{
std::string loginCountry = (*sessionCountryQuery)[0].GetString();
- TC_LOG_DEBUG("server.battlenet", "[Battlenet::AuthChallenge] Account '%s' is locked to country: '%s' Player country is '%s'", _accountName.c_str(), accountCountry.c_str(), loginCountry.c_str());
+ TC_LOG_DEBUG("session", "[Battlenet::LogonRequest] Account '%s' is locked to country: '%s' Player country is '%s'", _accountName.c_str(), accountCountry.c_str(), loginCountry.c_str());
if (loginCountry != accountCountry)
{
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
@@ -237,7 +236,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(LOGIN_BANNED);
AsyncWrite(logonResponse);
- TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::LogonRequest] Banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
+ TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::LogonRequest] Banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
return;
}
else
@@ -245,7 +244,7 @@ void Battlenet::Session::HandleLogonRequest(Authentication::LogonRequest const&
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(LOGIN_SUSPENDED);
AsyncWrite(logonResponse);
- TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::LogonRequest] Temporarily banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
+ TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::LogonRequest] Temporarily banned account %s tried to login!", ip_address.c_str(), GetRemotePort(), _accountName.c_str());
return;
}
}
@@ -494,7 +493,7 @@ void Battlenet::Session::ReadHandler()
if (header.Channel != AUTHENTICATION && !_authed)
{
- TC_LOG_DEBUG("server.battlenet", "Battlenet::Session::ReadDataHandler Received not allowed packet %s", header.ToString().c_str());
+ TC_LOG_DEBUG("session.packets", "%s Received not allowed %s. Client has not authed yet.", GetClientInfo().c_str(), header.ToString().c_str());
CloseSocket();
return;
}
@@ -503,13 +502,13 @@ void Battlenet::Session::ReadHandler()
{
packet->CallHandler(this);
if (packet->WasHandled())
- TC_LOG_TRACE("server.battlenet", "Battlenet::Session::ReadDataHandler %s", packet->ToString().c_str());
+ TC_LOG_TRACE("session.packets", "%s Received %s", GetClientInfo().c_str(), packet->ToString().c_str());
delete packet;
}
else
{
- TC_LOG_DEBUG("server.battlenet", "Battlenet::Session::ReadDataHandler Unhandled opcode %s", header.ToString().c_str());
+ TC_LOG_DEBUG("session.packets", "%s Received unknown %s", GetClientInfo().c_str(), header.ToString().c_str());
break;
}
@@ -517,7 +516,7 @@ void Battlenet::Session::ReadHandler()
}
catch (BitStreamPositionException const& e)
{
- TC_LOG_ERROR("server.battlenet", "Battlenet::Session::ReadDataHandler Exception: %s", e.what());
+ TC_LOG_ERROR("session.packets", "%s Exception thrown during packet processing %s", GetClientInfo().c_str(), e.what());
CloseSocket();
return;
}
@@ -529,7 +528,7 @@ void Battlenet::Session::ReadHandler()
void Battlenet::Session::Start()
{
- TC_LOG_TRACE("server.battlenet", "Battlenet::Session::Start");
+ TC_LOG_TRACE("session", "Accepted connection from %s", GetRemoteIpAddress().to_string().c_str());
AsyncRead();
}
@@ -541,7 +540,7 @@ void Battlenet::Session::AsyncWrite(ServerPacket* packet)
return;
}
- TC_LOG_TRACE("server.battlenet", "Battlenet::Session::AsyncWrite %s", packet->ToString().c_str());
+ TC_LOG_TRACE("session.packets", "%s Sending %s", GetClientInfo().c_str(), packet->ToString().c_str());
packet->Write();
@@ -752,12 +751,12 @@ bool Battlenet::Session::HandlePasswordModule(BitStream* dataStream, ServerPacke
if (fields[2].GetUInt32() == fields[3].GetUInt32())
{
logonResponse->SetAuthResult(LOGIN_BANNED);
- TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::Password] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
+ TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::Password] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
}
else
{
logonResponse->SetAuthResult(LOGIN_SUSPENDED);
- TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::Password] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
+ TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::Password] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
}
ReplaceResponse(response, logonResponse);
@@ -824,12 +823,12 @@ bool Battlenet::Session::HandleSelectGameAccountModule(BitStream* dataStream, Se
if (fields[2].GetUInt32() == fields[3].GetUInt32())
{
logonResponse->SetAuthResult(LOGIN_BANNED);
- TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::SelectGameAccount] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
+ TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::SelectGameAccount] Banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
}
else
{
logonResponse->SetAuthResult(LOGIN_SUSPENDED);
- TC_LOG_DEBUG("server.battlenet", "'%s:%d' [Battlenet::SelectGameAccount] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
+ TC_LOG_DEBUG("session", "'%s:%d' [Battlenet::SelectGameAccount] Temporarily banned account %s tried to login!", GetRemoteIpAddress().to_string().c_str(), GetRemotePort(), _accountName.c_str());
}
ReplaceResponse(response, logonResponse);
@@ -935,7 +934,7 @@ bool Battlenet::Session::HandleResumeModule(BitStream* dataStream, ServerPacket*
stmt->setString(0, _accountName);
LoginDatabase.Execute(stmt);
- TC_LOG_DEBUG("server.battlenet", "[Battlenet::Resume] Invalid proof!");
+ TC_LOG_DEBUG("session", "[Battlenet::Resume] Invalid proof!");
Authentication::ResumeResponse* resumeResponse = new Authentication::ResumeResponse();
resumeResponse->SetAuthResult(AUTH_UNKNOWN_ACCOUNT);
ReplaceResponse(response, resumeResponse);
@@ -975,6 +974,7 @@ bool Battlenet::Session::HandleResumeModule(BitStream* dataStream, ServerPacket*
bool Battlenet::Session::UnhandledModule(BitStream* /*dataStream*/, ServerPacket** response)
{
+ TC_LOG_ERROR("session.packets", "Unhandled module.");
Authentication::LogonResponse* logonResponse = new Authentication::LogonResponse();
logonResponse->SetAuthResult(AUTH_CORRUPTED_MODULE);
ReplaceResponse(response, logonResponse);
@@ -1026,3 +1026,18 @@ Battlenet::WoWRealm::ListUpdate* Battlenet::Session::BuildListUpdate(Realm const
listUpdate->Id = realm->Id;
return listUpdate;
}
+
+std::string Battlenet::Session::GetClientInfo() const
+{
+ std::ostringstream stream;
+ stream << '[' << GetRemoteIpAddress() << ':' << GetRemotePort();
+ if (!_accountName.empty())
+ stream << ", Account: " << _accountName;
+
+ if (!_gameAccountName.empty())
+ stream << ", Game account: " << _gameAccountName;
+
+ stream << ']';
+
+ return stream.str();
+}
diff --git a/src/server/bnetserver/Server/Session.h b/src/server/bnetserver/Server/Session.h
index 3f5e53389b8..764ef7e0c73 100644
--- a/src/server/bnetserver/Server/Session.h
+++ b/src/server/bnetserver/Server/Session.h
@@ -85,14 +85,14 @@ namespace Battlenet
void UpdateRealms(std::vector<Realm const*>& realms, std::vector<RealmId>& deletedRealms);
- void AsyncWrite(ServerPacket* packet);
-
uint32 GetAccountId() const { return _accountId; }
uint32 GetGameAccountId() const { return _gameAccountId; }
bool IsSubscribedToRealmListUpdates() const { return _subscribedToRealmListUpdates; }
protected:
+ void AsyncWrite(ServerPacket* packet);
+
void ReadHandler() override;
private:
@@ -108,6 +108,7 @@ namespace Battlenet
bool UnhandledModule(BitStream* dataStream, ServerPacket** response);
WoWRealm::ListUpdate* BuildListUpdate(Realm const* realm) const;
+ std::string GetClientInfo() const;
uint32 _accountId;
std::string _accountName;
diff --git a/src/server/bnetserver/bnetserver.conf.dist b/src/server/bnetserver/bnetserver.conf.dist
index ac02a06c918..84456c117b3 100644
--- a/src/server/bnetserver/bnetserver.conf.dist
+++ b/src/server/bnetserver/bnetserver.conf.dist
@@ -245,6 +245,9 @@ Appender.Bnet=2,2,0,Bnet.log,w
#
Logger.root=3,Console Bnet
+Logger.realmlist=3,Console Bnet
+Logger.session=3,Console Bnet
+Logger.session.packets=3,Console Bnet
#
###################################################################################################