src/core/module/ModuleManager.cpp
std::tuple<LogLevel, LogFormat> ModuleManager::set_module_before(const std::string&, const Configuration& config) {
    // Set new log level if necessary
    LogLevel prev_level = Log::getReportingLevel();
    if(config.has("log_level")) {
        auto log_level_string = config.get<std::string>("log_level");
        std::transform(log_level_string.begin(), log_level_string.end(), log_level_string.begin(), ::toupper);
        try {
            LogLevel log_level = Log::getLevelFromString(log_level_string);
            if(log_level != prev_level) {
                LOG(TRACE) << "Local log level is set to " << log_level_string;
                Log::setReportingLevel(log_level);
            }
        } catch(std::invalid_argument& e) {
            throw InvalidValueError(config, "log_level", e.what());
        }
    }

    // Set new log format if necessary
    LogFormat prev_format = Log::getFormat();
    if(config.has("log_format")) {
        auto log_format_string = config.get<std::string>("log_format");
        std::transform(log_format_string.begin(), log_format_string.end(), log_format_string.begin(), ::toupper);
        try {
            LogFormat log_format = Log::getFormatFromString(log_format_string);
            if(log_format != prev_format) {
                LOG(TRACE) << "Local log format is set to " << log_format_string;
                Log::setFormat(log_format);
            }
        } catch(std::invalid_argument& e) {
            throw InvalidValueError(config, "log_format", e.what());
        }
    }

    return std::make_tuple(prev_level, prev_format);
}
// Helper functions to set the module specific log settings if necessary
Helper functions to set the module specific log settings if necessary
Helper functions to set the module specific log settings if necessary
std::tuple<LogLevel, LogFormat> ModuleManager::set_module_before(const std::string&, const Configuration& config) {
    LogLevel prev_level = Log::getReportingLevel();
    if(config.has("log_level")) {
        auto log_level_string = config.get<std::string>("log_level");
        std::transform(log_level_string.begin(), log_level_string.end(), log_level_string.begin(), ::toupper);
        try {
            LogLevel log_level = Log::getLevelFromString(log_level_string);
            if(log_level != prev_level) {
                LOG(TRACE) << "Local log level is set to " << log_level_string;
                Log::setReportingLevel(log_level);
            }
        } catch(std::invalid_argument& e) {
            throw InvalidValueError(config, "log_level", e.what());
        }
    }
    LogFormat prev_format = Log::getFormat();
    if(config.has("log_format")) {
        auto log_format_string = config.get<std::string>("log_format");
        std::transform(log_format_string.begin(), log_format_string.end(), log_format_string.begin(), ::toupper);
        try {
            LogFormat log_format = Log::getFormatFromString(log_format_string);
            if(log_format != prev_format) {
                LOG(TRACE) << "Local log format is set to " << log_format_string;
                Log::setFormat(log_format);
            }
        } catch(std::invalid_argument& e) {
            throw InvalidValueError(config, "log_format", e.what());
        }
    }
    return std::make_tuple(prev_level, prev_format);
}
std :: tuple < LogLevel , LogFormat > ModuleManager :: set_module_before ( const std :: string & , const Configuration & config ) { LogLevel prev_level = Log :: getReportingLevel ( ) ; if ( config . has ( " " ) ) { auto log_level_string = config . get < std :: string > ( " " ) ; std :: transform ( log_level_string . begin ( ) , log_level_string . end ( ) , log_level_string . begin ( ) , :: toupper ) ; try { LogLevel log_level = Log :: getLevelFromString ( log_level_string ) ; if ( log_level != prev_level ) { LOG ( TRACE ) << " " << log_level_string ; Log :: setReportingLevel ( log_level ) ; } } catch ( std :: invalid_argument & e ) { throw InvalidValueError ( config , " " , e . what ( ) ) ; } } LogFormat prev_format = Log :: getFormat ( ) ; if ( config . has ( " " ) ) { auto log_format_string = config . get < std :: string > ( " " ) ; std :: transform ( log_format_string . begin ( ) , log_format_string . end ( ) , log_format_string . begin ( ) , :: toupper ) ; try { LogFormat log_format = Log :: getFormatFromString ( log_format_string ) ; if ( log_format != prev_format ) { LOG ( TRACE ) << " " << log_format_string ; Log :: setFormat ( log_format ) ; } } catch ( std :: invalid_argument & e ) { throw InvalidValueError ( config , " " , e . what ( ) ) ; } } return std :: make_tuple ( prev_level , prev_format ) ; }
Helper functions to set the module specific log settings if necessary
Helper functions to set the module specific log settings if necessary
// Set new log level if necessary // Set new log format if necessary