Add debugging framework
This patch adds a user configurable debug level. For testing it includes connection info and reporting errors.
This commit is contained in:
@@ -196,6 +196,7 @@ void print_help(void)
|
||||
fprintf(stderr, " -i, --initiator-name=iqn-name Initiatorname to use\n");
|
||||
fprintf(stderr, " -e, --evpd=integer evpd\n");
|
||||
fprintf(stderr, " -c, --pagecode=integer page code\n");
|
||||
fprintf(stderr, " -d, --debug=integer debug level (0=disabled)\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Help options:\n");
|
||||
fprintf(stderr, " -?, --help Show this help message\n");
|
||||
@@ -218,7 +219,7 @@ int main(int argc, const char *argv[])
|
||||
const char *url = NULL;
|
||||
struct iscsi_url *iscsi_url = NULL;
|
||||
int evpd = 0, pagecode = 0;
|
||||
int show_help = 0, show_usage = 0;
|
||||
int show_help = 0, show_usage = 0, debug = 0;
|
||||
int res;
|
||||
|
||||
struct poptOption popt_options[] = {
|
||||
@@ -227,6 +228,7 @@ int main(int argc, const char *argv[])
|
||||
{ "initiator-name", 'i', POPT_ARG_STRING, &initiator, 0, "Initiatorname to use", "iqn-name" },
|
||||
{ "evpd", 'e', POPT_ARG_INT, &evpd, 0, "evpd", "integer" },
|
||||
{ "pagecode", 'c', POPT_ARG_INT, &pagecode, 0, "page code", "integer" },
|
||||
{ "debug", 'd', POPT_ARG_INT, &debug, 0, "Debugging level", "integer" },
|
||||
POPT_TABLEEND
|
||||
};
|
||||
|
||||
@@ -263,6 +265,10 @@ int main(int argc, const char *argv[])
|
||||
exit(10);
|
||||
}
|
||||
|
||||
if (debug > 0) {
|
||||
iscsi_set_debug(iscsi, debug);
|
||||
}
|
||||
|
||||
if (url == NULL) {
|
||||
fprintf(stderr, "You must specify the URL\n");
|
||||
print_usage();
|
||||
|
||||
@@ -291,6 +291,7 @@ void print_help(void)
|
||||
fprintf(stderr, "Usage: iscsi-ls [OPTION...] <iscsi-url>\n");
|
||||
fprintf(stderr, " -i, --initiator-name=iqn-name Initiatorname to use\n");
|
||||
fprintf(stderr, " -s, --show-luns Show the luns for each target\n");
|
||||
fprintf(stderr, " -d, --debug=integer debug level (0=disabled)\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Help options:\n");
|
||||
fprintf(stderr, " -?, --help Show this help message\n");
|
||||
@@ -314,13 +315,14 @@ int main(int argc, const char *argv[])
|
||||
const char *url = NULL;
|
||||
poptContext pc;
|
||||
int res;
|
||||
int show_help = 0, show_usage = 0;
|
||||
int show_help = 0, show_usage = 0, debug = 0;
|
||||
|
||||
struct poptOption popt_options[] = {
|
||||
{ "help", '?', POPT_ARG_NONE, &show_help, 0, "Show this help message", NULL },
|
||||
{ "usage", 0, POPT_ARG_NONE, &show_usage, 0, "Display brief usage message", NULL },
|
||||
{ "initiator-name", 'i', POPT_ARG_STRING, &initiator, 0, "Initiatorname to use", "iqn-name" },
|
||||
{ "show-luns", 's', POPT_ARG_NONE, &showluns, 0, "Show the luns for each target", NULL },
|
||||
{ "debug", 'd', POPT_ARG_INT, &debug, 0, "Debugging level", "integer" },
|
||||
POPT_TABLEEND
|
||||
};
|
||||
|
||||
@@ -353,7 +355,6 @@ int main(int argc, const char *argv[])
|
||||
|
||||
poptFreeContext(pc);
|
||||
|
||||
|
||||
if (url == NULL) {
|
||||
fprintf(stderr, "You must specify iscsi target portal.\n");
|
||||
print_usage();
|
||||
@@ -366,6 +367,10 @@ int main(int argc, const char *argv[])
|
||||
exit(10);
|
||||
}
|
||||
|
||||
if (debug > 0) {
|
||||
iscsi_set_debug(iscsi, debug);
|
||||
}
|
||||
|
||||
iscsi_url = iscsi_parse_portal_url(iscsi, url);
|
||||
if (iscsi_url == NULL) {
|
||||
fprintf(stderr, "Failed to parse URL: %s\n",
|
||||
|
||||
Reference in New Issue
Block a user