From: Guus Sliepen Date: Tue, 4 Sep 2012 12:21:50 +0000 (+0200) Subject: Remove newlines at end of log messages. X-Git-Tag: release-1.1pre3~54 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e9de08be0dab58a48f9a8ce3d250516cf05d6b8e;p=oweals%2Ftinc.git Remove newlines at end of log messages. --- diff --git a/src/logger.c b/src/logger.c index cc47a4a..56bee84 100644 --- a/src/logger.c +++ b/src/logger.c @@ -88,6 +88,7 @@ void reopenlogger() { void logger(int level, int priority, const char *format, ...) { va_list ap; + int len; char timestr[32] = ""; char message[1024] = ""; time_t now; @@ -101,9 +102,12 @@ void logger(int level, int priority, const char *format, ...) { return; va_start(ap, format); - vsnprintf(message, sizeof message, format, ap); + len = vsnprintf(message, sizeof message, format, ap); va_end(ap); + if(len > 0 && len < sizeof message && message[len - 1] == '\n') + message[len - 1] = 0; + if(level <= debug_level) { switch(logmode) { case LOGMODE_STDERR: diff --git a/src/net.c b/src/net.c index 1a45041..11fbcb1 100644 --- a/src/net.c +++ b/src/net.c @@ -344,7 +344,7 @@ int reload_configuration(void) { for(node = myself->subnet_tree->head; node; node = node->next) { subnet_t *subnet = node->data; - logger(DEBUG_ALWAYS, LOG_DEBUG, "subnet %p expires %d\n", subnet, (int)subnet->expires); + logger(DEBUG_ALWAYS, LOG_DEBUG, "subnet %p expires %d", subnet, (int)subnet->expires); if(!subnet->expires) subnet->expires = 1; } @@ -356,7 +356,7 @@ int reload_configuration(void) { continue; if((s2 = lookup_subnet(myself, subnet))) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "read subnet that already exists: %p expires %d\n", s2, (int)s2->expires); + logger(DEBUG_ALWAYS, LOG_DEBUG, "read subnet that already exists: %p expires %d", s2, (int)s2->expires); if(s2->expires == 1) s2->expires = 0; diff --git a/src/net_socket.c b/src/net_socket.c index 7f3db5c..c107351 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -306,7 +306,7 @@ static void do_outgoing_pipe(connection_t *c, char *command) { int fd[2]; if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not create socketpair: %s\n", strerror(errno)); + logger(DEBUG_ALWAYS, LOG_ERR, "Could not create socketpair: %s", strerror(errno)); return; } @@ -339,7 +339,7 @@ static void do_outgoing_pipe(connection_t *c, char *command) { int result = system(command); if(result < 0) - logger(DEBUG_ALWAYS, LOG_ERR, "Could not execute %s: %s\n", command, strerror(errno)); + logger(DEBUG_ALWAYS, LOG_ERR, "Could not execute %s: %s", command, strerror(errno)); else if(result) logger(DEBUG_ALWAYS, LOG_ERR, "%s exited with non-zero status %d", command, result); exit(result);