DPDK patches and discussions
 help / color / mirror / Atom feed
From: Elza Mathew <elza.mathew@intel.com>
To: jingjing.wu@intel.com, wenzhuo.lu@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2] app/testpmd: change log level at run time
Date: Mon, 22 Jan 2018 14:09:45 -0800	[thread overview]
Message-ID: <1516658985-30392-1-git-send-email-elza.mathew@intel.com> (raw)
In-Reply-To: <1516400350-96747-1-git-send-email-elza.mathew@intel.com>

Introduced a run time command to change the
log level for a given log type. Added the
necessary documentation.

V2: Changed the position of the command in
the documentation since generic commands
are placed at the beginning.

Signed-off-by: Elza Mathew <elza.mathew@intel.com>
---
 app/test-pmd/cmdline.c                      | 53 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 19 +++++++++++
 2 files changed, 72 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9f12c0f..c9b2b57 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -274,6 +274,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set verbose (level)\n"
 			"    Set the debug verbosity level X.\n\n"
 
+			"set log global|(type) (level)\n"
+			"    Set the log level.\n\n"
+
 			"set nbport (num)\n"
 			"    Set number of ports.\n\n"
 
@@ -3055,6 +3058,55 @@ static void cmd_set_parsed(void *parsed_result,
 	},
 };
 
+/* *** SET LOG LEVEL CONFIGURATION *** */
+
+struct cmd_set_log_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t log;
+	cmdline_fixed_string_t type;
+	uint32_t level;
+};
+
+static void
+cmd_set_log_parsed(void *parsed_result,
+		   __attribute__((unused)) struct cmdline *cl,
+		   __attribute__((unused)) void *data)
+{
+	struct cmd_set_log_result *res;
+	int ret;
+
+	res = parsed_result;
+	if (!strcmp(res->type, "global"))
+		rte_log_set_global_level(res->level);
+	else {
+		ret = rte_log_set_level_regexp(res->type, res->level);
+		if (ret < 0)
+			printf("Unable to set log level\n");
+	}
+}
+
+cmdline_parse_token_string_t cmd_set_log_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
+cmdline_parse_token_string_t cmd_set_log_log =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
+cmdline_parse_token_string_t cmd_set_log_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
+cmdline_parse_token_num_t cmd_set_log_level =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
+
+cmdline_parse_inst_t cmd_set_log = {
+	.f = cmd_set_log_parsed,
+	.data = NULL,
+	.help_str = "set log global|<type> <level>",
+	.tokens = {
+		(void *)&cmd_set_log_set,
+		(void *)&cmd_set_log_log,
+		(void *)&cmd_set_log_type,
+		(void *)&cmd_set_log_level,
+		NULL,
+	},
+};
+
 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
 
 struct cmd_set_txpkts_result {
@@ -16026,6 +16078,7 @@ struct cmd_cmdfile_result {
 	(cmdline_parse_inst_t *)&cmd_set_link_down,
 	(cmdline_parse_inst_t *)&cmd_reset,
 	(cmdline_parse_inst_t *)&cmd_set_numbers,
+	(cmdline_parse_inst_t *)&cmd_set_log,
 	(cmdline_parse_inst_t *)&cmd_set_txpkts,
 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index d8c9ef0..f7a709f 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -448,6 +448,25 @@ Set the debug verbosity level::
 
 Currently the only available levels are 0 (silent except for error) and 1 (fully verbose).
 
+set log
+~~~~~~~
+
+Set the log level for a log type::
+
+	testpmd> set log global|(type) (level)
+
+Where:
+
+* ``type`` is the log name.
+
+* ``level`` is the log level.
+
+For example, to change the global log level::
+	testpmd> set log global (level)
+
+Regexes can also be used for type. To change log level of user1, user2 and user3::
+	testpmd> set log user[1-3] (level)
+
 set nbport
 ~~~~~~~~~~
 
-- 
1.9.1

  parent reply	other threads:[~2018-01-22 22:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 22:19 [dpdk-dev] [PATCH] " Elza Mathew
2018-01-20  1:23 ` Ferruh Yigit
2018-01-20 14:29 ` Thomas Monjalon
2018-01-22 22:09 ` Elza Mathew [this message]
2018-01-31 22:15   ` [dpdk-dev] [PATCH v2] " Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516658985-30392-1-git-send-email-elza.mathew@intel.com \
    --to=elza.mathew@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).