eal: change several log levels matching a regexp
[dpdk.git] / lib / librte_eal / common / eal_common_log.c
index 9032621..d026893 100644 (file)
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <regex.h>
 
 #include <rte_eal.h>
 #include <rte_log.h>
@@ -132,6 +133,26 @@ rte_log_set_level(uint32_t type, uint32_t level)
        return 0;
 }
 
+/* set level */
+int
+rte_log_set_level_regexp(const char *pattern, uint32_t level)
+{
+       regex_t r;
+       size_t i;
+
+       if (level > RTE_LOG_DEBUG)
+               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)
+                       rte_logs.dynamic_types[i].loglevel = level;
+       }
+
+       return 0;
+}
+
 /* get the current loglevel for the message beeing processed */
 int rte_log_cur_msg_loglevel(void)
 {