have LOGF macros add a newline, so user code doesn't need to.

This commit is contained in:
Nils O. Selåsdal
2014-10-06 21:52:28 +02:00
parent 33b48c4276
commit 9bd1336d26
4 changed files with 95 additions and 94 deletions
+8 -8
View File
@@ -99,7 +99,7 @@ void peer_add_addr(struct HBContext *ctx, const struct sockaddr_in *addr)
int usec;
if (peer != NULL) {
UC_LOGF(UC_LL_INFO, LMAIN, "Ignoring adding existing peer %s:%u\n",
UC_LOGF(UC_LL_INFO, LMAIN, "Ignoring adding existing peer %s:%u",
inet_ntoa(addr->sin_addr), addr->sin_port);
return;
}
@@ -169,12 +169,12 @@ void peer_do_state(struct HBPeer *peer, enum PeerEvent event)
{
if (peer->state == PeerUnknown || peer->state == PeerDead) {
if (event == PeerReceived) {
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is now alive\n");
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is now alive");
peer->state = PeerAlive;
}
} else if (peer->state == PeerAlive) {
if (event == PeerTimedout) {
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is dead !\n");
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is dead !");
peer->state = PeerDead;
}
}
@@ -206,7 +206,7 @@ void hb_read(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
return;
}
UC_LOGF(UC_LL_INFO, LMAIN, "Message from %s:%u\n", inet_ntoa(peer_addr.sin_addr),
UC_LOGF(UC_LL_INFO, LMAIN, "Message from %s:%u", inet_ntoa(peer_addr.sin_addr),
ntohs(peer_addr.sin_port));
if (rc < 4) {
@@ -216,13 +216,13 @@ void hb_read(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
magic = uc_unpack_32_be(buf);
if (magic != HB_MAGIX) {
UC_LOGF(UC_LL_WARNING, LMAIN, "Received unknown message, magic = 0x%X\n", magic);
UC_LOGF(UC_LL_WARNING, LMAIN, "Received unknown message, magic = 0x%X", magic);
return;
}
peer = hb_peer_find(ctx, &peer_addr);
if (peer == NULL) {
UC_LOGF(UC_LL_WARNING, LMAIN, "Found no peer\n");
UC_LOGF(UC_LL_WARNING, LMAIN, "Found no peer");
return;
}
@@ -241,13 +241,13 @@ void init_hb_context(struct HBContext *ctx, uint16_t local_port)
sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock_fd == -1) {
UC_LOGF(UC_LL_ERROR, LMAIN, "socket failed : %s\n", strerror(errno));
UC_LOGF(UC_LL_ERROR, LMAIN, "socket failed : %s", strerror(errno));
return;
}
if (bind(sock_fd, (struct sockaddr*)&addr, sizeof addr) != 0) {
UC_LOGF(UC_LL_ERROR, LMAIN, "Cannot bind socket to port %u : %s\n",
UC_LOGF(UC_LL_ERROR, LMAIN, "Cannot bind socket to port %u : %s",
local_port, strerror(errno));
close(sock_fd);
return;