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;
static FILE *default_log_stream;
/**
- * This global structure stores some informations about the message
+ * This global structure stores some information about the message
* that is currently being processed by one lcore
*/
struct log_cur_msg {
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)
{
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)
{
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)
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 */