From: openocd-gerrit <ope...@us...> - 2025-08-02 13:01:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 374a1f99832cbeb5eb345ed6c497b7abe3850f68 (commit) from eea3c568f9bdede39ee7e1446aeeb07d073d0ba8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 374a1f99832cbeb5eb345ed6c497b7abe3850f68 Author: Marc Schink <de...@za...> Date: Sun Jul 13 09:05:40 2025 +0200 helper/log: Rework 'debug_level' command The patch changes the following: - Use correct return value ERROR_COMMAND_ARGUMENT_INVALID is case an invalid debug level is provided. - Do not echo the selected debug level. - Remove the 'debug_level: ' prefix when the debug level is shown. This makes processing via Tcl easier. - Use command_print() in order to provide the error message to the caller. Change-Id: Ida84a58c61060497fc36a1926eec7dd30c66cd72 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/8996 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 90ed9d3b6..b188f2175 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -810,8 +810,7 @@ itself), use the @option{-d} command line switch. This sets the @option{debug_level} to "3", outputting the most information, including debug messages. The default setting is "2", outputting only informational messages, warnings and errors. You can also change this -setting from within a telnet or gdb session using @command{debug_level<n>} -(@pxref{debuglevel,,debug_level}). +setting from within a telnet or gdb session using @ref{debuglevel,,@command{debug_level}}. You can redirect all output from the server to a file using the @option{-l <logfile>} switch. @@ -9329,10 +9328,10 @@ will proceed to quit. @end deffn @anchor{debuglevel} -@deffn {Command} {debug_level} [n] +@deffn {Command} {debug_level} [number] @cindex message level -Display debug level. -If @var{n} (from 0..4) is provided, then set it to that level. +Without arguments it displays the current debug level. +If @var{number} (from 0..4) is provided, then set it to that level. This affects the kind of messages sent to the server log. Level 0 is error messages only; level 1 adds warnings; diff --git a/src/helper/log.c b/src/helper/log.c index 8f7ab0039..d8c4e09ac 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -207,18 +207,19 @@ void log_printf_lf(enum log_levels level, COMMAND_HANDLER(handle_debug_level_command) { - if (CMD_ARGC == 1) { + if (!CMD_ARGC) { + command_print(CMD, "%i", debug_level); + } else if (CMD_ARGC == 1) { int new_level; COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], new_level); if ((new_level > LOG_LVL_DEBUG_IO) || (new_level < LOG_LVL_SILENT)) { - LOG_ERROR("level must be between %d and %d", LOG_LVL_SILENT, LOG_LVL_DEBUG_IO); - return ERROR_COMMAND_SYNTAX_ERROR; + command_print(CMD, "level must be between %d and %d", LOG_LVL_SILENT, LOG_LVL_DEBUG_IO); + return ERROR_COMMAND_ARGUMENT_INVALID; } debug_level = new_level; - } else if (CMD_ARGC > 1) + } else { return ERROR_COMMAND_SYNTAX_ERROR; - - command_print(CMD, "debug_level: %i", debug_level); + } return ERROR_OK; } @@ -261,11 +262,11 @@ static const struct command_registration log_command_handlers[] = { .name = "debug_level", .handler = handle_debug_level_command, .mode = COMMAND_ANY, - .help = "Sets the verbosity level of debugging output. " + .help = "Sets or display the verbosity level of debugging output. " "0 shows errors only; 1 adds warnings; " "2 (default) adds other info; 3 adds debugging; " "4 adds extra verbose debugging.", - .usage = "number", + .usage = "[number]", }, COMMAND_REGISTRATION_DONE }; ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 9 ++++----- src/helper/log.c | 17 +++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) hooks/post-receive -- Main OpenOCD repository |