version: 18.05-rc3
[dpdk.git] / lib / librte_eal / common / eal_common_options.c
index bf4296b..ecebb29 100644 (file)
@@ -27,6 +27,7 @@
 #include "eal_internal_cfg.h"
 #include "eal_options.h"
 #include "eal_filesystem.h"
+#include "eal_private.h"
 
 #define BITS_PER_HEX 4
 #define LCORE_OPT_LST 1
@@ -958,19 +959,23 @@ eal_parse_log_priority(const char *level)
 static int
 eal_parse_log_level(const char *arg)
 {
-       char *str, *type, *level;
+       const char *pattern = NULL;
+       const char *regex = NULL;
+       char *str, *level;
        int priority;
 
        str = strdup(arg);
        if (str == NULL)
                return -1;
 
-       if (strchr(str, ',') == NULL) {
-               type = NULL;
-               level = str;
+       if ((level = strchr(str, ','))) {
+               regex = str;
+               *level++ = '\0';
+       } else if ((level = strchr(str, ':'))) {
+               pattern = str;
+               *level++ = '\0';
        } else {
-               type = strsep(&str, ",");
-               level = strsep(&str, ",");
+               level = str;
        }
 
        priority = eal_parse_log_priority(level);
@@ -979,35 +984,24 @@ eal_parse_log_level(const char *arg)
                goto fail;
        }
 
-       if (type == NULL) {
-               rte_log_set_global_level(priority);
-       } else if (rte_log_set_level_regexp(type, priority) < 0) {
-               fprintf(stderr, "cannot set log level %s,%d\n",
-                       type, priority);
-               goto fail;
-       } else {
-               struct rte_eal_opt_loglevel *opt_ll;
-
-               /*
-                * Save the type (regexp string) and the loglevel
-                * in the global storage so that it could be used
-                * to configure dynamic logtypes which are absent
-                * at the moment of EAL option processing but may
-                * be registered during runtime.
-                */
-               opt_ll = malloc(sizeof(*opt_ll));
-               if (opt_ll == NULL)
+       if (regex) {
+               if (rte_log_set_level_regexp(regex, priority) < 0) {
+                       fprintf(stderr, "cannot set log level %s,%d\n",
+                               pattern, priority);
                        goto fail;
-
-               opt_ll->re_type = strdup(type);
-               if (opt_ll->re_type == NULL) {
-                       free(opt_ll);
+               }
+               if (rte_log_save_regexp(regex, priority) < 0)
+                       goto fail;
+       } else if (pattern) {
+               if (rte_log_set_level_pattern(pattern, priority) < 0) {
+                       fprintf(stderr, "cannot set log level %s:%d\n",
+                               pattern, priority);
                        goto fail;
                }
-
-               opt_ll->level = priority;
-
-               TAILQ_INSERT_HEAD(&opt_loglevel_list, opt_ll, next);
+               if (rte_log_save_pattern(pattern, priority) < 0)
+                       goto fail;
+       } else {
+               rte_log_set_global_level(priority);
        }
 
        free(str);
@@ -1372,7 +1366,7 @@ eal_common_usage(void)
               "  --"OPT_PROC_TYPE"         Type of this process (primary|secondary|auto)\n"
               "  --"OPT_SYSLOG"            Set syslog facility\n"
               "  --"OPT_LOG_LEVEL"=<int>   Set global log level\n"
-              "  --"OPT_LOG_LEVEL"=<type-regexp>,<int>\n"
+              "  --"OPT_LOG_LEVEL"=<type-match>:<int>\n"
               "                      Set specific log level\n"
               "  -v                  Display version information on startup\n"
               "  -h, --help          This help\n"