1、日志等级
/* Can't use 0, as it gives compiler warnings */
#define RTE_LOG_EMERG 1U /**< System is unusable. */
#define RTE_LOG_ALERT 2U /**< Action must be taken immediately. */
#define RTE_LOG_CRIT 3U /**< Critical conditions. */
#define RTE_LOG_ERR 4U /**< Error conditions. */
#define RTE_LOG_WARNING 5U /**< Warning conditions. */
#define RTE_LOG_NOTICE 6U /**< Normal but significant condition. */
#define RTE_LOG_INFO 7U /**< Informational. */
#define RTE_LOG_DEBUG 8U /**< Debug-level messages. */
2、设置日志等级函数
rte_set_log_level();
eg:rte_set_log_level(RTE_LOG_DEBUG ); 设置调试日志,默认直接打印在终端上
在dpdk库里,rte_set_log_level()在rte_eal_init()里调用
3、日志输出到文件
rte_openlog_stream(fd);
注意fd是文件描述符,得自己使用fopen(log_file, "a+")创建
4、dpdk函数库运行参数
log-level [数字]
eg: ./build/l2fwd -c 3 -n 4 --log-level 8
5、注意事项
在有的使用dpdk库的开源程序里,比如dvps, 在dvps.conf文件里
global_defs {
log_level WARNING
! log_file /var/log/dpvs.log
}
设置了日志等级,你在运行时使用--log-level 8可能不会生效,原因是dvps代码在执行rte_eal_init()函数后调用了rte_set_log_level,日志等级肯定是以最后调用的为准了