X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_log.c;h=8835c8fff8973ec330c8520268289f7fa16d3e2a;hb=8b9dae0cc3f870c61610800427d28c439edff7a7;hp=c0efd5214fa99914f02f75044d78d160c77980fd;hpb=baf023a8edfa70122c96eefa59a8bbd940d034bc;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index c0efd5214f..8835c8fff8 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -29,7 +29,7 @@ struct rte_eal_opt_loglevel { TAILQ_ENTRY(rte_eal_opt_loglevel) next; /** Compiled regular expression obtained from the option */ regex_t re_match; - /** Glob match string option */ + /** Globbing pattern option */ char *pattern; /** Log level value obtained from the option */ uint32_t level; @@ -112,6 +112,24 @@ rte_log_get_level(uint32_t type) return rte_logs.dynamic_types[type].loglevel; } +bool +rte_log_can_log(uint32_t logtype, uint32_t level) +{ + int log_level; + + if (level > rte_log_get_global_level()) + return false; + + log_level = rte_log_get_level(logtype); + if (log_level < 0) + return false; + + if (level > (uint32_t)log_level) + return false; + + return true; +} + int rte_log_set_level(uint32_t type, uint32_t level) { @@ -189,7 +207,7 @@ int rte_log_save_regexp(const char *regex, int tmp) return rte_log_save_level(tmp, regex, NULL); } -/* set log level based on glob (file match) pattern */ +/* set log level based on globbing pattern */ int rte_log_set_level_pattern(const char *pattern, uint32_t level) { @@ -302,7 +320,7 @@ rte_log_register_type_and_pick_level(const char *name, uint32_t level_def) continue; if (opt_ll->pattern) { - if (fnmatch(opt_ll->pattern, name, 0)) + if (fnmatch(opt_ll->pattern, name, 0) == 0) level = opt_ll->level; } else { if (regexec(&opt_ll->re_match, name, 0, NULL, 0) == 0) @@ -417,11 +435,9 @@ rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) FILE *f = rte_log_get_stream(); int ret; - if (level > rte_logs.level) - return 0; if (logtype >= rte_logs.dynamic_types_len) return -1; - if (level > rte_logs.dynamic_types[logtype].loglevel) + if (!rte_log_can_log(logtype, level)) return 0; /* save loglevel and logtype in a global per-lcore variable */