diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index c5776bf15..8c1f619f1 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -133,6 +133,17 @@ void EQEmuLogSys::LoadLogSettingsDefaults() log_settings[Logs::Headless_Client].log_to_console = Logs::General; log_settings[Logs::NPCScaling].log_to_gmsay = Logs::General; + /** + * RFC 5424 + */ + log_settings[Logs::Emergency].log_to_console = Logs::General; + log_settings[Logs::Alert].log_to_console = Logs::General; + log_settings[Logs::Critical].log_to_console = Logs::General; + log_settings[Logs::Error].log_to_console = Logs::General; + log_settings[Logs::Warning].log_to_console = Logs::General; + log_settings[Logs::Notice].log_to_console = Logs::General; + log_settings[Logs::Info].log_to_console = Logs::General; + /** * Set Category enabled status on defaults */ @@ -172,6 +183,24 @@ void EQEmuLogSys::LoadLogSettingsDefaults() } } +/** + * @param log_category + * @return + */ +bool EQEmuLogSys::IsRfc5424LogCategory(uint16 log_category) +{ + return ( + log_category == Logs::Emergency || + log_category == Logs::Alert || + log_category == Logs::Critical || + log_category == Logs::Error || + log_category == Logs::Warning || + log_category == Logs::Notice || + log_category == Logs::Info || + log_category == Logs::Debug + ); +} + /** * @param log_category * @param in_message @@ -182,13 +211,13 @@ std::string EQEmuLogSys::FormatOutMessageString( const std::string &in_message ) { - std::string ret; - ret.push_back('['); - ret.append(Logs::LogCategoryName[log_category]); - ret.push_back(']'); - ret.push_back(' '); - ret.append(in_message); - return ret; + std::string return_string; + + if (IsRfc5424LogCategory(log_category)) { + return_string = "[" + GetPlatformName() + "] "; + } + + return return_string + "[" + Logs::LogCategoryName[log_category] + "] " + in_message; } /** @@ -390,7 +419,7 @@ constexpr const char *r_slant(const char *str) * @param str * @return */ -constexpr const char *file_name(const char *str) +constexpr const char *base_file_name(const char *str) { return str_slant(str) ? r_slant(str_end(str)) : str; } @@ -436,7 +465,7 @@ void EQEmuLogSys::Out( std::string prefix; if (RuleB(Logging, PrintFileFunctionAndLine)) { - prefix = fmt::format("[{0}::{1}:{2}] ", file_name(file), func, line); + prefix = fmt::format("[{0}::{1}:{2}] ", base_file_name(file), func, line); } va_list args; diff --git a/common/eqemu_logsys.h b/common/eqemu_logsys.h index ed5088fec..4626b0399 100644 --- a/common/eqemu_logsys.h +++ b/common/eqemu_logsys.h @@ -94,6 +94,12 @@ namespace Logs { NPCRoamBox, NPCScaling, MobAppearance, + Info, + Warning, + Critical, + Emergency, + Alert, + Notice, MaxCategoryID /* Don't Remove this */ }; @@ -153,15 +159,74 @@ namespace Logs { "Traps", "NPC Roam Box", "NPC Scaling", - "Mob Appearance" + "Mob Appearance", + "Info", + "Warning", + "Critical", + "Emergency", + "Alert", + "Notice" }; } -#define Error(message, ...) do {\ +/** + * RFC 5424 + */ + +#define LogEmergency(message, ...) do {\ + if (LogSys.log_settings[Logs::Emergency].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Emergency, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + +#define LogAlert(message, ...) do {\ + if (LogSys.log_settings[Logs::Alert].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Alert, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + +#define LogCritical(message, ...) do {\ + if (LogSys.log_settings[Logs::Critical].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Critical, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + +#define LogError(message, ...) do {\ if (LogSys.log_settings[Logs::Error].is_category_enabled == 1)\ OutF(LogSys, Logs::General, Logs::Error, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) + +#define LogWarning(message, ...) do {\ + if (LogSys.log_settings[Logs::Warning].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + +#define LogNotice(message, ...) do {\ + if (LogSys.log_settings[Logs::Notice].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Notice, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + +#define LogInfo(message, ...) do {\ + if (LogSys.log_settings[Logs::Info].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + +#define LogDebug(message, ...) do {\ + if (LogSys.log_settings[Logs::Debug].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Debug, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + + + + + +/** + * Other + */ + +#define LogStatus(message, ...) do {\ + if (LogSys.log_settings[Logs::Status].is_category_enabled == 1)\ + OutF(LogSys, Logs::General, Logs::Status, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ +} while (0) + #define Log(debug_level, log_category, message, ...) do {\ if (LogSys.log_settings[log_category].is_category_enabled == 1)\ LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ @@ -172,15 +237,6 @@ namespace Logs { OutF(LogSys, debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) -#define LogLoginserver(message, ...) do {\ - if (LogSys.log_settings[Logs::Login_Server].is_category_enabled == 1)\ - OutF(LogSys, Logs::General, Logs::Login_Server, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) - -#define LogLoginserverDetail(message, ...) do {\ - if (LogSys.log_settings[Logs::Login_Server].is_category_enabled == 1)\ - OutF(LogSys, Logs::Detail, Logs::Login_Server, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ -} while (0) class EQEmuLogSys { public: @@ -329,6 +385,12 @@ private: * @param message */ void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message); + + /** + * @param log_category + * @return + */ + bool IsRfc5424LogCategory(uint16 log_category); }; extern EQEmuLogSys LogSys; diff --git a/common/eqemu_logsys_fmt.h b/common/eqemu_logsys_fmt.h deleted file mode 100644 index 2874d5766..000000000 --- a/common/eqemu_logsys_fmt.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * -*/ - -#pragma once - -#include - -template -void OutF( - EQEmuLogSys &ls, - Logs::DebugLevel debug_level, - uint16 log_category, - const char *file, - const char *func, - int line, - const char *fmt, - const Args &... args -) -{ - std::string log_str = fmt::format(fmt, args...); - ls.Out(debug_level, log_category, file, func, line, log_str); -} \ No newline at end of file diff --git a/common/platform.cpp b/common/platform.cpp index 4955d6639..b67267155 100644 --- a/common/platform.cpp +++ b/common/platform.cpp @@ -1,3 +1,23 @@ +/** + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + #include "platform.h" EQEmuExePlatform exe_platform = ExePlatformNone; @@ -10,6 +30,44 @@ const EQEmuExePlatform& GetExecutablePlatform() { return exe_platform; } +/** + * @return + */ int GetExecutablePlatformInt(){ return exe_platform; +} + +/** + * Returns platform name by string + * + * @return + */ +std::string GetPlatformName() +{ + switch (GetExecutablePlatformInt()) { + case EQEmuExePlatform::ExePlatformWorld: + return "WorldServer"; + case EQEmuExePlatform::ExePlatformQueryServ: + return "QueryServer"; + case EQEmuExePlatform::ExePlatformZone: + return "ZoneServer"; + case EQEmuExePlatform::ExePlatformUCS: + return "UCS"; + case EQEmuExePlatform::ExePlatformLogin: + return "LoginServer"; + case EQEmuExePlatform::ExePlatformSocket_Server: + return "SocketServer"; + case EQEmuExePlatform::ExePlatformSharedMemory: + return "SharedMemory"; + case EQEmuExePlatform::ExePlatformClientImport: + return "ClientImport"; + case EQEmuExePlatform::ExePlatformClientExport: + return "ClientExport"; + case EQEmuExePlatform::ExePlatformLaunch: + return "Launch"; + case EQEmuExePlatform::ExePlatformHC: + return "HC"; + default: + return ""; + } } \ No newline at end of file diff --git a/common/platform.h b/common/platform.h index 8eb765257..bd24a1493 100644 --- a/common/platform.h +++ b/common/platform.h @@ -1,6 +1,28 @@ +/** + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2019 EQEmulator Development Team (https://github.com/EQEmu/Server) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + #ifndef EQEMU_PLATFORM_H #define EQEMU_PLATFORM_H +#include "iostream" + enum EQEmuExePlatform { ExePlatformNone = 0, @@ -20,5 +42,6 @@ enum EQEmuExePlatform void RegisterExecutablePlatform(EQEmuExePlatform p); const EQEmuExePlatform& GetExecutablePlatform(); int GetExecutablePlatformInt(); +std::string GetPlatformName(); #endif diff --git a/loginserver/client.cpp b/loginserver/client.cpp index b08c47a27..41e6c16dc 100644 --- a/loginserver/client.cpp +++ b/loginserver/client.cpp @@ -62,19 +62,19 @@ bool Client::Process() switch (app->GetOpcode()) { case OP_SessionReady: { if (server.options.IsTraceOn()) { - LogLoginserver("Session ready received from client."); + LogInfo("Session ready received from client."); } Handle_SessionReady((const char *) app->pBuffer, app->Size()); break; } case OP_Login: { if (app->Size() < 20) { - Error("Login received but it is too small, discarding."); + LogError("Login received but it is too small, discarding."); break; } if (server.options.IsTraceOn()) { - LogLoginserver("Login received from client."); + LogInfo("Login received from client."); } Handle_Login((const char *) app->pBuffer, app->Size()); @@ -82,12 +82,12 @@ bool Client::Process() } case OP_ServerListRequest: { if (app->Size() < 4) { - Error("Server List Request received but it is too small, discarding."); + LogError("Server List Request received but it is too small, discarding."); break; } if (server.options.IsTraceOn()) { - LogLoginserver("Server list request received from client."); + LogInfo("Server list request received from client."); } SendServerListPacket(*(uint32_t *) app->pBuffer); @@ -95,7 +95,7 @@ bool Client::Process() } case OP_PlayEverquestRequest: { if (app->Size() < sizeof(PlayEverquestRequest_Struct)) { - Error("Play received but it is too small, discarding."); + LogError("Play received but it is too small, discarding."); break; } @@ -106,7 +106,7 @@ bool Client::Process() if (LogSys.log_settings[Logs::Client_Server_Packet_Unhandled].is_category_enabled == 1) { char dump[64]; app->build_header_dump(dump); - Error("Recieved unhandled application packet from the client: %s.", dump); + LogError("Recieved unhandled application packet from the client: %s.", dump); } } } @@ -127,12 +127,12 @@ bool Client::Process() void Client::Handle_SessionReady(const char *data, unsigned int size) { if (status != cs_not_sent_session_ready) { - Error("Session ready received again after already being received."); + LogError("Session ready received again after already being received."); return; } if (size < sizeof(unsigned int)) { - Error("Session ready was too small."); + LogError("Session ready was too small."); return; } @@ -180,18 +180,18 @@ void Client::Handle_SessionReady(const char *data, unsigned int size) void Client::Handle_Login(const char *data, unsigned int size) { if (status != cs_waiting_for_login) { - Error("Login received after already having logged in"); + LogError("Login received after already having logged in"); return; } if ((size - 12) % 8 != 0) { - Error("Login received packet of size: {0}, this would cause a block corruption, discarding", size); + LogError("Login received packet of size: {0}, this would cause a block corruption, discarding", size); return; } if (size < sizeof(LoginLoginRequest_Struct)) { - Error("Login received packet of size: {0}, this would cause a buffer overflow, discarding", size); + LogError("Login received packet of size: {0}, this would cause a buffer overflow, discarding", size); return; } @@ -205,13 +205,13 @@ void Client::Handle_Login(const char *data, unsigned int size) std::string outbuffer; outbuffer.resize(size - 12); if (outbuffer.length() == 0) { - Error("Corrupt buffer sent to server, no length."); + LogError("Corrupt buffer sent to server, no length."); return; } auto r = eqcrypt_block(data + 10, size - 12, &outbuffer[0], 0); if (r == nullptr) { - Error("Failed to decrypt eqcrypt block"); + LogError("Failed to decrypt eqcrypt block"); return; } @@ -219,7 +219,7 @@ void Client::Handle_Login(const char *data, unsigned int size) std::string user(&outbuffer[0]); if (user.length() >= outbuffer.length()) { - Error("Corrupt buffer sent to server, preventing buffer overflow."); + LogError("Corrupt buffer sent to server, preventing buffer overflow."); return; } @@ -247,7 +247,7 @@ void Client::Handle_Login(const char *data, unsigned int size) user = components[1]; } - LogLoginserver( + LogInfo( "Attempting password based login [{0}] login [{1}] user [{2}]", user, db_loginserver, @@ -259,7 +259,7 @@ void Client::Handle_Login(const char *data, unsigned int size) if (server.db->GetLoginDataFromAccountInfo(user, db_loginserver, db_account_password_hash, db_account_id)) { result = VerifyLoginHash(user, db_loginserver, cred, db_account_password_hash); - LogLoginserverDetail("[VerifyLoginHash] Success [{0}]", (result ? "true" : "false")); + LogDebug("[VerifyLoginHash] Success [{0}]", (result ? "true" : "false")); } else { status = cs_creating_account; @@ -274,7 +274,7 @@ void Client::Handle_Login(const char *data, unsigned int size) * Login accepted */ if (result) { - LogLoginserverDetail( + LogDebug( "login [{0}] user [{1}] Login succeeded", db_loginserver, user @@ -283,7 +283,7 @@ void Client::Handle_Login(const char *data, unsigned int size) DoSuccessfulLogin(user, db_account_id, db_loginserver); } else { - LogLoginserverDetail( + LogDebug( "login [{0}] user [{1}] Login failed", db_loginserver, user @@ -301,7 +301,7 @@ void Client::Handle_Login(const char *data, unsigned int size) void Client::Handle_Play(const char *data) { if (status != cs_logged_in) { - Error("Client sent a play request when they were not logged in, discarding."); + LogError("Client sent a play request when they were not logged in, discarding."); return; } @@ -310,7 +310,7 @@ void Client::Handle_Play(const char *data) auto sequence_in = (unsigned int) play->Sequence; if (server.options.IsTraceOn()) { - LogLoginserver("Play received from client, server number {0} sequence {1}", server_id_in, sequence_in); + LogInfo("Play received from client, server number {0} sequence {1}", server_id_in, sequence_in); } this->play_server_id = (unsigned int) play->ServerNumber; @@ -375,10 +375,10 @@ void Client::AttemptLoginAccountCreation( { if (loginserver == "eqemu") { - LogLoginserver("Attempting login account creation via '{0}'", loginserver); + LogInfo("Attempting login account creation via '{0}'", loginserver); if (!server.options.CanAutoLinkAccounts()) { - LogLoginserver("CanAutoLinkAccounts disabled - sending failed login"); + LogInfo("CanAutoLinkAccounts disabled - sending failed login"); DoFailedLogin(); return; } @@ -500,7 +500,7 @@ bool Client::VerifyLoginHash( if (hash.length() == 32) { //md5 is insecure for (int i = EncryptionModeMD5; i <= EncryptionModeMD5Triple; ++i) { if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) { - LogLoginserverDetail( + LogDebug( "user [{0}] loginserver [{1}] mode [{2}]", user, loginserver, @@ -514,7 +514,7 @@ bool Client::VerifyLoginHash( else if (hash.length() == 40) { //sha1 is insecure for (int i = EncryptionModeSHA; i <= EncryptionModeSHATriple; ++i) { if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) { - LogLoginserverDetail( + LogDebug( "user [{0}] loginserver [{1}] mode [{2}]", user, loginserver, @@ -529,7 +529,7 @@ bool Client::VerifyLoginHash( else if (hash.length() == 128) { //sha2-512 is insecure for (int i = EncryptionModeSHA512; i <= EncryptionModeSHA512Triple; ++i) { if (i != mode && eqcrypt_verify_hash(user, cred, hash, i)) { - LogLoginserverDetail( + LogDebug( "user [{0}] loginserver [{1}] mode [{2}]", user, loginserver, @@ -605,7 +605,7 @@ void Client::DoSuccessfulLogin(const std::string &user, int db_account_id, const char encrypted_buffer[80] = {0}; auto rc = eqcrypt_block((const char *) login_failed_attempts, 75, encrypted_buffer, 1); if (rc == nullptr) { - LogLoginserverDetail("Failed to encrypt eqcrypt block"); + LogDebug("Failed to encrypt eqcrypt block"); } memcpy(login_accepted->encrypt, encrypted_buffer, 80); @@ -682,12 +682,12 @@ void Client::LoginOnStatusChange( ) { if (to == EQ::Net::StatusConnected) { - LogLoginserverDetail("EQ::Net::StatusConnected"); + LogDebug("EQ::Net::StatusConnected"); LoginSendSessionReady(); } if (to == EQ::Net::StatusDisconnecting || to == EQ::Net::StatusDisconnected) { - LogLoginserverDetail("EQ::Net::StatusDisconnecting || EQ::Net::StatusDisconnected"); + LogDebug("EQ::Net::StatusDisconnecting || EQ::Net::StatusDisconnected"); DoFailedLogin(); } @@ -785,12 +785,12 @@ void Client::LoginProcessLoginResponse(const EQ::Net::Packet &p) ); if (response_error > 101) { - LogLoginserverDetail("response [{0}] failed login", response_error); + LogDebug("response [{0}] failed login", response_error); DoFailedLogin(); login_connection->Close(); } else { - LogLoginserverDetail( + LogDebug( "response [{0}] login succeeded user [{1}]", response_error, stored_user diff --git a/loginserver/client_manager.cpp b/loginserver/client_manager.cpp index 1c610c562..0967f2a63 100644 --- a/loginserver/client_manager.cpp +++ b/loginserver/client_manager.cpp @@ -41,7 +41,7 @@ ClientManager::ClientManager() "login_opcodes.conf" ).c_str())) { - Error( + LogError( "ClientManager fatal error: couldn't load opcodes for Titanium file [{0}]", server.config.GetVariableString("Titanium", "opcodes", "login_opcodes.conf") ); @@ -51,7 +51,7 @@ ClientManager::ClientManager() titanium_stream->OnNewConnection( [this](std::shared_ptr stream) { - LogLoginserver( + LogInfo( "New Titanium client connection from {0}:{1}", stream->GetRemoteIP(), stream->GetRemotePort() @@ -69,7 +69,7 @@ ClientManager::ClientManager() sod_stream = new EQ::Net::EQStreamManager(sod_opts); sod_ops = new RegularOpcodeManager; if (!sod_ops->LoadOpcodes(server.config.GetVariableString("SoD", "opcodes", "login_opcodes.conf").c_str())) { - Error( + LogError( "ClientManager fatal error: couldn't load opcodes for SoD file {0}", server.config.GetVariableString("SoD", "opcodes", "login_opcodes.conf").c_str() ); @@ -79,7 +79,7 @@ ClientManager::ClientManager() sod_stream->OnNewConnection( [this](std::shared_ptr stream) { - LogLoginserver( + LogInfo( "New SoD client connection from {0}:{1}", stream->GetRemoteIP(), stream->GetRemotePort() @@ -134,7 +134,7 @@ void ClientManager::ProcessDisconnect() while (iter != clients.end()) { std::shared_ptr c = (*iter)->GetConnection(); if (c->CheckState(CLOSED)) { - LogLoginserver("Client disconnected from the server, removing client."); + LogInfo("Client disconnected from the server, removing client."); delete (*iter); iter = clients.erase(iter); } @@ -153,7 +153,7 @@ void ClientManager::RemoveExistingClient(unsigned int account_id, const std::str auto iter = clients.begin(); while (iter != clients.end()) { if ((*iter)->GetAccountID() == account_id && (*iter)->GetLoginServerName().compare(loginserver) == 0) { - LogLoginserver("Client attempting to log in existing client already logged in, removing existing client"); + LogInfo("Client attempting to log in existing client already logged in, removing existing client"); delete (*iter); iter = clients.erase(iter); } diff --git a/loginserver/config.cpp b/loginserver/config.cpp index 59b0f2ee5..88daab757 100644 --- a/loginserver/config.cpp +++ b/loginserver/config.cpp @@ -52,7 +52,7 @@ std::string Config::GetVariable(std::string title, std::string parameter) void Config::Parse(const char *file_name) { if (file_name == nullptr) { - Error("Config::Parse(), file_name passed was null"); + LogError("Config::Parse(), file_name passed was null"); return; } @@ -72,7 +72,7 @@ void Config::Parse(const char *file_name) bool first = true; ++iter; if (iter == tokens.end()) { - Error("Config::Parse(), EOF before title done parsing"); + LogError("Config::Parse(), EOF before title done parsing"); fclose(input); vars.clear(); return; @@ -99,7 +99,7 @@ void Config::Parse(const char *file_name) else if (mode == 1) { mode++; if ((*iter).compare("=") != 0) { - Error("Config::Parse(), invalid parse token where = should be"); + LogError("Config::Parse(), invalid parse token where = should be"); fclose(input); vars.clear(); return; @@ -124,7 +124,7 @@ void Config::Parse(const char *file_name) fclose(input); } else { - Error("Config::Parse(), file was unable to be opened for parsing"); + LogError("Config::Parse(), file was unable to be opened for parsing"); } } diff --git a/loginserver/database.cpp b/loginserver/database.cpp index 4336d7656..0a873be3f 100644 --- a/loginserver/database.cpp +++ b/loginserver/database.cpp @@ -103,7 +103,7 @@ bool Database::GetLoginDataFromAccountInfo( auto results = QueryDatabase(query); if (results.RowCount() != 1) { - LogLoginserverDetail( + LogDebug( "Could not find account for name [{0}] login [{1}]", name, loginserver @@ -121,7 +121,7 @@ bool Database::GetLoginDataFromAccountInfo( id = atoi(row[0]); password = row[1]; - LogLoginserverDetail( + LogDebug( "Found account for name [{0}] login [{1}]", name, loginserver @@ -301,7 +301,7 @@ void Database::UpdateLoginHash( const std::string &hash ) { - LogLoginserverDetail( + LogDebug( "name [{0}] loginserver [{1}] hash [{2}]", name, loginserver, diff --git a/loginserver/main.cpp b/loginserver/main.cpp index b95e51649..223df4197 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -47,10 +47,10 @@ int main() LogSys.LoadLogSettingsDefaults(); - LogLoginserver("Logging System Init"); + LogInfo("Logging System Init"); server.config = EQ::JsonConfigFile::Load("login.json"); - LogLoginserver("Config System Init"); + LogInfo("Config System Init"); server.options.Trace(server.config.GetVariableBool("general", "trace", false)); server.options.WorldTrace(server.config.GetVariableBool("general", "world_trace", false)); @@ -119,7 +119,7 @@ int main() /** * mysql connect */ - LogLoginserver("MySQL Database Init"); + LogInfo("MySQL Database Init"); server.db = new Database( server.config.GetVariableString("database", "user", "root"), @@ -135,19 +135,19 @@ int main() * make sure our database got created okay, otherwise cleanup and exit */ if (!server.db) { - Error("Database Initialization Failure"); - LogLoginserver("Log System Shutdown"); + LogError("Database Initialization Failure"); + LogInfo("Log System Shutdown"); return 1; } /** * create server manager */ - LogLoginserver("Server Manager Init"); + LogInfo("Server Manager Init"); server.server_manager = new ServerManager(); if (!server.server_manager) { - Error("Server Manager Failed to Start"); - LogLoginserver("Database System Shutdown"); + LogError("Server Manager Failed to Start"); + LogInfo("Database System Shutdown"); delete server.db; return 1; } @@ -155,14 +155,14 @@ int main() /** * create client manager */ - LogLoginserver("Client Manager Init"); + LogInfo("Client Manager Init"); server.client_manager = new ClientManager(); if (!server.client_manager) { - Error("Client Manager Failed to Start"); - LogLoginserver("Server Manager Shutdown"); + LogError("Client Manager Failed to Start"); + LogInfo("Server Manager Shutdown"); delete server.server_manager; - LogLoginserver("Database System Shutdown"); + LogInfo("Database System Shutdown"); delete server.db; return 1; } @@ -175,10 +175,10 @@ int main() #endif #endif - LogLoginserver("Server Started"); + LogInfo("Server Started"); if (LogSys.log_settings[Logs::Login_Server].log_to_console == 1) { - LogLoginserver("Loginserver logging set to level [1] for more debugging, enable detail [3]"); + LogInfo("Loginserver logging set to level [1] for more debugging, enable detail [3]"); } while (run_server) { @@ -188,13 +188,13 @@ int main() Sleep(50); } - LogLoginserver("Server Shutdown"); - LogLoginserver("Client Manager Shutdown"); + LogInfo("Server Shutdown"); + LogInfo("Client Manager Shutdown"); delete server.client_manager; - LogLoginserver("Server Manager Shutdown"); + LogInfo("Server Manager Shutdown"); delete server.server_manager; - LogLoginserver("Database System Shutdown"); + LogInfo("Database System Shutdown"); delete server.db; return 0; } diff --git a/loginserver/server_manager.cpp b/loginserver/server_manager.cpp index 44b323342..711104597 100644 --- a/loginserver/server_manager.cpp +++ b/loginserver/server_manager.cpp @@ -39,11 +39,11 @@ ServerManager::ServerManager() opts.ipv6 = false; server_connection->Listen(opts); - LogLoginserver("Loginserver now listening on port [{0}]", listen_port); + LogInfo("Loginserver now listening on port [{0}]", listen_port); server_connection->OnConnectionIdentified( "World", [this](std::shared_ptr world_connection) { - LogLoginserver( + LogInfo( "New world server connection from {0}:{1}", world_connection->Handle()->RemoteIP(), world_connection->Handle()->RemotePort() @@ -55,7 +55,7 @@ ServerManager::ServerManager() 0 && (*iter)->GetConnection()->Handle()->RemotePort() == world_connection->Handle()->RemotePort()) { - LogLoginserver( + LogInfo( "World server already existed for {0}:{1}, removing existing connection.", world_connection->Handle()->RemoteIP(), world_connection->Handle()->RemotePort() @@ -138,7 +138,7 @@ EQApplicationPacket *ServerManager::CreateServerListPacket(Client *client, uint3 packet_size += (*iter)->GetLongName().size() + (*iter)->GetLocalIP().size() + 24; } else if (IpUtil::IsIpInPrivateRfc1918(client_ip)) { - LogLoginserver("Client is requesting server list from a local address [{0}]", client_ip); + LogInfo("Client is requesting server list from a local address [{0}]", client_ip); packet_size += (*iter)->GetLongName().size() + (*iter)->GetLocalIP().size() + 24; } else { @@ -264,14 +264,14 @@ void ServerManager::SendUserToWorldRequest( found = true; if (server.options.IsDumpInPacketsOn()) { - LogLoginserver("{0}", outapp.ToString()); + LogInfo("{0}", outapp.ToString()); } } ++iter; } if (!found && server.options.IsTraceOn()) { - Error("Client requested a user to world but supplied an invalid id of {0}", server_id); + LogError("Client requested a user to world but supplied an invalid id of {0}", server_id); } } diff --git a/loginserver/world_server.cpp b/loginserver/world_server.cpp index fe4fff693..74ae10a59 100644 --- a/loginserver/world_server.cpp +++ b/loginserver/world_server.cpp @@ -107,7 +107,7 @@ void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &packe } if (packet.Length() < sizeof(ServerNewLSInfo_Struct)) { - Error( + LogError( "Received application packet from server that had opcode ServerOP_NewLSInfo, " "but was too small. Discarded to avoid buffer overrun" ); @@ -118,7 +118,7 @@ void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &packe auto *info = (ServerNewLSInfo_Struct *) packet.Data(); - LogLoginserver( + LogInfo( "Received New Login Server Info \n" " - name [{0}]\n" " - shortname [{1}]\n" @@ -162,7 +162,7 @@ void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &packet } if (packet.Length() < sizeof(ServerLSStatus_Struct)) { - Error( + LogError( "Received application packet from server that had opcode ServerOP_LSStatus, but was too small. Discarded to avoid buffer overrun" ); @@ -171,7 +171,7 @@ void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &packet auto *ls_status = (ServerLSStatus_Struct *) packet.Data(); - LogLoginserverDetail( + LogDebug( "World Server Status Update Received | Server [{0}] Status [{1}] Players [{2}] Zones [{3}]", this->GetLongName(), ls_status->status, @@ -201,7 +201,7 @@ void WorldServer::ProcessUsertoWorldRespLeg(uint16_t opcode, const EQ::Net::Pack } if (packet.Length() < sizeof(UsertoWorldResponseLegacy_Struct)) { - Error( + LogError( "Received application packet from server that had opcode ServerOP_UsertoWorldResp, " "but was too small. Discarded to avoid buffer overrun" ); @@ -284,7 +284,7 @@ void WorldServer::ProcessUsertoWorldRespLeg(uint16_t opcode, const EQ::Net::Pack delete outapp; } else { - Error( + LogError( "Received User-To-World Response for {0} but could not find the client referenced!", user_to_world_response->lsaccountid ); @@ -403,7 +403,7 @@ void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Pac delete outapp; } else { - Error("Received User-To-World Response for {0} but could not find the client referenced!.", + LogError("Received User-To-World Response for {0} but could not find the client referenced!.", user_to_world_response->lsaccountid); } } @@ -427,7 +427,7 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet } if (packet.Length() < sizeof(ServerLSAccountUpdate_Struct)) { - Error( + LogError( "Received application packet from server that had opcode ServerLSAccountUpdate_Struct, " "but was too small. Discarded to avoid buffer overrun" ); @@ -464,7 +464,7 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info_packet) { if (is_server_logged_in) { - Error("WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting."); + LogError("WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting."); return; } @@ -472,7 +472,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info account_name = new_world_server_info_packet->account; } else { - Error("Handle_NewLSInfo error, account name was too long."); + LogError("Handle_NewLSInfo error, account name was too long."); return; } @@ -480,7 +480,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info account_password = new_world_server_info_packet->password; } else { - Error("Handle_NewLSInfo error, account password was too long."); + LogError("Handle_NewLSInfo error, account password was too long."); return; } @@ -488,7 +488,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info long_name = new_world_server_info_packet->name; } else { - Error("Handle_NewLSInfo error, long name was too long."); + LogError("Handle_NewLSInfo error, long name was too long."); return; } @@ -496,13 +496,13 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info short_name = new_world_server_info_packet->shortname; } else { - Error("Handle_NewLSInfo error, short name was too long."); + LogError("Handle_NewLSInfo error, short name was too long."); return; } if (strlen(new_world_server_info_packet->local_address) <= 125) { if (strlen(new_world_server_info_packet->local_address) == 0) { - Error("Handle_NewLSInfo error, local address was null, defaulting to localhost"); + LogError("Handle_NewLSInfo error, local address was null, defaulting to localhost"); local_ip = "127.0.0.1"; } else { @@ -510,7 +510,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info } } else { - Error("Handle_NewLSInfo error, local address was too long."); + LogError("Handle_NewLSInfo error, local address was too long."); return; } @@ -518,7 +518,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info if (strlen(new_world_server_info_packet->remote_address) <= 125) { if (strlen(new_world_server_info_packet->remote_address) == 0) { remote_ip = GetConnection()->Handle()->RemoteIP(); - Error( + LogError( "Remote address was null, defaulting to stream address %s.", remote_ip.c_str() ); @@ -542,7 +542,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info version = new_world_server_info_packet->serverversion; } else { - Error("Handle_NewLSInfo error, server version was too long."); + LogError("Handle_NewLSInfo error, server version was too long."); return; } @@ -550,7 +550,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info protocol = new_world_server_info_packet->protocolversion; } else { - Error("Handle_NewLSInfo error, protocol version was too long."); + LogError("Handle_NewLSInfo error, protocol version was too long."); return; } @@ -559,13 +559,13 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info if (server.options.IsRejectingDuplicateServers()) { if (server.server_manager->ServerExists(long_name, short_name, this)) { - Error("World tried to login but there already exists a server that has that name"); + LogError("World tried to login but there already exists a server that has that name"); return; } } else { if (server.server_manager->ServerExists(long_name, short_name, this)) { - Error("World tried to login but there already exists a server that has that name"); + LogError("World tried to login but there already exists a server that has that name"); server.server_manager->DestroyServerByName(long_name, short_name, this); } } @@ -700,14 +700,14 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info * this is the second of two cases where we should deny access even if unregistered is allowed */ if (server_account_name.size() > 0 || server_account_password.size() > 0) { - LogLoginserver( + LogInfo( "Server [{0}] [{1}] did not login but this server required a password to login", long_name, short_name ); } else { - LogLoginserver( + LogInfo( "Server [{0}] [{1}] did not login but unregistered servers are allowed", long_name, short_name @@ -720,7 +720,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info } } else { - LogLoginserver( + LogInfo( "Server [{0}] ({1}) is not registered but unregistered servers are allowed", long_name, short_name @@ -782,7 +782,7 @@ void WorldServer::SendClientAuth( client_auth.local = 1; } else if (IpUtil::IsIpInPrivateRfc1918(client_address)) { - LogLoginserver("Client is authenticating from a local address [{0}]", client_address); + LogInfo("Client is authenticating from a local address [{0}]", client_address); client_auth.local = 1; } else { @@ -792,13 +792,13 @@ void WorldServer::SendClientAuth( struct in_addr ip_addr{}; ip_addr.s_addr = client_auth.ip; - LogLoginserver( + LogInfo( "Client authentication response: world_address [{0}] client_address [{1}]", world_address, client_address ); - LogLoginserver( + LogInfo( "Sending Client Authentication Response ls_account_id [{0}] ls_name [{1}] name [{2}] key [{3}] ls_admin [{4}] " " world_admin [{5}] ip [{6}] local [{7}]", client_auth.lsaccount_id,