From 908b826fb42eb69d7c5852142831b2af0db8edd8 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Sun, 27 Jul 2025 15:34:14 -0500 Subject: [PATCH] more log adjustments --- common/database/database_update.cpp | 16 ++-- common/eqemu_logsys.cpp | 5 +- common/eqemu_logsys_log_aliases.h | 10 ++ common/path_manager.cpp | 8 +- world/world_boot.cpp | 143 +++++++++++----------------- 5 files changed, 81 insertions(+), 101 deletions(-) diff --git a/common/database/database_update.cpp b/common/database/database_update.cpp index d296aa92b..7d4291703 100644 --- a/common/database/database_update.cpp +++ b/common/database/database_update.cpp @@ -55,7 +55,7 @@ void DatabaseUpdate::CheckDbUpdates() } if (UpdateManifest(manifest_entries, v.server_database_version, b.server_database_version)) { - LogInfo( + LogInfoNoFn( "Updates ran successfully, setting database version to [{}] from [{}]", b.server_database_version, v.server_database_version @@ -64,7 +64,7 @@ void DatabaseUpdate::CheckDbUpdates() } if (UpdateManifest(manifest_entries_custom, v.custom_database_version, b.custom_database_version)) { - LogInfo( + LogInfoNoFn( "Updates ran successfully, setting database version to [{}] from [{}]", b.custom_database_version, v.custom_database_version @@ -337,9 +337,9 @@ DatabaseUpdate *DatabaseUpdate::SetSkipBackup(bool skip) bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b) { - LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); + LogInfoNoFn("{}", Strings::Repeat("-", BREAK_LENGTH)); - LogInfo( + LogInfoNoFn( "{:>8} | database [{}] binary [{}] {}", "Server", v.server_database_version, @@ -348,7 +348,7 @@ bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b) ); if (RuleB(Bots, Enabled) && b.bots_database_version > 0) { - LogInfo( + LogInfoNoFn( "{:>8} | database [{}] binary [{}] {}", "Bots", v.bots_database_version, @@ -358,7 +358,7 @@ bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b) } if (b.custom_database_version > 0) { - LogInfo( + LogInfoNoFn( "{:>8} | database [{}] binary [{}] {}", "Custom", v.custom_database_version, @@ -367,9 +367,9 @@ bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b) ); } - LogInfo("{:>8} | [server.auto_database_updates] [true]", "Config"); + LogInfoNoFn("{:>8} | [server.auto_database_updates] [true]", "Config"); - LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); + LogInfoNoFn("{}", Strings::Repeat("-", BREAK_LENGTH)); // server database version is required bool server_up_to_date = v.server_database_version >= b.server_database_version; diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index 8943a52f1..9194a4634 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -317,7 +317,10 @@ void EQEmuLogSys::ProcessConsoleMessage( } } - out << rang::fgB::black << "#" << func << " "; + // check if func is not empty + if (func && *func) { + out << rang::fgB::black << "#" << func << " "; + } if (!origination_info.zone_short_name.empty()) { out << rang::fgB::black << "-- " diff --git a/common/eqemu_logsys_log_aliases.h b/common/eqemu_logsys_log_aliases.h index a2c88a03f..b4b0fc352 100644 --- a/common/eqemu_logsys_log_aliases.h +++ b/common/eqemu_logsys_log_aliases.h @@ -449,6 +449,11 @@ inline auto logsys = EQEmuLogSys::Instance(); OutF(logsys, Logs::General, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) +#define LogInfoNoFn(message, ...) do {\ + if (logsys->IsLogEnabled(Logs::General, Logs::Info))\ + OutF(logsys, Logs::General, Logs::Info, "", "", 0, message, ##__VA_ARGS__);\ +} while (0) + #define LogInfoDetail(message, ...) do {\ if (logsys->IsLogEnabled(Logs::Detail, Logs::Info))\ OutF(logsys, Logs::Detail, Logs::Info, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ @@ -459,6 +464,11 @@ inline auto logsys = EQEmuLogSys::Instance(); OutF(logsys, Logs::General, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ } while (0) +#define LogWarningNoFn(message, ...) do {\ + if (logsys->IsLogEnabled(Logs::General, Logs::Info))\ + OutF(logsys, Logs::General, Logs::Warning, "", "", 0, message, ##__VA_ARGS__);\ +} while (0) + #define LogWarningDetail(message, ...) do {\ if (logsys->IsLogEnabled(Logs::Detail, Logs::Warning))\ OutF(logsys, Logs::Detail, Logs::Warning, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\ diff --git a/common/path_manager.cpp b/common/path_manager.cpp index c63835854..7afa0c16c 100644 --- a/common/path_manager.cpp +++ b/common/path_manager.cpp @@ -87,16 +87,16 @@ void PathManager::Init() constexpr int break_length = 70; LogInfo("Loading server paths"); - LogInfo("{}", Strings::Repeat("-", break_length)); + LogInfoNoFn("{}", Strings::Repeat("-", break_length)); for (const auto& [name, in_path] : paths) { if (!in_path.empty()) { - LogInfo("{:>{}} > [{:<{}}]", name, name_width, in_path, path_width); + LogInfoNoFn("{:>{}} > {:<{}}", name, name_width, in_path, path_width); } } auto log_paths = [&](const std::string& label, const std::vector& paths) { if (!paths.empty()) { - LogInfo("{:>{}} > [{:<{}}]", label, name_width - 1, Strings::Join(paths, ";"), path_width); + LogInfoNoFn("{:>{}} > {:<{}}", label, name_width, Strings::Join(paths, ";"), path_width); } }; @@ -104,7 +104,7 @@ void PathManager::Init() log_paths("plugins", m_plugin_paths); log_paths("lua_modules", m_lua_module_paths); - LogInfo("{}", Strings::Repeat("-", break_length)); + LogInfoNoFn("{}", Strings::Repeat("-", break_length)); } const std::string &PathManager::GetServerPath() const diff --git a/world/world_boot.cpp b/world/world_boot.cpp index 19667927c..568365e4f 100644 --- a/world/world_boot.cpp +++ b/world/world_boot.cpp @@ -419,7 +419,7 @@ void WorldBoot::CheckForPossibleConfigurationIssues() const auto c = EQEmuConfig::get(); if (c->DisableConfigChecks) { - LogInfo("Configuration checking [disabled]"); + LogInfoNoFn("Configuration checking [disabled]"); return; } @@ -429,17 +429,17 @@ void WorldBoot::CheckForPossibleConfigurationIssues() const std::ifstream is_in_docker("/.dockerenv"); if (local_address.empty() && public_address.empty()) { - LogInfo("Configuration check, probes failed for local and public address, returning"); + LogInfoNoFn("Configuration check, probes failed for local and public address, returning"); return; } - LogInfo("Checking for possible configuration issues"); - LogInfo("To disable configuration checks, set [server.disable_config_checks] to [true] in [{}]", config_file); + LogInfoNoFn("Checking for possible configuration issues"); + LogInfoNoFn("To disable configuration checks, set [server.disable_config_checks] to [true] in [{}]", config_file); std::string config_address = c->WorldAddress; if (!IpUtil::IsIPAddress(config_address)) { config_address = IpUtil::DNSLookupSync(c->WorldAddress, 9000); - LogInfo( + LogInfoNoFn( "World config address using DNS [{}] resolves to [{}]", c->WorldAddress, config_address @@ -454,16 +454,12 @@ void WorldBoot::CheckForPossibleConfigurationIssues() && local_address != c->LocalAddress && !is_in_docker ) { - LogWarning("# LAN detection (Configuration)"); - LogWarning(""); - LogWarning("You appear to be on a LAN and your localaddress may not be properly set!"); - LogWarning("This can prevent local clients from properly connecting to your server"); - LogWarning(""); - LogWarning("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); - LogWarning(""); - LogWarning("Config file [{}] path [server.world] variable [localaddress]", config_file); - LogWarning(""); - LogWarning("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); + LogWarningNoFn("# LAN detection (Configuration)"); + LogWarningNoFn("You appear to be on a LAN and your localaddress may not be properly set!"); + LogWarningNoFn("This can prevent local clients from properly connecting to your server"); + LogWarningNoFn("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); + LogWarningNoFn("Config file [{}] path [server.world] variable [localaddress]", config_file); + LogWarningNoFn("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); std::cout << std::endl; } @@ -475,28 +471,21 @@ void WorldBoot::CheckForPossibleConfigurationIssues() ) && is_in_docker ) { - LogWarning("# Docker Configuration (Configuration)"); - LogWarning(""); - LogWarning("You appear to running EQEmu in a docker container"); - LogWarning("In order for networking to work properly you will need to properly configure your server"); - LogWarning(""); - LogWarning( + LogWarningNoFn("# Docker Configuration (Configuration)"); + LogWarningNoFn("You appear to running EQEmu in a docker container"); + LogWarningNoFn("In order for networking to work properly you will need to properly configure your server"); + LogWarningNoFn( "If your Docker host is on a [LAN] or behind a NAT / Firewall, your [localaddress] variable under [server.world] will need to"); - LogWarning( + LogWarningNoFn( "be set to your LAN address on the host, not the container address. [address] will need to be your public address"); - LogWarning(""); - LogWarning( + LogWarningNoFn( "If your Docker host is directly on the [public internet], your [localaddress] variable under [server.world] can be set to [127.0.0.1]." ); - LogWarning(""); - LogWarning("[address] will need to be your public address"); - LogWarning(""); - LogWarning("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); - LogWarning(""); - LogWarning("Config file [{}] path [server.world] variable(s) [localaddress] [address]", config_file); - LogWarning(""); - LogWarning("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); - LogWarning( + LogWarningNoFn("[address] will need to be your public address"); + LogWarningNoFn("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); + LogWarningNoFn("Config file [{}] path [server.world] variable(s) [localaddress] [address]", config_file); + LogWarningNoFn("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); + LogWarningNoFn( "Public address (eqemu_config) value [{}] detected value [{}]", config_address, public_address @@ -506,30 +495,23 @@ void WorldBoot::CheckForPossibleConfigurationIssues() // docker LAN not set if (c->LocalAddress.empty() && is_in_docker) { - LogWarning("# Docker LAN (Configuration)"); - LogWarning(""); - LogWarning("You appear to running EQEmu in a docker container"); - LogWarning( + LogWarningNoFn("# Docker LAN (Configuration)"); + LogWarningNoFn("You appear to running EQEmu in a docker container"); + LogWarningNoFn( "Your local address does not appear to be set, this may not be an issue if your deployment is not on a LAN" ); - LogWarning(""); - LogWarning( + LogWarningNoFn( "If your Docker host is on a [LAN] or behind a NAT / Firewall, your [localaddress] variable under [server.world] will need to"); - LogWarning( + LogWarningNoFn( "be set to your LAN address on the host, not the container address. [address] will need to be your public address"); - LogWarning(""); - LogWarning( + LogWarningNoFn( "If your Docker host is directly on the [public internet], your [localaddress] variable under [server.world] can be set to [127.0.0.1]." ); - LogWarning(""); - LogWarning("[address] will need to be your public address"); - LogWarning(""); - LogWarning("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); - LogWarning(""); - LogWarning("Config file [{}] path [server.world] variable(s) [localaddress] [address]", config_file); - LogWarning(""); - LogWarning("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); - LogWarning( + LogWarningNoFn("[address] will need to be your public address"); + LogWarningNoFn("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); + LogWarningNoFn("Config file [{}] path [server.world] variable(s) [localaddress] [address]", config_file); + LogWarningNoFn("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); + LogWarningNoFn( "Public address (eqemu_config) value [{}] detected value [{}]", config_address, public_address @@ -539,15 +521,11 @@ void WorldBoot::CheckForPossibleConfigurationIssues() // public address different from configuration if (!config_address.empty() && public_address != config_address) { - LogWarning("# Public address (Configuration)"); - LogWarning(""); - LogWarning("Your configured public address appears to be different from what's detected!"); - LogWarning(""); - LogWarning("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); - LogWarning(""); - LogWarning("Config file [{}] path [server.world] variable [address]", config_file); - LogWarning(""); - LogWarning( + LogWarningNoFn("# Public address (Configuration)"); + LogWarningNoFn("Your configured public address appears to be different from what's detected!"); + LogWarningNoFn("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); + LogWarningNoFn("Config file [{}] path [server.world] variable [address]", config_file); + LogWarningNoFn( "Public address (eqemu_config) value [{}] detected value [{}]", config_address, public_address @@ -557,17 +535,13 @@ void WorldBoot::CheckForPossibleConfigurationIssues() // public address set to meta-address if (config_address == "0.0.0.0") { - LogWarning("# Public meta-address (Configuration)"); - LogWarning(""); - LogWarning("Your configured public address is set to a meta-address (0.0.0.0) (all-interfaces)"); - LogWarning( + LogWarningNoFn("# Public meta-address (Configuration)"); + LogWarningNoFn("Your configured public address is set to a meta-address (0.0.0.0) (all-interfaces)"); + LogWarningNoFn( "The meta-address may not work properly and it is recommended you configure your public address explicitly"); - LogWarning(""); - LogWarning("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); - LogWarning(""); - LogWarning("Config file [{}] path [server.world] variable [address]", config_file); - LogWarning(""); - LogWarning( + LogWarningNoFn("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); + LogWarningNoFn("Config file [{}] path [server.world] variable [address]", config_file); + LogWarningNoFn( "Public address (eqemu_config) value [{}] detected value [{}]", config_address, public_address @@ -577,18 +551,14 @@ void WorldBoot::CheckForPossibleConfigurationIssues() // local address set to meta-address if (c->LocalAddress == "0.0.0.0") { - LogWarning("# Local meta-address (Configuration)"); - LogWarning(""); - LogWarning("Your configured local address is set to a meta-address (0.0.0.0) (all-interfaces)"); - LogWarning( + LogWarningNoFn("# Local meta-address (Configuration)"); + LogWarningNoFn("Your configured local address is set to a meta-address (0.0.0.0) (all-interfaces)"); + LogWarningNoFn( "The meta-address may not work properly and it is recommended you configure your local address explicitly" ); - LogWarning(""); - LogWarning("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); - LogWarning(""); - LogWarning("Config file [{}] path [server.world] variable [localaddress]", config_file); - LogWarning(""); - LogWarning("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); + LogWarningNoFn("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#world]"); + LogWarningNoFn("Config file [{}] path [server.world] variable [localaddress]", config_file); + LogWarningNoFn("Local address (eqemu_config) value [{}] detected value [{}]", c->LocalAddress, local_address); std::cout << std::endl; } @@ -596,16 +566,13 @@ void WorldBoot::CheckForPossibleConfigurationIssues() if ( (!config_address.empty() && c->GetUCSHost() != config_address) ) { - LogWarning("# UCS Address Mailhost (Configuration)"); - LogWarning(""); - LogWarning( + LogWarningNoFn("# UCS Address Mailhost (Configuration)"); + LogWarningNoFn( "UCS (Universal Chat Service) mail or chat appears to use a different address from your main world address" ); - LogWarning("This can result in a chat service that doesn't network properly"); - LogWarning(""); - LogWarning("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#mailserver]"); - LogWarning(""); - LogWarning( + LogWarningNoFn("This can result in a chat service that doesn't network properly"); + LogWarningNoFn("Docs [https://docs.eqemu.io/server/installation/configure-your-eqemu_config/#mailserver]"); + LogWarningNoFn( "[server.world.address] value [{}] [server.ucs.host] [{}]", config_address, c->GetUCSHost()