summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorKitzunu <24550914+Kitzunu@users.noreply.github.com>2024-07-04 19:25:28 +0200
committerGitHub <noreply@github.com>2024-07-04 14:25:28 -0300
commit6031ae2eb918ee21b3bc3da78bbb20bdc80ecd71 (patch)
tree4bcda49a269e46c080a224755795d417b8bce2b2 /src/common
parent385d7fd515c998f6420912e966aa65af4318e49a (diff)
chore(Core/Conf): Show better logging when fatal config options are m… (#19236)
chore(Core/Conf): Show better logging when fatal config options are missing * Show better log when the server halts due to missing fatal config option * Change error to warning for missing config options. As they are not errors * Update output when autoupdater is disabled for all databases
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Configuration/Config.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp
index 742777b186..d8665593ca 100644
--- a/src/common/Configuration/Config.cpp
+++ b/src/common/Configuration/Config.cpp
@@ -35,6 +35,14 @@ namespace
std::unordered_map<std::string /*name*/, std::string /*value*/> _envVarCache;
std::mutex _configLock;
+ std::vector<std::string> _fatalConfigOptions =
+ {
+ { "RealmID" },
+ { "LoginDatabaseInfo" },
+ { "WorldDatabaseInfo" },
+ { "CharacterDatabaseInfo" },
+ };
+
// Check system configs like *server.conf*
bool IsAppConfig(std::string_view fileName)
{
@@ -388,6 +396,7 @@ T ConfigMgr::GetValueDefault(std::string const& name, T const& def, bool showLog
std::string strValue;
auto const& itr = _configOptions.find(name);
+ bool fatalConfig = false;
bool notFound = itr == _configOptions.end();
auto envVarName = GetEnvVarName(name);
Optional<std::string> envVar = GetEnvFromCache(name, envVarName);
@@ -406,7 +415,18 @@ T ConfigMgr::GetValueDefault(std::string const& name, T const& def, bool showLog
{
if (showLogs)
{
- LOG_ERROR("server.loading", "> Config: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable.",
+ for (std::string s : _fatalConfigOptions)
+ if (s == name)
+ {
+ fatalConfig = true;
+ break;
+ }
+
+ if (fatalConfig)
+ LOG_FATAL("server.loading", "> Config:\n\nFATAL ERROR: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable\n\nYour server cannot start without this option!",
+ name, _filename, name, Acore::ToString(def), envVarName);
+ else
+ LOG_WARN("server.loading", "> Config: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable.",
name, _filename, name, Acore::ToString(def), envVarName);
}
return def;
@@ -435,6 +455,7 @@ template<>
std::string ConfigMgr::GetValueDefault<std::string>(std::string const& name, std::string const& def, bool showLogs /*= true*/) const
{
auto const& itr = _configOptions.find(name);
+ bool fatalConfig = false;
bool notFound = itr == _configOptions.end();
auto envVarName = GetEnvVarName(name);
Optional<std::string> envVar = GetEnvFromCache(name, envVarName);
@@ -453,7 +474,18 @@ std::string ConfigMgr::GetValueDefault<std::string>(std::string const& name, std
{
if (showLogs)
{
- LOG_ERROR("server.loading", "> Config: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable.",
+ for (std::string s : _fatalConfigOptions)
+ if (s == name)
+ {
+ fatalConfig = true;
+ break;
+ }
+
+ if (fatalConfig)
+ LOG_FATAL("server.loading", "> Config:\n\nFATAL ERROR: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable.\n\nYour server cannot start without this option!",
+ name, _filename, name, def, envVarName);
+ else
+ LOG_WARN("server.loading", "> Config: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable.",
name, _filename, name, def, envVarName);
}