Merge pull request #439 from plieven/feat/improve_logging
Add some logging improvements
This commit is contained in:
@@ -72,9 +72,9 @@ iscsi_log_message(struct iscsi_context *iscsi, int level, const char *format, ..
|
||||
}
|
||||
|
||||
if (iscsi->target_name[0]) {
|
||||
static char message2[1282];
|
||||
static char message2[1294];
|
||||
|
||||
snprintf(message2, 1282, "%s [%s]", message, iscsi->target_name);
|
||||
snprintf(message2, sizeof(message2), "%s [%s/%d]", message, iscsi->target_name, iscsi->lun);
|
||||
iscsi->log_fn(level, message2);
|
||||
}
|
||||
else
|
||||
|
||||
20
lib/socket.c
20
lib/socket.c
@@ -306,6 +306,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
struct addrinfo *ai = NULL;
|
||||
union socket_address sa;
|
||||
int socksize;
|
||||
bool portal_is_ip;
|
||||
|
||||
ISCSI_LOG(iscsi, 2, "connecting to portal %s",portal);
|
||||
|
||||
@@ -352,6 +353,10 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
*str = 0;
|
||||
}
|
||||
|
||||
/* check if we got an ip address or hostname for portal */
|
||||
portal_is_ip = inet_pton(AF_INET, host, &sa) == 1 ||
|
||||
inet_pton(AF_INET6, host, &sa) == 1;
|
||||
|
||||
/* is it a hostname ? */
|
||||
if (getaddrinfo(host, NULL, NULL, &ai) != 0) {
|
||||
iscsi_free(iscsi, addr);
|
||||
@@ -371,6 +376,11 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
#ifdef HAVE_SOCK_SIN_LEN
|
||||
sa.sin.sin_len = socksize;
|
||||
#endif
|
||||
if (!portal_is_ip) {
|
||||
char ip[INET_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET, &sa.sin.sin_addr, ip, sizeof(ip));
|
||||
ISCSI_LOG(iscsi, 2, "portal resolved to ipv4 address %s", ip);
|
||||
}
|
||||
break;
|
||||
#ifdef HAVE_SOCKADDR_IN6
|
||||
case AF_INET6:
|
||||
@@ -381,6 +391,11 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
#ifdef HAVE_SOCK_SIN_LEN
|
||||
sa.sin6.sin6_len = socksize;
|
||||
#endif
|
||||
if (!portal_is_ip) {
|
||||
char ip[INET6_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET6, &sa.sin6.sin6_addr, ip, sizeof(ip));
|
||||
ISCSI_LOG(iscsi, 2, "portal resolved to ipv6 address %s", ip);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -1073,7 +1088,10 @@ iscsi_tcp_service(struct iscsi_context *iscsi, int revents)
|
||||
}
|
||||
|
||||
if (getsockname(iscsi->fd, (struct sockaddr *) &local, &local_l) == 0) {
|
||||
ISCSI_LOG(iscsi, 2, "connection established to %s", iscsi->connected_portal);
|
||||
char ip[INET_ADDRSTRLEN];
|
||||
inet_ntop(AF_INET, &local.sin_addr, ip, sizeof(ip));
|
||||
ISCSI_LOG(iscsi, 2, "connection established (%s:%u -> %s)", ip,
|
||||
(unsigned)ntohs(local.sin_port), iscsi->connected_portal);
|
||||
}
|
||||
|
||||
iscsi->is_connected = 1;
|
||||
|
||||
Reference in New Issue
Block a user