feat(Modules): load modules configs before Log initialization (#6104)
in order to properly load modules appenders and loggers
This commit is contained in:
@@ -347,7 +347,6 @@ bool ConfigMgr::LoadModulesConfigs()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Start loading module configs
|
// Start loading module configs
|
||||||
std::vector<std::string /*config variant*/> moduleConfigFiles;
|
|
||||||
std::string const& moduleConfigPath = GetConfigPath() + "modules/";
|
std::string const& moduleConfigPath = GetConfigPath() + "modules/";
|
||||||
bool isExistDefaultConfig = true;
|
bool isExistDefaultConfig = true;
|
||||||
bool isExistDistConfig = true;
|
bool isExistDistConfig = true;
|
||||||
@@ -368,25 +367,25 @@ bool ConfigMgr::LoadModulesConfigs()
|
|||||||
isExistDefaultConfig = false;
|
isExistDefaultConfig = false;
|
||||||
|
|
||||||
if (isExistDefaultConfig && isExistDistConfig)
|
if (isExistDefaultConfig && isExistDistConfig)
|
||||||
moduleConfigFiles.emplace_back(defaultFileName);
|
_moduleConfigFiles.emplace_back(defaultFileName);
|
||||||
else if (!isExistDefaultConfig && isExistDistConfig)
|
else if (!isExistDefaultConfig && isExistDistConfig)
|
||||||
moduleConfigFiles.emplace_back(distFileName);
|
_moduleConfigFiles.emplace_back(distFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If module configs not exist - no load
|
// If module configs not exist - no load
|
||||||
if (moduleConfigFiles.empty())
|
return !_moduleConfigFiles.empty();
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
void ConfigMgr::PrintLoadedModulesConfigs()
|
||||||
|
{
|
||||||
// Print modules configurations
|
// Print modules configurations
|
||||||
LOG_INFO("server", " ");
|
LOG_INFO("server", " ");
|
||||||
LOG_INFO("server", "Using modules configuration:");
|
LOG_INFO("server", "Using modules configuration:");
|
||||||
|
|
||||||
for (auto const& itr : moduleConfigFiles)
|
for (auto const& itr : _moduleConfigFiles)
|
||||||
LOG_INFO("server", "> %s", itr.c_str());
|
LOG_INFO("server", "> %s", itr.c_str());
|
||||||
|
|
||||||
LOG_INFO("server", " ");
|
LOG_INFO("server", " ");
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
bool isDryRun() { return dryRun; }
|
bool isDryRun() { return dryRun; }
|
||||||
void setDryRun(bool mode) { dryRun = mode; }
|
void setDryRun(bool mode) { dryRun = mode; }
|
||||||
|
|
||||||
|
void PrintLoadedModulesConfigs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
|
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
|
||||||
bool LoadInitial(std::string const& file);
|
bool LoadInitial(std::string const& file);
|
||||||
@@ -67,6 +69,8 @@ private:
|
|||||||
T GetValueDefault(std::string const& name, T const& def, bool showLogs = true) const;
|
T GetValueDefault(std::string const& name, T const& def, bool showLogs = true) const;
|
||||||
|
|
||||||
bool dryRun = false;
|
bool dryRun = false;
|
||||||
|
|
||||||
|
std::vector<std::string /*config variant*/> _moduleConfigFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigException : public std::length_error
|
class ConfigException : public std::length_error
|
||||||
|
|||||||
@@ -122,6 +122,9 @@ extern int main(int argc, char** argv)
|
|||||||
if (!sConfigMgr->LoadAppConfigs())
|
if (!sConfigMgr->LoadAppConfigs())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
// Loading modules configs
|
||||||
|
sConfigMgr->LoadModulesConfigs();
|
||||||
|
|
||||||
sLog->RegisterAppender<AppenderDB>();
|
sLog->RegisterAppender<AppenderDB>();
|
||||||
sLog->Initialize();
|
sLog->Initialize();
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ int Master::Run()
|
|||||||
LoadRealmInfo();
|
LoadRealmInfo();
|
||||||
|
|
||||||
// Loading modules configs
|
// Loading modules configs
|
||||||
sConfigMgr->LoadModulesConfigs();
|
sConfigMgr->PrintLoadedModulesConfigs();
|
||||||
|
|
||||||
///- Initialize the World
|
///- Initialize the World
|
||||||
sSecretMgr->Initialize();
|
sSecretMgr->Initialize();
|
||||||
|
|||||||
Reference in New Issue
Block a user