DEBUG add function to set debug fd
DPRINTF was blindly sending all debug output to fd 2 (stderr). The new function iscsi_set_debug_fd() will set the debug fd. In general debugging is completely disabled by default.
This commit is contained in:
12
lib/init.c
12
lib/init.c
@@ -87,6 +87,7 @@ iscsi_create_context(const char *initiator_name)
|
||||
strncpy(iscsi->initiator_name,initiator_name,MAX_STRING_SIZE);
|
||||
|
||||
iscsi->fd = -1;
|
||||
iscsi->debug_fd = 2;
|
||||
|
||||
srand(time(NULL) ^ getpid() ^ (u_int32_t) iscsi);
|
||||
|
||||
@@ -112,6 +113,10 @@ iscsi_create_context(const char *initiator_name)
|
||||
iscsi->tcp_keepintvl=30;
|
||||
iscsi->tcp_keepidle=30;
|
||||
|
||||
if (getenv("LIBISCSI_DEBUG_FD") != NULL) {
|
||||
iscsi_set_debug_fd(iscsi,atoi(getenv("LIBISCSI_DEBUG_FD")));
|
||||
}
|
||||
|
||||
if (getenv("LIBISCSI_DEBUG") != NULL) {
|
||||
iscsi_set_debug(iscsi,atoi(getenv("LIBISCSI_DEBUG")));
|
||||
}
|
||||
@@ -315,6 +320,13 @@ iscsi_set_debug(struct iscsi_context *iscsi, int level)
|
||||
DPRINTF(iscsi,2,"set debug level to %d",level);
|
||||
}
|
||||
|
||||
void
|
||||
iscsi_set_debug_fd(struct iscsi_context *iscsi, int fd)
|
||||
{
|
||||
iscsi->debug_fd = fd;
|
||||
DPRINTF(iscsi,2,"set debug fd to %d",fd);
|
||||
}
|
||||
|
||||
const char *
|
||||
iscsi_get_error(struct iscsi_context *iscsi)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user