From 75cddbea716a74da41bbb6c9e93d01e10884f864 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Wed, 9 Dec 2015 20:30:47 -0600 Subject: [PATCH] Loginserver conversion to new Logging system --- common/eqemu_logsys.cpp | 1 + common/eqemu_logsys.h | 2 + loginserver/client.cpp | 46 ++++++++--------- loginserver/client_manager.cpp | 29 ++++++----- loginserver/config.cpp | 12 ++--- loginserver/encryption.cpp | 12 ++--- loginserver/main.cpp | 69 ++++++++++++------------- loginserver/server_manager.cpp | 18 ++++--- loginserver/world_server.cpp | 93 ++++++++++++++++++---------------- 9 files changed, 146 insertions(+), 136 deletions(-) diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index 189c45bf6..4c0ee1c9f 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -102,6 +102,7 @@ void EQEmuLogSys::LoadLogSettingsDefaults() log_settings[Logs::UCS_Server].log_to_console = Logs::General; log_settings[Logs::Crash].log_to_console = Logs::General; log_settings[Logs::MySQLError].log_to_console = Logs::General; + log_settings[Logs::Login_Server].log_to_console = Logs::General; /* Declare process file names for log writing If there is no process_file_name declared, no log file will be written, simply diff --git a/common/eqemu_logsys.h b/common/eqemu_logsys.h index a99b3b439..153d61582 100644 --- a/common/eqemu_logsys.h +++ b/common/eqemu_logsys.h @@ -82,6 +82,7 @@ namespace Logs { Client_Server_Packet_Unhandled, Server_Client_Packet_With_Dump, Client_Server_Packet_With_Dump, + Login_Server, MaxCategoryID /* Don't Remove this*/ }; @@ -130,6 +131,7 @@ namespace Logs { "Packet :: Client -> Server Unhandled", "Packet :: Server -> Client (Dump)", "Packet :: Client -> Server (Dump)", + "Login Server" }; } diff --git a/loginserver/client.cpp b/loginserver/client.cpp index 28836f915..a6cea46bf 100644 --- a/loginserver/client.cpp +++ b/loginserver/client.cpp @@ -16,12 +16,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "client.h" -#include "error_log.h" #include "login_server.h" #include "login_structures.h" #include "../common/misc_functions.h" +#include "../common/eqemu_logsys.h" -extern ErrorLog *server_log; +extern EQEmuLogSys Log; extern LoginServer server; Client::Client(std::shared_ptr c, LSClientVersion v) @@ -41,7 +41,7 @@ bool Client::Process() { if(server.options.IsTraceOn()) { - server_log->Log(log_network, "Application packet received from client (size %u)", app->Size()); + Log.Out(Logs::General, Logs::Login_Server, "Application packet received from client (size %u)", app->Size()); } if(server.options.IsDumpInPacketsOn()) @@ -55,7 +55,7 @@ bool Client::Process() { if(server.options.IsTraceOn()) { - server_log->Log(log_network, "Session ready received from client."); + Log.Out(Logs::General, Logs::Login_Server, "Session ready received from client."); } Handle_SessionReady((const char*)app->pBuffer, app->Size()); break; @@ -64,13 +64,13 @@ bool Client::Process() { if(app->Size() < 20) { - server_log->Log(log_network_error, "Login received but it is too small, discarding."); + Log.Out(Logs::General, Logs::Error, "Login received but it is too small, discarding."); break; } if(server.options.IsTraceOn()) { - server_log->Log(log_network, "Login received from client."); + Log.Out(Logs::General, Logs::Login_Server, "Login received from client."); } Handle_Login((const char*)app->pBuffer, app->Size()); @@ -80,7 +80,7 @@ bool Client::Process() { if(server.options.IsTraceOn()) { - server_log->Log(log_network, "Server list request received from client."); + Log.Out(Logs::General, Logs::Login_Server, "Server list request received from client."); } SendServerListPacket(); @@ -90,7 +90,7 @@ bool Client::Process() { if(app->Size() < sizeof(PlayEverquestRequest_Struct)) { - server_log->Log(log_network_error, "Play received but it is too small, discarding."); + Log.Out(Logs::General, Logs::Error, "Play received but it is too small, discarding."); break; } @@ -101,7 +101,7 @@ bool Client::Process() { char dump[64]; app->build_header_dump(dump); - server_log->Log(log_network_error, "Recieved unhandled application packet from the client: %s.", dump); + Log.Out(Logs::General, Logs::Error, "Recieved unhandled application packet from the client: %s.", dump); } } @@ -116,20 +116,20 @@ void Client::Handle_SessionReady(const char* data, unsigned int size) { if(status != cs_not_sent_session_ready) { - server_log->Log(log_network_error, "Session ready received again after already being received."); + Log.Out(Logs::General, Logs::Error, "Session ready received again after already being received."); return; } if(size < sizeof(unsigned int)) { - server_log->Log(log_network_error, "Session ready was too small."); + Log.Out(Logs::General, Logs::Error, "Session ready was too small."); return; } unsigned int mode = *((unsigned int*)data); if(mode == (unsigned int)lm_from_world) { - server_log->Log(log_network, "Session ready indicated logged in from world(unsupported feature), disconnecting."); + Log.Out(Logs::General, Logs::Login_Server, "Session ready indicated logged in from world(unsupported feature), disconnecting."); connection->Close(); return; } @@ -177,13 +177,13 @@ void Client::Handle_Login(const char* data, unsigned int size) { if(status != cs_waiting_for_login) { - server_log->Log(log_network_error, "Login received after already having logged in."); + Log.Out(Logs::General, Logs::Error, "Login received after already having logged in."); return; } if((size - 12) % 8 != 0) { - server_log->Log(log_network_error, "Login received packet of size: %u, this would cause a block corruption, discarding.", size); + Log.Out(Logs::General, Logs::Error, "Login received packet of size: %u, this would cause a block corruption, discarding.", size); return; } @@ -204,8 +204,8 @@ void Client::Handle_Login(const char* data, unsigned int size) if(server.options.IsTraceOn()) { - server_log->Log(log_client, "User: %s", e_user.c_str()); - server_log->Log(log_client, "Hash: %s", e_hash.c_str()); + Log.Out(Logs::General, Logs::Debug, "User: %s", e_user.c_str()); + Log.Out(Logs::General, Logs::Debug, "Hash: %s", e_hash.c_str()); } server.eq_crypto->DeleteHeap(e_buffer); @@ -218,8 +218,8 @@ void Client::Handle_Login(const char* data, unsigned int size) if(server.options.IsTraceOn()) { - server_log->Log(log_client, "User: %s", e_user.c_str()); - server_log->Log(log_client, "Hash: %s", e_hash.c_str()); + Log.Out(Logs::General, Logs::Debug, "User: %s", e_user.c_str()); + Log.Out(Logs::General, Logs::Debug, "Hash: %s", e_hash.c_str()); } _HeapDeleteCharBuffer(e_buffer); @@ -228,7 +228,7 @@ void Client::Handle_Login(const char* data, unsigned int size) bool result; if(server.db->GetLoginDataFromAccountName(e_user, d_pass_hash, d_account_id) == false) { - server_log->Log(log_client_error, "Error logging in, user %s does not exist in the database.", e_user.c_str()); + Log.Out(Logs::General, Logs::Error, "Error logging in, user %s does not exist in the database.", e_user.c_str()); result = false; } else @@ -331,7 +331,7 @@ void Client::Handle_Play(const char* data) { if(status != cs_logged_in) { - server_log->Log(log_client_error, "Client sent a play request when they either were not logged in, discarding."); + Log.Out(Logs::General, Logs::Error, "Client sent a play request when they either were not logged in, discarding."); return; } @@ -341,7 +341,7 @@ void Client::Handle_Play(const char* data) if(server.options.IsTraceOn()) { - server_log->Log(log_network, "Play received from client, server number %u sequence %u.", server_id_in, sequence_in); + Log.Out(Logs::General, Logs::Login_Server, "Play received from client, server number %u sequence %u.", server_id_in, sequence_in); } this->play_server_id = (unsigned int)play->ServerNumber; @@ -367,8 +367,8 @@ void Client::SendPlayResponse(EQApplicationPacket *outapp) { if(server.options.IsTraceOn()) { - server_log->Log(log_network_trace, "Sending play response for %s.", GetAccountName().c_str()); - server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); + Log.Out(Logs::General, Logs::Netcode, "Sending play response for %s.", GetAccountName().c_str()); + // server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); } connection->QueuePacket(outapp); status = cs_logged_in; diff --git a/loginserver/client_manager.cpp b/loginserver/client_manager.cpp index eb982f613..c600d58f5 100644 --- a/loginserver/client_manager.cpp +++ b/loginserver/client_manager.cpp @@ -16,13 +16,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "client_manager.h" -#include "error_log.h" #include "login_server.h" -extern ErrorLog *server_log; extern LoginServer server; extern bool run_server; +#include "../common/eqemu_logsys.h" +extern EQEmuLogSys Log; + ClientManager::ClientManager() { int titanium_port = atoi(server.config->GetVariable("Titanium", "port").c_str()); @@ -30,18 +31,18 @@ ClientManager::ClientManager() titanium_ops = new RegularOpcodeManager; if(!titanium_ops->LoadOpcodes(server.config->GetVariable("Titanium", "opcodes").c_str())) { - server_log->Log(log_error, "ClientManager fatal error: couldn't load opcodes for Titanium file %s.", + Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't load opcodes for Titanium file %s.", server.config->GetVariable("Titanium", "opcodes").c_str()); run_server = false; } if(titanium_stream->Open()) { - server_log->Log(log_network, "ClientManager listening on Titanium stream."); + Log.Out(Logs::General, Logs::Login_Server, "ClientManager listening on Titanium stream."); } else { - server_log->Log(log_error, "ClientManager fatal error: couldn't open Titanium stream."); + Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't open Titanium stream."); run_server = false; } @@ -50,18 +51,18 @@ ClientManager::ClientManager() sod_ops = new RegularOpcodeManager; if(!sod_ops->LoadOpcodes(server.config->GetVariable("SoD", "opcodes").c_str())) { - server_log->Log(log_error, "ClientManager fatal error: couldn't load opcodes for SoD file %s.", + Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't load opcodes for SoD file %s.", server.config->GetVariable("SoD", "opcodes").c_str()); run_server = false; } if(sod_stream->Open()) { - server_log->Log(log_network, "ClientManager listening on SoD stream."); + Log.Out(Logs::General, Logs::Login_Server, "ClientManager listening on SoD stream."); } else { - server_log->Log(log_error, "ClientManager fatal error: couldn't open SoD stream."); + Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't open SoD stream."); run_server = false; } } @@ -99,7 +100,7 @@ void ClientManager::Process() { struct in_addr in; in.s_addr = cur->GetRemoteIP(); - server_log->Log(log_network, "New Titanium client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort())); + Log.Out(Logs::General, Logs::Login_Server, "New Titanium client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort())); cur->SetOpcodeManager(&titanium_ops); Client *c = new Client(cur, cv_titanium); @@ -112,7 +113,7 @@ void ClientManager::Process() { struct in_addr in; in.s_addr = cur->GetRemoteIP(); - server_log->Log(log_network, "New SoD client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort())); + Log.Out(Logs::General, Logs::Login_Server, "New SoD client connection from %s:%d", inet_ntoa(in), ntohs(cur->GetRemotePort())); cur->SetOpcodeManager(&sod_ops); Client *c = new Client(cur, cv_sod); @@ -125,7 +126,7 @@ void ClientManager::Process() { if((*iter)->Process() == false) { - server_log->Log(log_client, "Client had a fatal error and had to be removed from the login."); + Log.Out(Logs::General, Logs::Debug, "Client had a fatal error and had to be removed from the login."); delete (*iter); iter = clients.erase(iter); } @@ -144,7 +145,7 @@ void ClientManager::ProcessDisconnect() std::shared_ptr c = (*iter)->GetConnection(); if(c->CheckClosed()) { - server_log->Log(log_network, "Client disconnected from the server, removing client."); + Log.Out(Logs::General, Logs::Login_Server, "Client disconnected from the server, removing client."); delete (*iter); iter = clients.erase(iter); } @@ -172,7 +173,7 @@ void ClientManager::RemoveExistingClient(unsigned int account_id) { if((*iter)->GetAccountID() == account_id) { - server_log->Log(log_network, "Client attempting to log in and existing client already logged in, removing existing client."); + Log.Out(Logs::General, Logs::Login_Server, "Client attempting to log in and existing client already logged in, removing existing client."); delete (*iter); iter = clients.erase(iter); } @@ -200,7 +201,7 @@ Client *ClientManager::GetClient(unsigned int account_id) if(count > 1) { - server_log->Log(log_client_error, "More than one client with a given account_id existed in the client list."); + Log.Out(Logs::General, Logs::Error, "More than one client with a given account_id existed in the client list."); } return cur; } diff --git a/loginserver/config.cpp b/loginserver/config.cpp index 96a4c8568..ee17bdbed 100644 --- a/loginserver/config.cpp +++ b/loginserver/config.cpp @@ -16,10 +16,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" +#include "../common/eqemu_logsys.h" #include "config.h" -#include "error_log.h" -extern ErrorLog *server_log; +extern EQEmuLogSys Log; /** * Retrieves the variable we want from our title or theme * First gets the map from the title @@ -48,7 +48,7 @@ void Config::Parse(const char *file_name) { if(file_name == nullptr) { - server_log->Log(log_error, "Config::Parse(), file_name passed was null."); + Log.Out(Logs::General, Logs::Error, "Config::Parse(), file_name passed was null."); return; } @@ -71,7 +71,7 @@ void Config::Parse(const char *file_name) ++iter; if(iter == tokens.end()) { - server_log->Log(log_error, "Config::Parse(), EOF before title done parsing."); + Log.Out(Logs::General, Logs::Error, "Config::Parse(), EOF before title done parsing."); fclose(input); vars.clear(); return; @@ -104,7 +104,7 @@ void Config::Parse(const char *file_name) mode++; if((*iter).compare("=") != 0) { - server_log->Log(log_error, "Config::Parse(), invalid parse token where = should be."); + Log.Out(Logs::General, Logs::Error, "Config::Parse(), invalid parse token where = should be."); fclose(input); vars.clear(); return; @@ -133,7 +133,7 @@ void Config::Parse(const char *file_name) } else { - server_log->Log(log_error, "Config::Parse(), file was unable to be opened for parsing."); + Log.Out(Logs::General, Logs::Error, "Config::Parse(), file was unable to be opened for parsing."); } } diff --git a/loginserver/encryption.cpp b/loginserver/encryption.cpp index b00f5e88b..3c9ebd49f 100644 --- a/loginserver/encryption.cpp +++ b/loginserver/encryption.cpp @@ -17,16 +17,16 @@ */ #include "../common/global_define.h" #include "encryption.h" -#include "error_log.h" #include -extern ErrorLog *server_log; +#include "../common/eqemu_logsys.h" +extern EQEmuLogSys Log; bool Encryption::LoadCrypto(std::string name) { if(!Load(name.c_str())) { - server_log->Log(log_error, "Failed to load %s from the operating system.", name.c_str()); + Log.Out(Logs::General, Logs::Error, "Failed to load %s from the operating system.", name.c_str()); return false; } else @@ -34,21 +34,21 @@ bool Encryption::LoadCrypto(std::string name) encrypt_func = (DLLFUNC_Encrypt)GetSym("Encrypt"); if(encrypt_func == NULL) { - server_log->Log(log_error, "Failed to attach Encrypt."); + Log.Out(Logs::General, Logs::Error, "Failed to attach Encrypt."); Unload(); return false; } decrypt_func = (DLLFUNC_DecryptUsernamePassword)GetSym("DecryptUsernamePassword"); if(decrypt_func == NULL) { - server_log->Log(log_error, "Failed to attach DecryptUsernamePassword."); + Log.Out(Logs::General, Logs::Error, "Failed to attach DecryptUsernamePassword."); Unload(); return false; } delete_func = (DLLFUNC_HeapDelete)GetSym("_HeapDeleteCharBuffer"); if(delete_func == NULL) { - server_log->Log(log_error, "Failed to attach _HeapDeleteCharBuffer."); + Log.Out(Logs::General, Logs::Error, "Failed to attach _HeapDeleteCharBuffer."); Unload(); return false; } diff --git a/loginserver/main.cpp b/loginserver/main.cpp index 62973cd16..7d3abd87c 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -43,6 +43,7 @@ int main() { RegisterExecutablePlatform(ExePlatformLogin); set_exception_handler(); + Log.LoadLogSettingsDefaults(); /* Start Loginserver log */ time_t current_time = time(nullptr); @@ -53,11 +54,11 @@ int main() log_name << "./logs/login_" << (unsigned int)current_time << ".log"; #endif server_log = new ErrorLog(log_name.str().c_str()); - server_log->Log(log_debug, "Logging System Init."); + Log.Out(Logs::General, Logs::Login_Server, "Logging System Init."); /* Parse out login.ini */ server.config = new Config(); - server_log->Log(log_debug, "Config System Init."); + Log.Out(Logs::General, Logs::Login_Server, "Config System Init."); server.config->Parse("login.ini"); if (server.config->GetVariable("options", "unregistered_allowed").compare("FALSE") == 0) @@ -105,7 +106,7 @@ int main() /* Create database connection */ if (server.config->GetVariable("database", "subsystem").compare("MySQL") == 0) { #ifdef EQEMU_MYSQL_ENABLED - server_log->Log(log_debug, "MySQL Database Init."); + Log.Out(Logs::General, Logs::Login_Server, "MySQL Database Init."); server.db = (Database*)new DatabaseMySQL( server.config->GetVariable("database", "user"), server.config->GetVariable("database", "password"), @@ -116,7 +117,7 @@ int main() } else if (server.config->GetVariable("database", "subsystem").compare("PostgreSQL") == 0) { #ifdef EQEMU_POSTGRESQL_ENABLED - server_log->Log(log_debug, "PostgreSQL Database Init."); + Log.Out(Logs::General, Logs::Login_Server, "PostgreSQL Database Init."); server.db = (Database*)new DatabasePostgreSQL( server.config->GetVariable("database", "user"), server.config->GetVariable("database", "password"), @@ -128,74 +129,74 @@ int main() /* Make sure our database got created okay, otherwise cleanup and exit. */ if (!server.db) { - server_log->Log(log_error, "Database Initialization Failure."); - server_log->Log(log_debug, "Config System Shutdown."); + Log.Out(Logs::General, Logs::Error, "Database Initialization Failure."); + Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; - server_log->Log(log_debug, "Log System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Log System Shutdown."); delete server_log; return 1; } #if WIN32 //initialize our encryption. - server_log->Log(log_debug, "Encryption Initialize."); + Log.Out(Logs::General, Logs::Login_Server, "Encryption Initialize."); server.eq_crypto = new Encryption(); if (server.eq_crypto->LoadCrypto(server.config->GetVariable("security", "plugin"))) { - server_log->Log(log_debug, "Encryption Loaded Successfully."); + Log.Out(Logs::General, Logs::Login_Server, "Encryption Loaded Successfully."); } else { //We can't run without encryption, cleanup and exit. - server_log->Log(log_error, "Encryption Failed to Load."); - server_log->Log(log_debug, "Database System Shutdown."); + Log.Out(Logs::General, Logs::Error, "Encryption Failed to Load."); + Log.Out(Logs::General, Logs::Login_Server, "Database System Shutdown."); delete server.db; - server_log->Log(log_debug, "Config System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; - server_log->Log(log_debug, "Log System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Log System Shutdown."); delete server_log; return 1; } #endif //create our server manager. - server_log->Log(log_debug, "Server Manager Initialize."); + Log.Out(Logs::General, Logs::Login_Server, "Server Manager Initialize."); server.server_manager = new ServerManager(); if (!server.server_manager) { //We can't run without a server manager, cleanup and exit. - server_log->Log(log_error, "Server Manager Failed to Start."); + Log.Out(Logs::General, Logs::Error, "Server Manager Failed to Start."); #ifdef WIN32 - server_log->Log(log_debug, "Encryption System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Encryption System Shutdown."); delete server.eq_crypto; #endif - server_log->Log(log_debug, "Database System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Database System Shutdown."); delete server.db; - server_log->Log(log_debug, "Config System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; - server_log->Log(log_debug, "Log System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Log System Shutdown."); delete server_log; return 1; } //create our client manager. - server_log->Log(log_debug, "Client Manager Initialize."); + Log.Out(Logs::General, Logs::Login_Server, "Client Manager Initialize."); server.client_manager = new ClientManager(); if (!server.client_manager) { //We can't run without a client manager, cleanup and exit. - server_log->Log(log_error, "Client Manager Failed to Start."); - server_log->Log(log_debug, "Server Manager Shutdown."); + Log.Out(Logs::General, Logs::Error, "Client Manager Failed to Start."); + Log.Out(Logs::General, Logs::Login_Server, "Server Manager Shutdown."); delete server.server_manager; #ifdef WIN32 - server_log->Log(log_debug, "Encryption System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Encryption System Shutdown."); delete server.eq_crypto; #endif - server_log->Log(log_debug, "Database System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Database System Shutdown."); delete server.db; - server_log->Log(log_debug, "Config System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; - server_log->Log(log_debug, "Log System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Log System Shutdown."); delete server_log; return 1; } @@ -208,7 +209,7 @@ int main() #endif #endif - server_log->Log(log_debug, "Server Started."); + Log.Out(Logs::General, Logs::Login_Server, "Server Started."); while (run_server) { Timer::SetCurrentTime(); server.client_manager->Process(); @@ -216,22 +217,22 @@ int main() Sleep(100); } - server_log->Log(log_debug, "Server Shutdown."); - server_log->Log(log_debug, "Client Manager Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Server Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Client Manager Shutdown."); delete server.client_manager; - server_log->Log(log_debug, "Server Manager Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Server Manager Shutdown."); delete server.server_manager; #ifdef WIN32 - server_log->Log(log_debug, "Encryption System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Encryption System Shutdown."); delete server.eq_crypto; #endif - server_log->Log(log_debug, "Database System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Database System Shutdown."); delete server.db; - server_log->Log(log_debug, "Config System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; - server_log->Log(log_debug, "Log System Shutdown."); + Log.Out(Logs::General, Logs::Login_Server, "Log System Shutdown."); delete server_log; return 0; } diff --git a/loginserver/server_manager.cpp b/loginserver/server_manager.cpp index 3da497523..f63e72b4e 100644 --- a/loginserver/server_manager.cpp +++ b/loginserver/server_manager.cpp @@ -21,7 +21,9 @@ #include "login_structures.h" #include -extern ErrorLog *server_log; +#include "../common/eqemu_logsys.h" + +extern EQEmuLogSys Log; extern LoginServer server; extern bool run_server; @@ -32,10 +34,10 @@ ServerManager::ServerManager() int listen_port = atoi(server.config->GetVariable("options", "listen_port").c_str()); tcps = new EmuTCPServer(listen_port, true); if(tcps->Open(listen_port, error_buffer)) { - server_log->Log(log_network, "ServerManager listening on port %u", listen_port); + Log.Out(Logs::General, Logs::Login_Server, "ServerManager listening on port %u", listen_port); } else { - server_log->Log(log_error, "ServerManager fatal error opening port on %u: %s", listen_port, error_buffer); + Log.Out(Logs::General, Logs::Error, "ServerManager fatal error opening port on %u: %s", listen_port, error_buffer); run_server = false; } } @@ -55,11 +57,11 @@ void ServerManager::Process() while (tcp_c = tcps->NewQueuePop()) { in_addr tmp; tmp.s_addr = tcp_c->GetrIP(); - server_log->Log(log_network, "New world server connection from %s:%d", inet_ntoa(tmp), tcp_c->GetrPort()); + Log.Out(Logs::General, Logs::Login_Server, "New world server connection from %s:%d", inet_ntoa(tmp), tcp_c->GetrPort()); WorldServer *server_entity = GetServerByAddress(tcp_c->GetrIP()); if (server_entity) { - server_log->Log(log_network, "World server already existed for %s, removing existing connection and updating current.", inet_ntoa(tmp)); + Log.Out(Logs::General, Logs::Login_Server, "World server already existed for %s, removing existing connection and updating current.", inet_ntoa(tmp)); server_entity->GetConnection()->Free(); server_entity->SetConnection(tcp_c); server_entity->Reset(); @@ -73,7 +75,7 @@ void ServerManager::Process() list::iterator iter = world_servers.begin(); while (iter != world_servers.end()) { if ((*iter)->Process() == false) { - server_log->Log(log_world, "World server %s had a fatal error and had to be removed from the login.", (*iter)->GetLongName().c_str()); + Log.Out(Logs::General, Logs::World_Server, "World server %s had a fatal error and had to be removed from the login.", (*iter)->GetLongName().c_str()); delete (*iter); iter = world_servers.erase(iter); } @@ -91,7 +93,7 @@ void ServerManager::ProcessDisconnect() if (!connection->Connected()) { in_addr tmp; tmp.s_addr = connection->GetrIP(); - server_log->Log(log_network, "World server disconnected from the server, removing server and freeing connection."); + Log.Out(Logs::General, Logs::Login_Server, "World server disconnected from the server, removing server and freeing connection."); connection->Free(); delete (*iter); iter = world_servers.erase(iter); @@ -258,7 +260,7 @@ void ServerManager::SendUserToWorldRequest(unsigned int server_id, unsigned int } if (!found && server.options.IsTraceOn()) { - server_log->Log(log_client_error, "Client requested a user to world but supplied an invalid id of %u.", server_id); + Log.Out(Logs::General, Logs::Error, "Client requested a user to world but supplied an invalid id of %u.", server_id); } } diff --git a/loginserver/world_server.cpp b/loginserver/world_server.cpp index 64f7de02c..8e912e285 100644 --- a/loginserver/world_server.cpp +++ b/loginserver/world_server.cpp @@ -16,11 +16,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "world_server.h" -#include "error_log.h" #include "login_server.h" #include "login_structures.h" +#include "config.h" -extern ErrorLog *server_log; +#include "../common/eqemu_logsys.h" + +extern EQEmuLogSys Log; extern LoginServer server; WorldServer::WorldServer(EmuTCPConnection *c) @@ -63,7 +65,7 @@ bool WorldServer::Process() { if(server.options.IsWorldTraceOn()) { - server_log->Log(log_network_trace, "Application packet received from server: 0x%.4X, (size %u)", app->opcode, app->size); + Log.Out(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", app->opcode, app->size); } if(server.options.IsDumpInPacketsOn()) @@ -77,14 +79,14 @@ bool WorldServer::Process() { if(app->size < sizeof(ServerNewLSInfo_Struct)) { - server_log->Log(log_network_error, "Received application packet from server that had opcode ServerOP_NewLSInfo, " + Log.Out(Logs::General, Logs::Error, "Received application packet from server that had opcode ServerOP_NewLSInfo, " "but was too small. Discarded to avoid buffer overrun."); break; } if(server.options.IsWorldTraceOn()) { - server_log->Log(log_network_trace, "New Login Info Recieved."); + Log.Out(Logs::General, Logs::Netcode, "New Login Info Recieved."); } ServerNewLSInfo_Struct *info = (ServerNewLSInfo_Struct*)app->pBuffer; @@ -95,14 +97,14 @@ bool WorldServer::Process() { if(app->size < sizeof(ServerLSStatus_Struct)) { - server_log->Log(log_network_error, "Recieved application packet from server that had opcode ServerOP_LSStatus, " + Log.Out(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerOP_LSStatus, " "but was too small. Discarded to avoid buffer overrun."); break; } if(server.options.IsWorldTraceOn()) { - server_log->Log(log_network_trace, "World Server Status Recieved."); + Log.Out(Logs::General, Logs::Netcode, "World Server Status Recieved."); } ServerLSStatus_Struct *ls_status = (ServerLSStatus_Struct*)app->pBuffer; @@ -126,7 +128,7 @@ bool WorldServer::Process() { if(app->size < sizeof(UsertoWorldResponse_Struct)) { - server_log->Log(log_network_error, "Recieved application packet from server that had opcode ServerOP_UsertoWorldResp, " + Log.Out(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerOP_UsertoWorldResp, " "but was too small. Discarded to avoid buffer overrun."); break; } @@ -136,21 +138,22 @@ bool WorldServer::Process() //While keeping world server spam with multiple servers connected almost impossible. if(server.options.IsTraceOn()) { - server_log->Log(log_network_trace, "User-To-World Response received."); + Log.Out(Logs::General, Logs::Netcode, "User-To-World Response received."); } UsertoWorldResponse_Struct *utwr = (UsertoWorldResponse_Struct*)app->pBuffer; - server_log->Log(log_client, "Trying to find client with user id of %u.", utwr->lsaccountid); + Log.Out(Logs::General, Logs::Debug, "Trying to find client with user id of %u.", utwr->lsaccountid); Client *c = server.client_manager->GetClient(utwr->lsaccountid); if(c) { - server_log->Log(log_client, "Found client with user id of %u and account name of %s.", utwr->lsaccountid, c->GetAccountName().c_str()); + Log.Out(Logs::General, Logs::Debug, "Found client with user id of %u and account name of %s.", utwr->lsaccountid, c->GetAccountName().c_str()); EQApplicationPacket *outapp = new EQApplicationPacket(OP_PlayEverquestResponse, sizeof(PlayEverquestResponse_Struct)); PlayEverquestResponse_Struct *per = (PlayEverquestResponse_Struct*)outapp->pBuffer; per->Sequence = c->GetPlaySequence(); per->ServerNumber = c->GetPlayServerID(); - server_log->Log(log_client, "Found sequence and play of %u %u", c->GetPlaySequence(), c->GetPlayServerID()); - server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); + Log.Out(Logs::General, Logs::Debug, "Found sequence and play of %u %u", c->GetPlaySequence(), c->GetPlayServerID()); + + Log.Out(Logs::General, Logs::Netcode, "[Size: %u] %s", outapp->size, DumpPacketToString(outapp).c_str()); if(utwr->response > 0) { @@ -179,9 +182,9 @@ bool WorldServer::Process() if(server.options.IsTraceOn()) { - server_log->Log(log_network_trace, "Sending play response with following data, allowed %u, sequence %u, server number %u, message %u", + Log.Out(Logs::General, Logs::Netcode, "Sending play response with following data, allowed %u, sequence %u, server number %u, message %u", per->Allowed, per->Sequence, per->ServerNumber, per->Message); - server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); + Log.Out(Logs::General, Logs::Netcode, "[Size: %u] %s", outapp->size, DumpPacketToString(outapp).c_str()); } if(server.options.IsDumpOutPacketsOn()) @@ -194,7 +197,7 @@ bool WorldServer::Process() } else { - server_log->Log(log_client_error, "Recieved User-To-World Response for %u but could not find the client referenced!.", utwr->lsaccountid); + Log.Out(Logs::General, Logs::Error, "Recieved User-To-World Response for %u but could not find the client referenced!.", utwr->lsaccountid); } break; } @@ -202,16 +205,16 @@ bool WorldServer::Process() { if(app->size < sizeof(ServerLSAccountUpdate_Struct)) { - server_log->Log(log_network_error, "Recieved application packet from server that had opcode ServerLSAccountUpdate_Struct, " + Log.Out(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerLSAccountUpdate_Struct, " "but was too small. Discarded to avoid buffer overrun."); break; } - server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str()); + Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str()); ServerLSAccountUpdate_Struct *lsau = (ServerLSAccountUpdate_Struct*)app->pBuffer; if(is_server_trusted) { - server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate update processed for: %s", lsau->useraccount); + Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate update processed for: %s", lsau->useraccount); string name; string password; string email; @@ -224,7 +227,7 @@ bool WorldServer::Process() } default: { - server_log->Log(log_network_error, "Recieved application packet from server that had an unknown operation code 0x%.4X.", app->opcode); + Log.Out(Logs::General, Logs::Error, "Recieved application packet from server that had an unknown operation code 0x%.4X.", app->opcode); } } @@ -238,7 +241,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) { if(is_server_logged_in) { - server_log->Log(log_network_error, "WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting."); + Log.Out(Logs::General, Logs::Error, "WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting."); return; } @@ -248,7 +251,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_network_error, "Handle_NewLSInfo error, account name was too long."); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, account name was too long."); return; } @@ -258,7 +261,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_network_error, "Handle_NewLSInfo error, account password was too long."); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, account password was too long."); return; } @@ -268,7 +271,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_network_error, "Handle_NewLSInfo error, long name was too long."); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, long name was too long."); return; } @@ -278,7 +281,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_network_error, "Handle_NewLSInfo error, short name was too long."); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, short name was too long."); return; } @@ -286,7 +289,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) { if(strlen(i->local_address) == 0) { - server_log->Log(log_network_error, "Handle_NewLSInfo error, local address was null, defaulting to localhost"); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, local address was null, defaulting to localhost"); local_ip = "127.0.0.1"; } else @@ -296,7 +299,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_network_error, "Handle_NewLSInfo error, local address was too long."); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, local address was too long."); return; } @@ -307,7 +310,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) in_addr in; in.s_addr = GetConnection()->GetrIP(); remote_ip = inet_ntoa(in); - server_log->Log(log_network_error, "Handle_NewLSInfo error, remote address was null, defaulting to stream address %s.", remote_ip.c_str()); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, remote address was null, defaulting to stream address %s.", remote_ip.c_str()); } else { @@ -319,7 +322,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) in_addr in; in.s_addr = GetConnection()->GetrIP(); remote_ip = inet_ntoa(in); - server_log->Log(log_network_error, "Handle_NewLSInfo error, remote address was too long, defaulting to stream address %s.", remote_ip.c_str()); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, remote address was too long, defaulting to stream address %s.", remote_ip.c_str()); } if(strlen(i->serverversion) <= 64) @@ -328,7 +331,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_network_error, "Handle_NewLSInfo error, server version was too long."); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, server version was too long."); return; } @@ -338,7 +341,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_network_error, "Handle_NewLSInfo error, protocol version was too long."); + Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, protocol version was too long."); return; } @@ -349,7 +352,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) { if(server.server_manager->ServerExists(long_name, short_name, this)) { - server_log->Log(log_world_error, "World tried to login but there already exists a server that has that name."); + Log.Out(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name."); return; } } @@ -357,7 +360,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) { if(server.server_manager->ServerExists(long_name, short_name, this)) { - server_log->Log(log_world_error, "World tried to login but there already exists a server that has that name."); + Log.Out(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name."); server.server_manager->DestroyServerByName(long_name, short_name, this); } } @@ -377,7 +380,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) { if(s_acct_name.size() == 0 || s_acct_pass.size() == 0) { - server_log->Log(log_world, "Server %s(%s) successfully logged into account that had no user/password requirement.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged into account that had no user/password requirement.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(s_id); @@ -386,33 +389,33 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else if(s_acct_name.compare(account_name) == 0 && s_acct_pass.compare(account_password) == 0) { - server_log->Log(log_world, "Server %s(%s) successfully logged in.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(s_id); server_list_id = s_list_type; desc = s_desc; if(s_trusted) { - server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate sent to world"); + Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world"); is_server_trusted = true; ServerPacket *outapp = new ServerPacket(ServerOP_LSAccountUpdate, 0); connection->SendPacket(outapp); } } else { - server_log->Log(log_world, "Server %s(%s) attempted to log in but account and password did not match the entry in the database, and only" + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database, and only" " registered servers are allowed.", long_name.c_str(), short_name.c_str()); return; } } else { - server_log->Log(log_world, "Server %s(%s) attempted to log in but database couldn't find an entry and only registered servers are allowed.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry and only registered servers are allowed.", long_name.c_str(), short_name.c_str()); return; } } else { - server_log->Log(log_world, "Server %s(%s) did not attempt to log in but only registered servers are allowed.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but only registered servers are allowed.", long_name.c_str(), short_name.c_str()); return; } @@ -441,7 +444,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) if(account_name.size() > 0 && account_password.size() > 0) { if(server_account_name.compare(account_name) == 0 && server_account_password.compare(account_password) == 0) { - server_log->Log(log_world, "Server %s(%s) successfully logged in.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(server_id); @@ -449,7 +452,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) desc = server_description; if(is_server_trusted) { - server_log->Log(log_network_trace, "ServerOP_LSAccountUpdate sent to world"); + Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world"); is_server_trusted = true; ServerPacket *outapp = new ServerPacket(ServerOP_LSAccountUpdate, 0); connection->SendPacket(outapp); @@ -457,18 +460,18 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { // this is the first of two cases where we should deny access even if unregistered is allowed - server_log->Log(log_world, "Server %s(%s) attempted to log in but account and password did not match the entry in the database.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database.", long_name.c_str(), short_name.c_str()); } } else { if(server_account_name.size() > 0 || server_account_password.size() > 0) { // this is the second of two cases where we should deny access even if unregistered is allowed - server_log->Log(log_world, "Server %s(%s) did not attempt to log in but this server requires a password.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but this server requires a password.", long_name.c_str(), short_name.c_str()); } else { - server_log->Log(log_world, "Server %s(%s) did not attempt to log in but unregistered servers are allowed.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but unregistered servers are allowed.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(server_id); @@ -478,7 +481,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - server_log->Log(log_world, "Server %s(%s) attempted to log in but database couldn't find an entry but unregistered servers are allowed.", + Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry but unregistered servers are allowed.", long_name.c_str(), short_name.c_str()); if(server.db->CreateWorldRegistration(long_name, short_name, server_id)) { is_server_authorized = true;