From: Alan T. DeKok Date: Fri, 6 Jul 2018 17:27:59 +0000 (-0400) Subject: add commands to show / set debug level X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98c1102dbc385d842a1d16e49ba9bbd22de69bc9;p=thirdparty%2Ffreeradius-server.git add commands to show / set debug level --- diff --git a/src/main/radmin.c b/src/main/radmin.c index a3eabbbcc5e..1700dd62930 100644 --- a/src/main/radmin.c +++ b/src/main/radmin.c @@ -378,6 +378,25 @@ static int cmd_stats_memory(FILE *fp, FILE *fp_err, UNUSED void *ctx, fr_cmd_inf return -1; } +static int cmd_set_debug_level(FILE *fp, FILE *fp_err, UNUSED void *ctx, fr_cmd_info_t const *info) +{ + int level = atoi(info->argv[0]); + + if ((level < 0) || level > 5) { + fprintf(fp_err, "Invalid debug level '%s'", info->argv[0]); + return -1; + } + + rad_debug_lvl = fr_debug_lvl = level; + return 0; +} + +static int cmd_show_debug_level(FILE *fp, FILE *fp_err, UNUSED void *ctx, UNUSED fr_cmd_info_t const *info) +{ + fprintf(fp, "%d\n", rad_debug_lvl); + return 0; +} + #ifdef CMD_TEST static int cmd_test(FILE *fp, UNUSED FILE *fp_err, UNUSED void *ctx, fr_cmd_info_t const *info) { @@ -403,6 +422,16 @@ static char const *stats_parents[] = { NULL }; +static char const *set_debug_parents[] = { + "set", "debug", + NULL +}; + +static char const *show_debug_parents[] = { + "show", "debug", + NULL +}; + static fr_cmd_table_t cmd_table[] = { { .syntax = "exit", @@ -444,6 +473,22 @@ static fr_cmd_table_t cmd_table[] = { .parents = stats_parents, }, + { + .syntax = "level INTEGER", + .func = cmd_set_debug_level, + .help = "set debug level INTEGER", + .read_only = true, + .parents = set_debug_parents, + }, + + { + .syntax = "level", + .func = cmd_show_debug_level, + .help = "show debug level", + .read_only = false, + .parents = show_debug_parents, + }, + CMD_TABLE_END };