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} -(@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 } 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 };