| 2907 | } |
| 2908 | |
| 2909 | void Loggers::configureFromGlobal(const char* globalConfigurationFilePath) { |
| 2910 | std::ifstream gcfStream(globalConfigurationFilePath, std::ifstream::in); |
| 2911 | ELPP_ASSERT(gcfStream.is_open(), "Unable to open global configuration file [" << globalConfigurationFilePath |
| 2912 | << "] for parsing."); |
| 2913 | std::string line = std::string(); |
| 2914 | std::stringstream ss; |
| 2915 | Logger* logger = nullptr; |
| 2916 | auto configure = [&](void) { |
| 2917 | ELPP_INTERNAL_INFO(8, "Configuring logger: '" << logger->id() << "' with configurations \n" << ss.str() |
| 2918 | << "\n--------------"); |
| 2919 | Configurations c; |
| 2920 | c.parseFromText(ss.str()); |
| 2921 | logger->configure(c); |
| 2922 | }; |
| 2923 | while (gcfStream.good()) { |
| 2924 | std::getline(gcfStream, line); |
| 2925 | ELPP_INTERNAL_INFO(1, "Parsing line: " << line); |
| 2926 | base::utils::Str::trim(line); |
| 2927 | if (Configurations::Parser::isComment(line)) continue; |
| 2928 | Configurations::Parser::ignoreComments(&line); |
| 2929 | base::utils::Str::trim(line); |
| 2930 | if (line.size() > 2 && base::utils::Str::startsWith(line, std::string(base::consts::kConfigurationLoggerId))) { |
| 2931 | if (!ss.str().empty() && logger != nullptr) { |
| 2932 | configure(); |
| 2933 | } |
| 2934 | ss.str(std::string("")); |
| 2935 | line = line.substr(2); |
| 2936 | base::utils::Str::trim(line); |
| 2937 | if (line.size() > 1) { |
| 2938 | ELPP_INTERNAL_INFO(1, "Getting logger: '" << line << "'"); |
| 2939 | logger = getLogger(line); |
| 2940 | } |
| 2941 | } else { |
| 2942 | ss << line << "\n"; |
| 2943 | } |
| 2944 | } |
| 2945 | if (!ss.str().empty() && logger != nullptr) { |
| 2946 | configure(); |
| 2947 | } |
| 2948 | } |
| 2949 | |
| 2950 | bool Loggers::configureFromArg(const char* argKey) { |
| 2951 | #if defined(ELPP_DISABLE_CONFIGURATION_FROM_PROGRAM_ARGS) |
nothing calls this directly
no test coverage detected