diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-07-01 08:26:00 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-07-01 08:26:00 +1000 |
commit | 9802a0c2f6c327b9533e2ed228b5a0ee4fb32aa8 (patch) | |
tree | 696fd15f96326771734fc6ca77fc9eb6fb264845 /ctdb/tools | |
parent | e6e1ff32a5c8527b538830bc7b769666915de307 (diff) | |
download | samba-9802a0c2f6c327b9533e2ed228b5a0ee4fb32aa8.tar.gz samba-9802a0c2f6c327b9533e2ed228b5a0ee4fb32aa8.tar.xz samba-9802a0c2f6c327b9533e2ed228b5a0ee4fb32aa8.zip |
when no debuglevel is specified, make 'ctdb setdebug' show the available options
(This used to be ctdb commit f4b0825d9da34578b9f90dc9bd7f99fcc2519ddf)
Diffstat (limited to 'ctdb/tools')
-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)); |