[misc] Add logging of net_connect() service

This commit is contained in:
ejurgensen 2021-02-26 22:42:09 +01:00
parent dd0f0ece78
commit dfc1580f13
2 changed files with 4 additions and 4 deletions

View File

@ -181,7 +181,7 @@ net_port_get(short unsigned *port, union net_sockaddr *naddr)
} }
int int
net_connect(const char *addr, unsigned short port, int type) net_connect(const char *addr, unsigned short port, int type, const char *log_service_name)
{ {
struct addrinfo hints = { 0 }; struct addrinfo hints = { 0 };
struct addrinfo *servinfo; struct addrinfo *servinfo;
@ -190,7 +190,7 @@ net_connect(const char *addr, unsigned short port, int type)
int fd; int fd;
int ret; int ret;
DPRINTF(E_DBG, L_MISC, "Connecting to %s, port %u\n", addr, port); DPRINTF(E_DBG, L_MISC, "Connecting to '%s' at %s (port %u)\n", log_service_name, addr, port);
hints.ai_socktype = type; hints.ai_socktype = type;
hints.ai_family = (cfg_getbool(cfg_getsec(cfg, "general"), "ipv6")) ? AF_UNSPEC : AF_INET; hints.ai_family = (cfg_getbool(cfg_getsec(cfg, "general"), "ipv6")) ? AF_UNSPEC : AF_INET;
@ -225,7 +225,7 @@ net_connect(const char *addr, unsigned short port, int type)
if (!ptr) if (!ptr)
{ {
DPRINTF(E_LOG, L_MISC, "Failed to connect to %s, port %u: %s\n", addr, port, strerror(errno)); DPRINTF(E_LOG, L_MISC, "Could not connect to '%s' at %s (port %u): %s\n", log_service_name, addr, port, strerror(errno));
return -1; return -1;
} }

View File

@ -34,7 +34,7 @@ int
net_port_get(short unsigned *port, union net_sockaddr *naddr); net_port_get(short unsigned *port, union net_sockaddr *naddr);
int int
net_connect(const char *addr, unsigned short port, int type); net_connect(const char *addr, unsigned short port, int type, const char *log_service_name);
int int
net_bind(short unsigned *port, int type, const char *log_service_name); net_bind(short unsigned *port, int type, const char *log_service_name);