diff options
Diffstat (limited to 'ctdb/tools/ctdb.c')
-rw-r--r-- | ctdb/tools/ctdb.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index b6ca332266..fc34e99fd6 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -2299,19 +2299,34 @@ static int control_setreclock(struct ctdb_context *ctdb, int argc, const char ** */ static int control_setdebug(struct ctdb_context *ctdb, int argc, const char **argv) { - int ret; + int i, ret; int32_t level; - if (argc < 1) { - usage(); + if (argc == 0) { + printf("You must specify the debug level. Valid levels are:\n"); + for (i=0;i<ARRAY_SIZE(debug_levels);i++) { + printf("%s (%d)\n", debug_levels[i].description, debug_levels[i].level); + } + + return 0; } - if (isalpha(argv[0][0])) { + if (isalpha(argv[0][0]) || argv[0][0] == '-') { level = get_debug_by_desc(argv[0]); } else { level = strtol(argv[0], NULL, 0); } + for (i=0;i<ARRAY_SIZE(debug_levels);i++) { + if (level == debug_levels[i].level) { + break; + } + } + if (i == ARRAY_SIZE(debug_levels)) { + printf("Invalid debug level\n"); + return -1; + } + ret = ctdb_ctrl_set_debuglevel(ctdb, options.pnn, level); if (ret != 0) { DEBUG(DEBUG_ERR, ("Unable to set debug level on node %u\n", options.pnn)); |