|
From: <zw...@ma...> - 2009-06-12 03:40:01
|
Author: zwelch
Date: 2009-06-12 03:39:57 +0200 (Fri, 12 Jun 2009)
New Revision: 2208
Modified:
trunk/src/helper/log.c
Log:
Simplify and improve handle_debug_level_comamnd:
- Bug fix: Return a syntax error if more than one argument is given.
- Bug fix: Use new parse_uint helper ensure debug_level parses correctly.
- Change: Display the debug_level after it has been set.
- Simplify bounds checking of debug_level.
Modified: trunk/src/helper/log.c
===================================================================
--- trunk/src/helper/log.c 2009-06-12 01:39:51 UTC (rev 2207)
+++ trunk/src/helper/log.c 2009-06-12 01:39:57 UTC (rev 2208)
@@ -194,18 +194,19 @@
*/
int handle_debug_level_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- if (argc == 0)
- command_print(cmd_ctx, "debug_level: %i", debug_level);
+ if (argc == 1)
+ {
+ unsigned new_level;
+ int retval = parse_uint(args[0], &new_level);
+ if (ERROR_OK != retval)
+ return retval;
+ debug_level = MIN(new_level, LOG_LVL_DEBUG);
+ }
+ else if (argc > 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc > 0)
- debug_level = strtoul(args[0], NULL, 0);
+ command_print(cmd_ctx, "debug_level: %i", debug_level);
- if (debug_level < 0)
- debug_level = 0;
-
- if (debug_level > 3)
- debug_level = 3;
-
if (debug_level >= LOG_LVL_DEBUG && server_use_pipes == 1)
{
/* if we are enabling debug info then we need to write to a log file
|