예제 #1
0
/*
 * Generates a log message The message will be sent in the stream
 * defined by the previous call to rte_openlog_stream().
 * No need to check level here, done by rte_vlog().
 */
int
rte_log(uint32_t level, uint32_t logtype, const char *format, ...)
{
	va_list ap;
	int ret;

	va_start(ap, format);
	ret = rte_vlog(level, logtype, format, ap);
	va_end(ap);
	return ret;
}
예제 #2
0
/* call abort(), it will generate a coredump if enabled */
void __rte_panic(const char *funcname, const char *format, ...)
{
	va_list ap;

	rte_log(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, "PANIC in %s():\n", funcname);
	va_start(ap, format);
	rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap);
	va_end(ap);
	rte_dump_stack();
	rte_dump_registers();
	abort();
}
/*
 * vr_uvhost_log - logs user space vhost messages to a file.
 */
void
vr_uvhost_log(const char *format, ...)
{
    va_list args;

    if (RTE_LOGTYPE_UVHOST & rte_logs.type) {
        char buf[VR_DPDK_STR_BUF_SZ] = "UVHOST: ";

        strncat(buf, format, sizeof(buf) - strlen(buf) - 1);
        buf[sizeof(buf) - 1] = '\0';

        va_start(args, format);
        rte_vlog(RTE_LOG_INFO, RTE_LOGTYPE_UVHOST, buf, args);
        va_end(args);
    }
}
예제 #4
0
/*
 * Like rte_panic this terminates the application. However, no traceback is
 * provided and no core-dump is generated.
 */
void
rte_exit(int exit_code, const char *format, ...)
{
	va_list ap;

	if (exit_code != 0)
		RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n"
				"  Cause: ", exit_code);

	va_start(ap, format);
	rte_vlog(RTE_LOG_CRIT, RTE_LOGTYPE_EAL, format, ap);
	va_end(ap);

#ifndef RTE_EAL_ALWAYS_PANIC_ON_ERROR
	exit(exit_code);
#else
	rte_dump_stack();
	rte_dump_registers();
	abort();
#endif
}
예제 #5
0
int
rte_log_ratelimit(uint32_t level, uint32_t logtype, const char *format, ...)
{
	struct log_ratelimit_state *lrs;
	int ratelimit_level = rte_log_get_level(logtype);
	if (unlikely(ratelimit_level < 0))
		return -1;

	lrs = &log_ratelimit_states[rte_lcore_id()];
	if (level <= (typeof(level))ratelimit_level &&
			log_ratelimit_allow(lrs)) {
		int ret;
		va_list ap;

		va_start(ap, format);
		ret = rte_vlog(level, logtype, format, ap);
		va_end(ap);

		return ret;
	}

	return 0;
}