summaryrefslogtreecommitdiffstats
path: root/ctdb/common/cmdline.c
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-08-08 13:36:00 +1000
committerAmitay Isaacs <amitay@samba.org>2014-10-28 05:42:04 +0100
commita22c8ca05618a63d6923fcf7dc567d1cd6119009 (patch)
tree9b9ec1166c1eb34170e67eba218b316e5a94c57c /ctdb/common/cmdline.c
parentd9d572a23cf527780caae9d7ff143376e9057f6a (diff)
downloadsamba-a22c8ca05618a63d6923fcf7dc567d1cd6119009.tar.gz
samba-a22c8ca05618a63d6923fcf7dc567d1cd6119009.tar.xz
samba-a22c8ca05618a63d6923fcf7dc567d1cd6119009.zip
ctdb-logging: Rework debug level parsing
Put declarations into ctdb_logging.h, factor out some common code, clean up #includes. Remove the check so see if the 1st character of the debug level is '-'. This is wrong, since it is trying to check for a negative numeric debug level (which is no longer supported) and would need to be handled in the else anyway. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/common/cmdline.c')
-rw-r--r--ctdb/common/cmdline.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c
index ab2b45e914..4ed3fae64d 100644
--- a/ctdb/common/cmdline.c
+++ b/ctdb/common/cmdline.c
@@ -96,10 +96,8 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
}
/* Set the debug level */
- if (isalpha(ctdb_cmdline.debuglevel[0]) || ctdb_cmdline.debuglevel[0] == '-') {
- DEBUGLEVEL = get_debug_by_desc(ctdb_cmdline.debuglevel);
- } else {
- DEBUGLEVEL = strtol(ctdb_cmdline.debuglevel, NULL, 0);
+ if (!parse_debug(ctdb_cmdline.debuglevel, &DEBUGLEVEL)) {
+ DEBUGLEVEL = DEBUG_ERR;
}
/* set up the tree to store server ids */
@@ -147,10 +145,8 @@ struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev,
}
/* Set the debug level */
- if (isalpha(ctdb_cmdline.debuglevel[0]) || ctdb_cmdline.debuglevel[0] == '-') {
- DEBUGLEVEL = get_debug_by_desc(ctdb_cmdline.debuglevel);
- } else {
- DEBUGLEVEL = strtol(ctdb_cmdline.debuglevel, NULL, 0);
+ if (!parse_debug(ctdb_cmdline.debuglevel, &DEBUGLEVEL)) {
+ DEBUGLEVEL = DEBUG_ERR;
}
ret = ctdb_socket_connect(ctdb);