fix: better logging behaviour
This commit is contained in:
parent
011c5a6102
commit
0530a350df
30 changed files with 343 additions and 176 deletions
src/handlers
|
@ -29,16 +29,16 @@ handler_discovery(struct mg_connection *c, int ev, void *ev_data)
|
|||
|
||||
if(c->recv_mbuf.len != sizeof(discovery_answer_port))
|
||||
{
|
||||
LOG_ERROR("received invalid discovery from %s\n", ip_buf);
|
||||
LOGGER_ERR("received invalid discovery from %s\n", ip_buf);
|
||||
return;
|
||||
}
|
||||
discovery_answer_port = *((uint16_t*)c->recv_mbuf.buf);
|
||||
|
||||
LOG_INFO("received discovery from %s:%d\n", ip_buf, discovery_answer_port);
|
||||
LOGGER_INFO("received discovery from %s:%d\n", ip_buf, discovery_answer_port);
|
||||
|
||||
if(discovery_answer_port == 0)
|
||||
{
|
||||
LOG_ERROR("invalid port received\n");
|
||||
LOGGER_ERR("invalid port received\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ handler_discovery(struct mg_connection *c, int ev, void *ev_data)
|
|||
// finish writing
|
||||
if(mpack_writer_destroy(&writer) != mpack_ok)
|
||||
{
|
||||
LOG_ERROR("error writing discovery answer payload\n");
|
||||
LOGGER_ERR("error writing discovery answer payload\n");
|
||||
return;
|
||||
|
||||
}
|
||||
|
@ -70,21 +70,21 @@ handler_discovery(struct mg_connection *c, int ev, void *ev_data)
|
|||
int fd_answer = helper_connect_tcp_server(ip_buf, discovery_answer_port);
|
||||
if(fd_answer == -1)
|
||||
{
|
||||
LOG_ERROR("error during connecting\n");
|
||||
LOGGER_ERR("error during connecting\n");
|
||||
free(payload);
|
||||
return;
|
||||
}
|
||||
|
||||
if((bytes_transferred = send(fd_answer, &payload_size, sizeof(payload_size), 0)) <= 0)
|
||||
{
|
||||
LOG_ERROR("error during sending\n");
|
||||
LOGGER_ERR("error during sending\n");
|
||||
free(payload);
|
||||
close(fd_answer);
|
||||
return;
|
||||
}
|
||||
if((bytes_transferred = send(fd_answer, payload, payload_size, 0)) <= 0)
|
||||
{
|
||||
LOG_ERROR("error during sending\n");
|
||||
LOGGER_ERR("error during sending\n");
|
||||
free(payload);
|
||||
close(fd_answer);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue