From 9bd1336d26b9e07ab12e540dcd4b52b7e6df71d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Mon, 6 Oct 2014 21:52:28 +0200 Subject: [PATCH] have LOGF macros add a newline, so user code doesn't need to. --- include/ucore/logging.h | 9 +-- test/logging.c | 24 +++---- test/test_logging.c | 140 ++++++++++++++++++++-------------------- test/udp_heartbeat.c | 16 ++--- 4 files changed, 95 insertions(+), 94 deletions(-) diff --git a/include/ucore/logging.h b/include/ucore/logging.h index 37234dd..db4780c 100644 --- a/include/ucore/logging.h +++ b/include/ucore/logging.h @@ -305,9 +305,9 @@ void uc_logf(int log_level, int module, int raw, // to override that by defining UC_DEBUG_ALWAYS #if defined(DEBUG) || defined(UC_DEBUG_ALWAYS) # define UC_DEBUGF(mod, fmt, ...)\ - uc_logf(UC_LL_DEBUG, mod,0 , UC_SRC_LOCATION, fmt, ## __VA_ARGS__) + uc_logf(UC_LL_DEBUG, mod,0 , UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__) # define UC_DEBUGFR(mod, fmt, ...)\ - uc_logf(UC_LL_DEBUG, mod,1 , UC_SRC_LOCATION, fmt, ## __VA_ARGS__) + uc_logf(UC_LL_DEBUG, mod,1 , UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__) #else # define UC_DEBUGF(mod, fmt, ...) do {} while (0) # define UC_DEBUGFR(mod, fmt, ...) do {} while (0) @@ -317,6 +317,7 @@ void uc_logf(int log_level, int module, int raw, * * For log messages with UC_LL_DEBUG, the UC_DEBUGF() macro can be used, * UC_DEBUGF will only be compiled in if the DEBUG macro is defined + * fmt must be a string literal, and a newline will be added * * @param lvl log level of this log message * @param mod module id of this log messagex. @@ -324,11 +325,11 @@ void uc_logf(int log_level, int module, int raw, * @param ... printf style arguments */ #define UC_LOGF(lvl, mod, fmt, ...) \ - uc_logf(lvl, mod, 0, UC_SRC_LOCATION, fmt, ## __VA_ARGS__) + uc_logf(lvl, mod, 0, UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__) /** Raw logging ,Like UC_LOGF, but only prints the supplied - * data, not timestamp, log level etc. + * data, not timestamp, log level, newline, etc. */ #define UC_LOGFR(lvl, mod, fmt, ...) \ uc_logf(lvl, mod, 1, UC_SRC_LOCATION, fmt, ## __VA_ARGS__) diff --git a/test/logging.c b/test/logging.c index a083807..fbce752 100644 --- a/test/logging.c +++ b/test/logging.c @@ -49,27 +49,27 @@ int main(int argc, char *argv[]) uc_log_add_destination(dest); dest = uc_log_new_stderr(UC_LL_INFO, 0); uc_log_add_destination(dest); - UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 2); - UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 3); - UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 4); - UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 5); - UC_LOGF( UC_LL_WARNING, HO, "Test HO warning%d\n", 2); - UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN info \n" ); - UC_LOGF( UC_LL_WARNING, MAIN, "Test MAIN warning\n" ); + UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 2); + UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 3); + UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 4); + UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 5); + UC_LOGF( UC_LL_WARNING, HO, "Test HO warning%d", 2); + UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN info " ); + UC_LOGF( UC_LL_WARNING, MAIN, "Test MAIN warning" ); uc_log_destination_set_module_loglevel(dest, MAIN, UC_LL_INFO); - UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 2\n" ); + UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 2" ); - UC_LOGFR(UC_LL_INFO, MAIN, "Test RAW logging 1\n" ); + UC_LOGFR(UC_LL_INFO, MAIN, "Test RAW logging 1" ); uc_log_destination_set_module_loglevel(dest,MAIN, UC_LL_WARNING); - UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 3\n" ); + UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 3" ); uc_log_destination_set_loglevel(dest, UC_LL_DEBUG); - UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD NOT SHOW\n" ); + UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD NOT SHOW" ); //uc_log_destination_set_module_loglevel(dest, MAIN, UC_LL_INFO); uc_log_destination_set_mask(dest, "HO=ERROR:MAIN=DEBUG:HO=DEBUG"); - UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD SHOW\n" ); + UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD SHOW" ); uc_log_delete_destination(dest); diff --git a/test/test_logging.c b/test/test_logging.c index 14a2ffc..d6a8a28 100644 --- a/test/test_logging.c +++ b/test/test_logging.c @@ -53,15 +53,15 @@ START_TEST (test_logfile_location) uc_log_add_destination(dest); uc_log_add_destination(dest); //adding this twice should do nothing - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n"); - UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n"); - UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n"); - UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n"); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2"); + UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3"); + UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4"); + UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5"); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 380, "was %ld", (long)st.st_size); END_TEST START_TEST (test_logfile_delete_destination) @@ -87,28 +87,28 @@ START_TEST (test_logfile_delete_destination) uc_log_add_destination(dest); uc_log_add_destination(dest); //adding this twice should do nothing - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n"); - UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n"); - UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n"); - UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n"); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2"); + UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3"); + UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4"); + UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5"); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 380, "was %ld", (long)st.st_size); uc_log_delete_destination(dest); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n"); - UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n"); - UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n"); - UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n"); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2"); + UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3"); + UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4"); + UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5"); //since we deleted destinatiion, no more logging should appear in the file rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 380, "was %ld", (long)st.st_size); END_TEST @@ -134,12 +134,12 @@ START_TEST (test_logfile_no_location) fail_if(dest == NULL); uc_log_add_destination(dest); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 52*2, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 52*2, "was %ld", (long)st.st_size); END_TEST START_TEST (test_logfile_loglevel_surpressed_dest) @@ -169,9 +169,9 @@ START_TEST (test_logfile_loglevel_surpressed_dest) UC_LOGF(UC_LL_INFO, 1, "Lorum ipson %d", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); - fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size); + fail_if(st.st_size != 0, "was %ld", (long)st.st_size); END_TEST START_TEST (test_logfile_loglevel_surpressed_module) @@ -201,9 +201,9 @@ START_TEST (test_logfile_loglevel_surpressed_module) UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 100); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); - fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size); + fail_if(st.st_size != 0, "was %ld", (long)st.st_size); END_TEST START_TEST (test_logfile_reopen_files) @@ -228,24 +228,24 @@ START_TEST (test_logfile_reopen_files) fail_if(dest == NULL); uc_log_add_destination(dest); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size); rc = remove(FILE_NAME); - fail_if(rc != 0, "Remove failed %s\n", strerror(errno)); + fail_if(rc != 0, "Remove failed %s", strerror(errno)); rc = uc_log_reopen_files(); - fail_if(rc != 0, "uc_log_reopen_files failed: %d\n", rc); + fail_if(rc != 0, "uc_log_reopen_files failed: %d", rc); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "2. stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 77, "was %ld\n", (long)st.st_size);//should only one line there now + fail_if(rc != 0, "2. stat failed: %s", strerror(errno)); + fail_if(st.st_size != 77, "was %ld", (long)st.st_size);//should only one line there now END_TEST @@ -277,29 +277,29 @@ START_TEST (test_logfile_remove_dest) uc_log_add_destination(dest1); uc_log_add_destination(dest2); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size); uc_log_remove_destination(dest1); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); //should not be logged now + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); //should not be logged now rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "2. stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size);//should be same size + fail_if(rc != 0, "2. stat failed: %s", strerror(errno)); + fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);//should be same size //removing the last destination should be fine too uc_log_remove_destination(dest2); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "2. stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size);//should be same size + fail_if(rc != 0, "2. stat failed: %s", strerror(errno)); + fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);//should be same size END_TEST @@ -326,9 +326,9 @@ START_TEST (test_logfile_full_filesystem) uc_log_add_destination(dest); for (i = 0; i < 1024; i++) { - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1); } END_TEST @@ -370,7 +370,7 @@ START_TEST (test_logfile_invalid_file_after_reopen) int rc; uc_log_init(&mods); - printf("SUBDIR_FILE_NAME= " SUBDIR_FILE_NAME " \n"); + printf("SUBDIR_FILE_NAME= " SUBDIR_FILE_NAME " "); dest = uc_log_new_file(SUBDIR_FILE_NAME, UC_LL_DEBUG, 1); fail_if(dest == NULL); @@ -378,18 +378,18 @@ START_TEST (test_logfile_invalid_file_after_reopen) logging_rm_subdir(); rc = access(SUBDIR_FILE_NAME, W_OK); - fail_if(rc == 0, "Test setup is wrong. Can still access" SUBDIR_FILE_NAME "\n"); + fail_if(rc == 0, "Test setup is wrong. Can still access" SUBDIR_FILE_NAME ""); - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1); uc_log_reopen_files(); //this should not crash now. - UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1); - UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d\n", 1); + UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d", 1); + UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1); END_TEST @@ -419,8 +419,8 @@ START_TEST (test_logfile_raw) UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 14*2, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 14*2, "was %ld", (long)st.st_size); END_TEST START_TEST (test_logfile_dest_mask) @@ -454,19 +454,19 @@ START_TEST (test_logfile_dest_mask) uc_log_add_destination(dest); UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); - UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); + UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 0, "was %ld", (long)st.st_size); uc_log_destination_set_mask(dest, "MOD1=DEBUG:mod2=Debug"); UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); UC_LOGFR(UC_LL_DEBUG, 1, "Lorum ipson %d\n", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 14*2, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 14*2, "was %ld", (long)st.st_size); END_TEST START_TEST (test_loglevel_module_none) @@ -494,8 +494,8 @@ START_TEST (test_loglevel_module_none) UC_LOGFR(UC_LL_ERROR, 0, "Lorum ipson %d\n", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 0, "was %ld", (long)st.st_size); END_TEST START_TEST (test_loglevel_dest_none) @@ -523,8 +523,8 @@ START_TEST (test_loglevel_dest_none) UC_LOGFR(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1); rc = stat(FILE_NAME, &st); - fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); - fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size); + fail_if(rc != 0, "stat failed: %s", strerror(errno)); + fail_if(st.st_size != 0, "was %ld", (long)st.st_size); END_TEST diff --git a/test/udp_heartbeat.c b/test/udp_heartbeat.c index 66bb717..f313b07 100644 --- a/test/udp_heartbeat.c +++ b/test/udp_heartbeat.c @@ -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;