X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_log.c;h=0e3b9320954fc9d1bf3e8c47709ea05fdebb91e5;hb=f4709b40940395b29521d6e5e36b58c516a74b29;hp=ddc99bda7737b74e5d4852d92df62203cd26fb02;hpb=75915f1bde6aca44b76d57184adaee876d7ee257;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index ddc99bda77..0e3b932095 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -112,6 +112,15 @@ rte_get_log_level(void) return rte_log_get_global_level(); } +int +rte_log_get_level(uint32_t type) +{ + if (type >= rte_logs.dynamic_types_len) + return -1; + + return rte_logs.dynamic_types[type].loglevel; +} + /* Set global log type */ __rte_deprecated void rte_set_log_type(uint32_t type, int enable) @@ -159,23 +168,27 @@ rte_log_set_level_regexp(const char *pattern, uint32_t level) if (level > RTE_LOG_DEBUG) return -1; + if (regcomp(&r, pattern, 0) != 0) + return -1; + for (i = 0; i < rte_logs.dynamic_types_len; i++) { if (rte_logs.dynamic_types[i].name == NULL) continue; - if (regexec(&r, pattern, 0, NULL, 0) == 0) + if (regexec(&r, rte_logs.dynamic_types[i].name, 0, + NULL, 0) == 0) rte_logs.dynamic_types[i].loglevel = level; } return 0; } -/* get the current loglevel for the message beeing processed */ +/* get the current loglevel for the message being processed */ int rte_log_cur_msg_loglevel(void) { return RTE_PER_LCORE(log_cur_msg).loglevel; } -/* get the current logtype for the message beeing processed */ +/* get the current logtype for the message being processed */ int rte_log_cur_msg_logtype(void) { return RTE_PER_LCORE(log_cur_msg).logtype; @@ -282,6 +295,12 @@ rte_log_init(void) { uint32_t i; +#if RTE_LOG_LEVEL >= RTE_LOG_DEBUG + rte_log_set_global_level(RTE_LOG_INFO); +#else + rte_log_set_global_level(RTE_LOG_LEVEL); +#endif + rte_logs.dynamic_types = calloc(RTE_LOGTYPE_FIRST_EXT_ID, sizeof(struct rte_log_dynamic_type)); if (rte_logs.dynamic_types == NULL) @@ -299,6 +318,7 @@ static const char * loglevel_to_string(uint32_t level) { switch (level) { + case 0: return "disabled"; case RTE_LOG_EMERG: return "emerg"; case RTE_LOG_ALERT: return "alert"; case RTE_LOG_CRIT: return "critical";