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 <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8996 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
committed by
Antonio Borneo
parent
eea3c568f9
commit
374a1f9983
@@ -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;
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user