コード例 #1
0
ファイル: LogService.cpp プロジェクト: AllenWangxiao/winner
	bool LogService::_load(const char* path){
		// load config
		protocol::LogServiceConfig* cfg =(protocol::LogServiceConfig*)protocol::create_protocol_from_lua_file(protocol::PROTOCOL_LOG_SERVICE_CONFIG, path);
		if(!cfg){
			DEBUG("load log service fail, cfg load error");
			return false;
		}

		// dump config
		Bytes* str =SafeNew<Bytes>();
		cfg->appendToString(str, 0);
		DEBUG(str->toString()->c_str());

		// add target
		const int64_t n =cfg->getTargetCount();
		for(int64_t i=0; i<n; ++i){
			protocol::LogTargetConfig* ltc =cfg->getTarget(i);
			Logger* lg =SafeNew<Logger>();
			lg->setName(ltc->getFileName());
			lg->SetFileLifeTime(ltc->getFileLifeTime());
			lg->setFlushMode(ltc->getFlushMode());
			m_logger_table->set(ltc->getType(), lg);
		}
		return true;
	}