Skip to content

Commit 95d99c9

Browse files
committed
Log underlying connection protocol
1 parent 6e037d2 commit 95d99c9

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/netlog/netlog-network.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ void manager_close_network_socket(Manager *m) {
139139
int manager_network_connect_socket(Manager *m) {
140140
_cleanup_free_ char *pretty = NULL;
141141
union sockaddr_union sa;
142+
const char *protocol;
142143
socklen_t salen;
143144
int r;
144145

@@ -170,16 +171,27 @@ int manager_network_connect_socket(Manager *m) {
170171
if (r < 0)
171172
return r;
172173

173-
log_debug("Connecting to remote server: '%s'", pretty);
174+
switch (m->protocol) {
175+
case SYSLOG_TRANSMISSION_PROTOCOL_UDP:
176+
protocol = "udp";
177+
break;
178+
case SYSLOG_TRANSMISSION_PROTOCOL_TCP:
179+
protocol = "tcp";
180+
break;
181+
default:
182+
assert_not_reached("Unknown protocol");
183+
}
184+
185+
log_debug("Connecting to remote server: '%s/%s'", pretty, protocol);
174186

175187
r = connect(m->socket, &m->address.sockaddr.sa, salen);
176188
if (r < 0 && errno != EINPROGRESS)
177-
return log_error_errno(errno, "Failed to connect to remote server='%s': %m", pretty);
189+
return log_error_errno(errno, "Failed to connect to remote server='%s/%s': %m", pretty, protocol);
178190

179191
if (errno != EINPROGRESS)
180-
log_debug("Connected to remote server: '%s'", pretty);
192+
log_debug("Connected to remote server: '%s/%s'", pretty, protocol);
181193
else
182-
log_debug("Connection in progress to remote server: '%s'", pretty);
194+
log_debug("Connection in progress to remote server: '%s/%s'", pretty, protocol);
183195

184196
return 0;
185197
}

0 commit comments

Comments
 (0)