mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
||||
bool DatabaseLoader::Load()
|
||||
{
|
||||
if (!_updateFlags)
|
||||
LOG_INFO("sql.updates", "Automatic database updates are disabled for all databases!");
|
||||
LOG_WARN("sql.updates", "> AUTOUPDATER: Automatic database updates are disabled for all databases in the config! This is not recommended!");
|
||||
|
||||
if (!OpenDatabases())
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user