442{
443 auto const& itr = _configOptions.find(name);
444 bool fatalConfig = false;
445 bool notFound = itr == _configOptions.end();
446 auto envVarName = GetEnvVarName(name);
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 {
463 for (std::string s : _fatalConfigOptions)
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!",
472 name, _filename, name, def, envVarName);
473 else
474 LOG_WARN(
"server.loading",
"> Config: Missing property {} in config file {}, add \"{} = {}\" to this file or define '{}' as an environment variable.",
475 name, _filename, name, def, envVarName);
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
Optional< std::string > GetEnvFromCache(std::string const &configName, std::string const &envVarName)
Definition Config.cpp:335