コード例 #1
0
//============================================================================//
void Configuration::prepareApplicationLoggingFiles(AbstractConfiguration &config, const string &prefix)
{

    // find all files loggers
    AbstractConfiguration::Keys             channelsKeys;
    AbstractConfiguration::Keys::iterator   keyIt;

    config.keys("logging.channels", channelsKeys);

    config.setString("application.logger", prefix);


    for(keyIt = channelsKeys.begin(); keyIt != channelsKeys.end(); ++keyIt) {
        if(!config.getString("logging.channels." + *keyIt + ".class", "").
            compare("FileChannel")) {

            config.setString("logging.channels." + *keyIt + ".path",
                Path(config.getString("logging.channels." + *keyIt + ".path", "") +
                    Path::separator()).makeAbsolute().
                    setFileName(
                        "UpSys" + prefix + 
                        config.getString("args.software_identifier")
                        + ".log").toString());
        }
    }

}
コード例 #2
0
ファイル: Clients.cpp プロジェクト: Rajan/Cumulus
void Client::copyProperties(const AbstractConfiguration& abstractConfigs,const string& root) {
	AbstractConfiguration::Keys keys;
	abstractConfigs.keys(root,keys);
	AbstractConfiguration::Keys::const_iterator it;
	for(it=keys.begin();it!=keys.end();++it) {
		string key(root);
		if(!key.empty())
			key+=".";
		key += (*it);
		if(abstractConfigs.hasOption(key))
			setString(key,abstractConfigs.getString(key));
		else
			copyProperties(abstractConfigs,key);
	}
}
コード例 #3
0
//============================================================================//
void Configuration::prepareApplicationLoggingDisableConsole(AbstractConfiguration &config)
{
    // find all files loggers
    AbstractConfiguration::Keys             channelsKeys;
    AbstractConfiguration::Keys::iterator   keyIt;

    config.keys("logging.channels", channelsKeys);

    for(keyIt = channelsKeys.begin(); keyIt != channelsKeys.end(); ++keyIt) {
        if(!config.getString("logging.channels." + *keyIt + ".class", "").
            compare("ConsoleChannel")) {

            config.setString("logging.channels." + *keyIt + ".class",
                "NullChannel");
        }
    }
}
コード例 #4
0
//============================================================================//
void AnalyzerDispatcher::create(AbstractConfiguration &config)
{
    AbstractConfiguration::Keys             analyzersCodes;
    AbstractConfiguration::Keys::iterator   iter;

    config.keys("analyzers.list", analyzersCodes);

    for(iter = analyzersCodes.begin(); iter != analyzersCodes.end(); ++iter) {

        string type = config.getString("analyzers.list."+(*iter)+".type");

        if(config.has("analyzers.list."+(*iter)+".disabled")) {
            poco_information_f2(Logger::get(_loggerName),
                "analyzer type of [%s] with code [%s] disabled",
                type, string(*iter));
            continue;
        }

        if(_fabrics->isClass(type)) {

            poco_information_f1(Logger::get(_loggerName), "create analyzer for type [%s]", type);

            Analyzer::Arguments  args(*iter, config);
            Analyzer *a = _fabrics->create(type, args);

            poco_information_f2(Logger::get(_loggerName),
                "starting analyzer type of [%s] with code [%s]",
                type, string(a->getCode()));

            try {
                a->start();
                _analyzers.insert(pair<string, SharedPtr<Analyzer> >(*iter, a));
            }
            catch(exception &e) {
                delete a;
            }
        }
        else {
            poco_warning_f1(Logger::get(_loggerName), "unknown analyzer type [%s]... skip this.", type);
        }
    }

    poco_information_f1(Logger::get(_loggerName), "[%d] analyzers was registered", (int)_analyzers.size());
}