442{
444 bool fatalConfig = false;
448 if (envVar)
449 {
450
451 if (showLogs && (notFound || itr->second != envVar->c_str()))
452 {
453 LOG_INFO(
"server.loading",
"> Config: Found config value '{}' from environment variable '{}'.", name, envVarName);
454 AddKey(name, *envVar,
"ENVIRONMENT",
false,
false);
455 }
456
457 return *envVar;
458 }
459 else if (notFound)
460 {
461 if (showLogs)
462 {
464 if (s == name)
465 {
466 fatalConfig = true;
467 break;
468 }
469
470 if (fatalConfig)
471 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!",
473 else
474 LOG_WARN(
"server.loading",
"> Config: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable.",
476 }
477
478 return def;
479 }
480
481 return itr->second;
482}
#define LOG_FATAL(filterType__,...)
Definition: Log.h:153
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_WARN(filterType__,...)
Definition: Log.h:161
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
std::string GetEnvVarName(std::string const &configName)
Definition: Config.cpp:281
std::vector< std::string > _fatalConfigOptions
Definition: Config.cpp:38
std::unordered_map< std::string, std::string > _configOptions
Definition: Config.cpp:34
std::string _filename
Definition: Config.cpp:31
void AddKey(std::string const &optionName, std::string const &optionKey, std::string_view fileName, bool isOptional, bool isReload)
Definition: Config.cpp:80
Optional< std::string > GetEnvFromCache(std::string const &configName, std::string const &envVarName)
Definition: Config.cpp:335