Skip to content

Commit

Permalink
Add various debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ssahani committed May 10, 2024
1 parent 819eca8 commit 23aefdb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/netlog/netlog-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ static int manager_read_journal_input(Manager *m) {
assert(m);
assert(m->journal);

log_debug("Reading from journal ...");

JOURNAL_FOREACH_DATA_RETVAL(m->journal, data, length, r) {

r = parse_field(data, length, "PRIORITY=", &priority);
Expand Down Expand Up @@ -389,6 +391,8 @@ int manager_connect(Manager *m) {

manager_disconnect(m);

log_debug("Connecting network ...");

switch (m->protocol) {
case SYSLOG_TRANSMISSION_PROTOCOL_DTLS:
r = dtls_connect(m->dtls, &m->address);
Expand All @@ -413,6 +417,8 @@ int manager_connect(Manager *m) {
void manager_disconnect(Manager *m) {
assert(m);

log_debug("Disconnecting network ...");

close_journal_input(m);

manager_close_network_socket(m);
Expand Down
8 changes: 7 additions & 1 deletion src/netlog/netlog-network.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
#define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)

static int sendmsg_loop(Manager *m, struct msghdr *mh) {
size_t n;
int r;

assert(m);
assert(mh);

for (;;) {
if (sendmsg(m->socket, mh, MSG_NOSIGNAL) >= 0)
n = sendmsg(m->socket, mh, MSG_NOSIGNAL);
if (r >= 0) {
log_debug("Successful sendmsg: %ld bytes", n);
return 0;
}

if (errno == EINTR)
continue;
Expand Down Expand Up @@ -421,6 +425,8 @@ int manager_open_network_socket(Manager *m) {
goto fail;
}

log_debug("Succesfully created socket with fd='%d'", m->socket);

return m->socket;

fail:
Expand Down

0 comments on commit 23aefdb

Please sign in to comment.