aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/cli.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2021-02-17 10:25:18 -0500
committerFlorin Coras <florin.coras@gmail.com>2021-02-18 15:42:03 +0000
commit3d0e0d155de32eb215a7ca675dfca5a28f8837cc (patch)
tree9e3292061613203a4e21a955f90951ad689dab1e /src/vlib/cli.c
parent8fb22fdade3633f1116c44b913934fcffe0d861b (diff)
vlib: add a "vpplog" debug CLI
To add arbitrary text to the vlib log. Combines nicely with comment/uncomment and the macro expander: define MY_FEATURE uncomment # or comment ... $(MY_FEATURE) { vpplog { My feature was enabled } } Type: improvement Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Ia019f0a8fa670d8593ae01595f5ef410796e5b1c
Diffstat (limited to 'src/vlib/cli.c')
-rw-r--r--src/vlib/cli.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index e1db95d6af9..85ec6cbc43c 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -472,6 +472,23 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
vec_free (string);
}
+ else if (unformat (input, "vpplog %v", &string))
+ {
+ int i;
+ /*
+ * Delete leading whitespace, so "vpplog { this and that }"
+ * and "vpplog this" line up nicely.
+ */
+ for (i = 0; i < vec_len (string); i++)
+ if (string[i] != ' ')
+ break;
+ if (i > 0)
+ vec_delete (string, i, 0);
+
+ vlib_log_notice (cm->log, "CLI: %v", string);
+ vec_free (string);
+ }
+
else if (unformat (input, "uncomment %U",
unformat_vlib_cli_sub_input, &sub_input))
{
@@ -1817,6 +1834,9 @@ vlib_cli_init (vlib_main_t * vm)
return error;
cmd = cmd->next_cli_command;
}
+
+ cm->log = vlib_log_register_class_rate_limit (
+ "cli", "log", 0x7FFFFFFF /* aka no rate limit */);
return error;
}