ikev2: better logging
[vpp.git] / src / plugins / ikev2 / ikev2_cli.c
index 0933667..2ca1a5c 100644 (file)
@@ -589,6 +589,42 @@ ikev2_cli_reference (void)
 {
 }
 
+static clib_error_t *
+ikev2_set_log_level_command_fn (vlib_main_t * vm,
+                               unformat_input_t * input,
+                               vlib_cli_command_t * cmd)
+{
+  unformat_input_t _line_input, *line_input = &_line_input;
+  u8 log_level = IKEV2_LOG_NONE;
+  clib_error_t *error = 0;
+
+  /* Get a line of input. */
+  if (!unformat_user (input, unformat_line_input, line_input))
+    return 0;
+
+  if (!unformat (line_input, "%d", &log_level))
+    {
+      error = clib_error_return (0, "unknown input '%U'",
+                                format_unformat_error, line_input);
+      goto done;
+    }
+  int rc = ikev2_set_log_level (log_level);
+  if (rc < 0)
+    error = clib_error_return (0, "setting log level failed!");
+
+done:
+  unformat_free (line_input);
+  return error;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (ikev2_set_log_level_command, static) = {
+  .path = "ikev2 set logging level",
+  .function = ikev2_set_log_level_command_fn,
+  .short_help = "ikev2 set logging level <0-5>",
+};
+/* *INDENT-ON* */
+
 /*
  * fd.io coding-style-patch-verification: ON
  *