当前位置: 首页>>代码示例>>C++>>正文


C++ KLOG_ERR函数代码示例

本文整理汇总了C++中KLOG_ERR函数的典型用法代码示例。如果您正苦于以下问题:C++ KLOG_ERR函数的具体用法?C++ KLOG_ERR怎么用?C++ KLOG_ERR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了KLOG_ERR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: throw

/** \brief Start the operation
 */
bt_err_t bt_session_t::start(const ipport_aview_t &p_listen_aview, const bt_id_t &p_local_peerid)	throw()
{
	socket_err_t	socket_err;
	// log to debug
	KLOG_ERR("p_listen_aview=" << p_listen_aview);
	// copy the parameter
	this->m_listen_aview	= p_listen_aview;
	
	// start the socket_resp_t
	socket_resp_arg_t	resp_arg;
	resp_arg	= bt_session_helper_t::build_socket_resp_arg(listen_lview(), this);
	socket_resp	= nipmem_new socket_resp_t();
	socket_err	= socket_resp->start(resp_arg, this, NULL);
	if( socket_err.failed() )	return bt_err_from_socket(socket_err);

	// update the listen_aview in case socket_resp_t did dynamic binding
	ipport_addr_t	bound_listen_lview = socket_resp->listen_addr().get_peerid_vapi()->to_string()
					+ std::string(":")
					+ socket_resp->listen_addr().get_portid_vapi()->to_string();
	this->m_listen_aview.update_once_bound(bound_listen_lview);

	// set the local_peerid - if the parameter is unset, get 
	if( !p_local_peerid.is_null() )	m_local_peerid	= p_local_peerid;
	else				m_local_peerid	= bt_id_t::build_random();

	// init the static link http - to ease access while debugging
	wikidbg_obj_add_static_page("/bt_session_" + local_peerid().to_string());
	// return no error
	return bt_err_t::OK;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:32,代码来源:neoip_bt_session.cpp

示例2: set_ezsession_maxrate

/** \brief Set the bt_ezsession_t recv_maxrate/xmit_maxrate
 */
static bool	set_ezsession_maxrate(void *userptr, const std::string &direction
			, const std::string &rate_str)	throw()
{
	btcli_resp_t *		btcli_resp	= (btcli_resp_t*)userptr;
	bt_ezsession_t *	bt_ezsession	= btcli_resp->bt_ezsession();
	// log to debug
	KLOG_ERR("direction=" << direction << " newrate=" << rate_str);	
	// get the rate_sched_t depending on the direction
	rate_sched_t *		rate_sched	= NULL;
	if( direction == "recv")	rate_sched = bt_ezsession->recv_rsched();
	if( direction == "xmit")	rate_sched = bt_ezsession->xmit_rsched();
	
	// TODO if rate_sched is null here, notify an error to the caller with 
	// "xmit rate sched is not tunable"
	DBG_ASSERT( rate_sched );
	
	// convert the new_rate_str into a double
	double	new_rate	= double(string_t::to_uint64(rate_str));
	// set the new maxrate
	rate_sched->max_rate(new_rate);
	
	// return true all the time
	// TODO currently void is not supported
	// - i need to have a way to report the error to the xmlrpc caller
	// - how do i do that ?
	return true;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:29,代码来源:neoip_btcli_resp.cpp

示例3: throw

/** \brief Start the operation
 * 
 * @return true on error, false otherwise
 */
bool	asyncop_t::start(asyncop_completed_cb_t *callback, void *userptr
				, asyncop_do_work_cb_t do_work_cb
				, asyncop_free_work_cb_t free_work_cb )	throw()
{
	// copy the parameter
	this->callback	= callback;
	this->userptr	= userptr;

	// allocate the thread_ctx - it gonna be freed in t
	thread_ctx	= nipmem_new asyncop_thread_ctx_t();
	// fill the struct
	thread_ctx->do_work_cb	= do_work_cb;
	thread_ctx->free_work_cb= free_work_cb;
	thread_ctx->result_ptr	= NULL;
	thread_ctx->userptr	= userptr;
	thread_ctx->asyncop	= this;

	// initialize glib thread if needed
	if(!g_thread_supported ())	g_thread_init (NULL);
	// create the thread
	GError *gerr	= NULL;
	GThread*thread	= g_thread_create(asyncop_thread_glib_cb, thread_ctx, TRUE, &gerr);
	if( gerr != NULL ){
		KLOG_ERR("can't create a thread for asyncop_t due to gerr=" << gerr->message);
		g_error_free(gerr);
		return true;
	}
	// sanity check - the thread MUST be non NULL
	DBG_ASSERT( thread );

	// return no error
	return false;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:37,代码来源:neoip_asyncop.cpp

示例4: throw

/** \brief handle the reception of a ntudp_event_t::CNX_ESTABLISHED from itor
 */
bool	ntudp_client_t::recv_cnx_established(ntudp_full_t *ntudp_full)	throw()
{
	ntudp_err_t	ntudp_err;
	ntudp_event_t	ntudp_event;
	// copy the ntudp_full_t pointer
	this->ntudp_full = ntudp_full;
	// start the ntudp_full
	ntudp_err = ntudp_full->start(this, NULL);
	if( ntudp_err.failed() )	goto error;

	// logging to debug
	KLOG_DBG("create a full udp " << *ntudp_full);
	
	// notify a CNX_ESTABLISHED with a NULL pointer
	// - the NULL pointer is required as the ntudp_full is already contained in the ntudp_client_t
	ntudp_event = ntudp_event_t::build_cnx_established(NULL);
	// notify the event
	return notify_callback(ntudp_event);
	
error:;	KLOG_ERR("Unable to init ntudp_full due to " << ntudp_err );
	// delete ntudp_full and mark it unused
	nipmem_zdelete	ntudp_full;
	// TODO: solve this issue
	// - ntudp_event has no real cnx_refused as it has no connection establishement over the wire
	// - so how to notify this error ?
	// - note that this error is currently quite theorical - doing a ASSERT( 0 ) until it 
	//   a solution is found
	DBG_ASSERT( 0 );
	// notify a CNX_REFUSED
//	ntudp_event = ntudp_event_t::build_cnx_refused("Unable to init ntudp_full due to "+ ntudp_err.to_string());
	// notify the event
//	notify_callback(ntudp_event);
	// return dontkeep - as the notified has just been deleted
	return false;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:37,代码来源:neoip_ntudp_client.cpp

示例5: throw

/** \brief callback notified by \ref socket_full_t when to notify an event
 */
bool	router_resp_cnx_t::neoip_socket_full_event_cb(void *userptr, socket_full_t &cb_socket_full
							, const socket_event_t &socket_event)	throw()
{
	KLOG_ERR("enter event=" << socket_event);
	// sanity check - the event MUST be full_ok
	DBG_ASSERT( socket_event.is_full_ok() );
	
	// if the socket_event_t is fatal, autodelete this router_resp_cnx_t
	if( socket_event.is_fatal() ){
		nipmem_delete	this;
		return false;
	}
	
	// handle each possible events from its type
	switch( socket_event.get_value() ){
	case socket_event_t::RECVED_DATA:
			// handle the received packet
			return handle_recved_data(*socket_event.get_recved_data());
	case socket_event_t::NEW_MTU:
			// TODO FIXME to look at i am not sure about the mtu discovery state
			// - it depends on the socket_t semantique in fact
			DBG_ASSERT( 0 );		
	default:	DBG_ASSERT(0);
	}	
	// return 'tokeep'
	return true;	
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:29,代码来源:neoip_router_resp_cnx.cpp

示例6: throw

/** \brief Return the file_range_t to read - may return null if no data are available
 * 
 * - even in case of has_circularidx, the returned file_range_t.beg is always < than end()
 */
file_range_t	bt_httpo_full_t::range_to_read()	const throw()
{
	const bt_mfile_t &	bt_mfile	= bt_swarm->get_mfile();
	const bt_pieceavail_t &	pieceavail	= bt_swarm->local_pavail();
	file_size_t		chunk_beg	= current_pos();
	file_size_t		chunk_end	= m_range_tosend.end();
	// log to debug
	KLOG_ERR("enter chunk_beg=" << chunk_beg << " chunk_end=" << chunk_end);
	// sanity check - bt_io_read_t MUST NOT be in progress when this function is called
	DBG_ASSERT( bt_io_read == NULL );

	// if the socket_full_t xmitbuf has no freespace, return now
	if( socket_full->xmitbuf_freelen() == 0 )		return file_range_t();

	// if the chunk_beg is > than chunk_end, return now
	// - special case which means that all data has been delivered
	// - happen IIF not has_circularidx()
	if( chunk_beg > chunk_end )				return file_range_t();

	// compute pieceidx_beg of the chunk_beg
	size_t	pieceidx_beg	= bt_unit_t::totfile_to_pieceidx(chunk_beg, bt_mfile);
	// if pieceidx_beg is not available, return a null file_range_t
	if( !pieceavail.is_avail(pieceidx_beg) )		return file_range_t();
	
	// clamp the chunk_end with bt_mfile.totfile_size()
	// - usefull in case of has_circular_idx(), where m_range_tosend.end()==file_size_t::MAX
	chunk_end = std::min( chunk_end, bt_mfile.totfile_size()-1);

	// Compute pieceidx_end - the pieceidx of the last piece available
	size_t	pieceidx_max	= bt_unit_t::totfile_to_pieceidx(chunk_end, bt_mfile);
	size_t	pieceidx_end	= 0;
	for(size_t i = pieceidx_beg; i <= pieceidx_max; i++){
		if( pieceavail.is_unavail(i) )	break; 
		pieceidx_end	= i;
	}
	// clamp chunk_end to be the end of the last available pieceidx
	chunk_end	= std::min( chunk_end, bt_unit_t::pieceidx_to_pieceend(pieceidx_end, bt_mfile) );
	// clamp the chunk_end with socket_full->xmitbuf_freelen()
	if( chunk_end-chunk_beg+1 > socket_full->xmitbuf_freelen() )
		chunk_end	= chunk_beg + socket_full->xmitbuf_freelen() - 1;

	// log to debug
	KLOG_ERR("leave chunk_beg=" << chunk_beg << " chunk_end=" << chunk_end);

	// return the file_range
	return file_range_t(chunk_beg, chunk_end);
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:51,代码来源:neoip_bt_httpo_full.cpp

示例7: throw

/** \brief dnsgrab_t callback to received request	
 */
bool url_redir_t::neoip_dnsgrab_cb(void *cb_userptr, dnsgrab_request_t &request)	throw()
{
	// log the request
	KLOG_ERR("Received a request of " << request.get_request_name() 
			<< " From " << request.get_addr_family()
			<< " by " << (request.is_request_by_name() ? "name" : "address"));

	// if the request is NOT for AF_INET, report notfound
// TODO i fails in the libnss library and if a AF_INET6 comes it does retry in
// AF_INET, before it did.... fix the libnss
// - then reenable this line
	if( request.get_addr_family() != "AF_INET" )		goto report_notfound;
	// if the request is NOT by name, report false for NOT OK
	if( !request.is_request_by_name() )			goto report_notfound;
	// if the request is for a unknown name, report false for NOT OK
	if( get_hosturl(request.get_request_name()).empty() )	goto report_notfound;

	KLOG_ERR("request handled for " << request.get_request_name());

/*
 * if the name start by "neoip." or "buddy." AND
 * doesnt end by .fr .org .com etc...
 * 
 * then keep it
 */
//	char *	required_prefix[]	= { "neoip.", "buddy." };
//	char *	forbidden_suffix[]	= { ".org", ".com", ".net" };

 

	// set the reply with dummy data before notifying it
	request.get_reply_present()	= true;
	request.get_reply_name()	= "neoip.localhost";
//	request.get_reply_aliases().push_back("jerome.etienne");
//	request.get_reply_aliases().push_back("jeje");
	request.get_reply_addresses().push_back("127.0.0.2");
	
	// return tokeep
	return true;
	
report_notfound:
	// make the reply as not found
	request.get_reply_present()	= true;
	request.get_reply_name()	= std::string();	
	return true;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:48,代码来源:neoip_url_redir.cpp

示例8: throw

/** \brief callback notified with fdwatch_t has an condition to notify
 */
bool	asyncexe_t::stdout_fdwatch_cb( void *cb_userptr, const fdwatch_t &cb_fdwatch
						, const fdwatch_cond_t &fdwatch_cond )	throw()
{
	int	readlen		= 0;	
	// log the event
	KLOG_DBG("enter fdwatch_cond=" << fdwatch_cond);

	// if the condition is input
	if( fdwatch_cond.is_input() ){
		size_t	recv_max_len	= 16*1024;
		void *	buffer		= nipmem_alloca(recv_max_len);
		// read data in the socket
		readlen = read(stdout_fdwatch->get_fd(), buffer, recv_max_len);
		// if readlen < 0, treat it as error
		// - due to a weird bug in glib|linux, G_IO_ERR/HUP isnt received
		//   so there is a test if (cond.is_input() && readlen==0) fallthru
		//   and treat it as error
		if( readlen < 0 )	readlen = 0;
		// if some data have been read, add them to the stdout_barray
		if( readlen > 0 )	stdout_barray.append(buffer, readlen);
		// log to debug
		KLOG_DBG("readlen=" << readlen);
	}

	// handle a connection error
	if( fdwatch_cond.is_error() || (fdwatch_cond.is_input() && readlen == 0) ){
		// wait for the pid to get the result
		int	status	= 0;
#ifndef _WIN32
		int	ret	= waitpid(childpid, &status, 0);
		if( ret == -1 && errno == ECHILD )	status = 0;
		else if( ret != childpid )		status = -1;
		// extract the return status
		status		= WEXITSTATUS(status);
#endif
		// log to debug
		KLOG_ERR("childpid=" << childpid << " return status=" << status );
		KLOG_ERR("received error. now recved_data=" << stdout_barray.to_datum() );
		// else notify the caller with a success
		return notify_callback(libsess_err_t::OK, stdout_barray, status);
	}

	// return tokeep
	return true;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:47,代码来源:neoip_asyncexe.cpp

示例9: throw

/** \brief Test function
 */
nunit_res_t	amf0_testclass_t::general(const nunit_testclass_ftor_t &testclass_ftor) throw()
{
	// log to debug
	KLOG_DBG("enter");

	// setup some dvar_t to do a comparison
	dvar_t	dvar0	= dvar_str_t("_result");
	dvar_t	dvar1	= dvar_dbl_t(1);
	dvar_t	dvar2	= dvar_nil_t();
	dvar_t	dvar3	= dvar_map_t()
			.insert("level"		, dvar_str_t("status"))
			.insert("description"	, dvar_str_t("Connection succeeded."))
			.insert("code"		, dvar_str_t("NetConnection.Connect.Success"));



	// build amf0_data from a dvar_t
	bytearray_t	amf0_data;
	amf0_build_t::to_amf0(dvar0, amf0_data);
	amf0_build_t::to_amf0(dvar1, amf0_data);
	amf0_build_t::to_amf0(dvar2, amf0_data);
	amf0_build_t::to_amf0(dvar3, amf0_data);
	// log to debug
	KLOG_ERR("dvar.to_amf0=" << amf0_data);

	// parse the
	flv_err_t	flv_err;
	dvar_t		dvar;
	flv_err		= amf0_parse_t::amf_to_dvar(amf0_data, dvar);
	NUNIT_ASSERT( flv_err.succeed() );
	NUNIT_ASSERT( dvar == dvar0 );
	flv_err		= amf0_parse_t::amf_to_dvar(amf0_data, dvar);
	NUNIT_ASSERT( flv_err.succeed() );
	NUNIT_ASSERT( dvar == dvar1 );
	flv_err		= amf0_parse_t::amf_to_dvar(amf0_data, dvar);
	NUNIT_ASSERT( flv_err.succeed() );
	NUNIT_ASSERT( dvar == dvar2 );
	flv_err		= amf0_parse_t::amf_to_dvar(amf0_data, dvar);
	NUNIT_ASSERT( flv_err.succeed() );
	NUNIT_ASSERT( dvar == dvar3 );
	KLOG_ERR("dvar=" << dvar);

	// report no error
	return NUNIT_RES_OK;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:47,代码来源:neoip_amf0_nunit.cpp

示例10: throw

/** \brief callback called when the timeout_t expire
 */
bool 	router_peer_testclass_t::neoip_timeout_expire_cb(void *userptr, timeout_t &cb_timeout)	throw()
{
	// log to debug
	KLOG_ERR("enter");
	// stop the timeout
	bstrap_timeout.stop();	
	// report the result
	return nunit_ftor(NUNIT_RES_OK);
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:11,代码来源:neoip_router_peer_nunit.cpp

示例11: throw

/** \brief Autodelete the object and return false to ease readability
 */
bool	http_sresp_cnx_t::autodelete(const std::string &reason)		throw()
{
	// if there is a reason, log it
	if( !reason.empty() )	KLOG_ERR("autodelete due to " << reason);	
	// delete the object itself
	nipmem_delete	this;
	// return dontkeep for convenience
	return false;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:11,代码来源:neoip_http_sresp_cnx.cpp

示例12: throw

/** \brief Used by kad_*_t internal to notify an echoed local ip_addr_t
 * 
 * - in practice this is used only by kad_ping_rpc_t as PING_REPLY does
 *   include the echoed local ip_addr_t
 * - this function is used to keep the local_ipaddr_pview() uptodate
 * - WARNING: this function MUST NOT notify any callback
 *   - this function is called INSYNC inside the kad_ping_rpc_t callback
 *   - so very low level
 *   - if there are notification to be made, use a zerotimer_t
 */
void	kad_listener_t::notify_echoed_local_ipaddr(const ip_addr_t &echoed_ipaddr
				, const kad_addr_t &remote_addr)	throw()
{
	// log to debug
	KLOG_ERR("enter echoed_ipaddr=" << echoed_ipaddr << " remote_kaddr=" << remote_addr);
	// if remote_addr.oaddr().ipaddr().is_public() is not true, do nothing
	// - as it mean the echoed_ipaddr is not a public view
	if( !remote_addr.oaddr().ipaddr().is_public() )	return;
	// if echoed_ipaddr is not public,, do nothing
	if( !echoed_ipaddr.is_public() )		return;

	// log to debug
	KLOG_ERR("notifying local_ipaddr_pview=" << echoed_ipaddr << " to ndiag_watch_t");

	// notify it to the ndiag_watch_t	
	ndiag_watch_t *	ndiag_watch	= ndiag_watch_get();
	ndiag_watch->notify_ipaddr_pview(echoed_ipaddr);
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:28,代码来源:neoip_kad_listener.cpp

示例13: throw

/** \brief init the gcry_md_hd
 * 
 * - this init is assumed to be done everytime it is done for ciph_type
 */
bool skey_ciph_t::init_gcry_hd()				throw()
{
	const skey_ciph_algo_t &algo	= ciph_type.get_algo();
	// get the algo from the algo_str
	int gcry_cipher_algo = gcry_cipher_map_name( algo.to_string().c_str() );
	// if the algo_str isnt supported, throw an exception
	if( !gcry_cipher_algo ){
		KLOG_ERR("Can't map " << algo.to_string() << " in gcrypt cipher_map_name");
		return true;
	}
	// open the gcrypt cipher
	if( gcry_cipher_open(&gcry_cipher_hd, gcry_cipher_algo, get_gcry_cipher_mode(), GCRY_CIPHER_SECURE) ){
		KLOG_ERR("Can't open " << ciph_type << " in gcrypt cipher_open");
		return true;
	}
	// return false if no error occured
	return false;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:22,代码来源:neoip_skey_ciph.cpp

示例14: throw

/** \brief callback notified by \ref nudp_t receive a packet
 */
bool	nudp_testclass_t::neoip_inet_nudp_event_cb(void *cb_userptr, nudp_t &cb_nudp, pkt_t &pkt
					, const ipport_addr_t &local_addr
					, const ipport_addr_t &remote_addr)	throw()
{
	// log to debug
	KLOG_ERR("enter local_addr=" << local_addr << " remote_addr=" << remote_addr
					<< " pkt=" << pkt );
	// return tokeep	
	return true;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:12,代码来源:neoip_nudp_nunit.cpp

示例15: throw

/** \brief Test function
 */
nunit_res_t	obj_factory_testclass_t::general(const nunit_testclass_ftor_t &testclass_ftor) throw()
{
	// log to debug
	KLOG_ERR("enter");

	// insert all the factory_product_t
	FACTORY_PRODUCT_INSERT	(nunit_obj_factory_plant, std::string, nunit_obj_factory_product_base_t
						, "two", nunit_obj_factory_product_2);
	FACTORY_PRODUCT_INSERT	(nunit_obj_factory_plant, std::string, nunit_obj_factory_product_base_t
						, "one", nunit_obj_factory_product_1);

	// test if the factory_product_t have been inserted
	std::vector<std::string>	key_list = nunit_obj_factory_plant->get_key_list();
	for(size_t i = 0; i < key_list.size(); i++ ){
		KLOG_ERR("i=" << i << " key=" << key_list[i]);
	}
	// return no error
	return NUNIT_RES_OK;
}
开发者ID:jeromeetienne,项目名称:neoip,代码行数:21,代码来源:neoip_obj_factory_nunit.cpp


注:本文中的KLOG_ERR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。