X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Flog.c;h=5d2af2b8bf295e2b80f1fc0c7c6dfcdd540c8563;hb=a8ca900b2e60cc837c5e9529d7a9c778ff30c955;hp=94f86a822503dda3bd18ed0aaab3661ee1b65d46;hpb=a72efcd9b1c000c47bbe363f51c9123528e41d84;p=umurmur.git diff --git a/src/log.c b/src/log.c index 94f86a8..5d2af2b 100644 --- a/src/log.c +++ b/src/log.c @@ -58,55 +58,52 @@ void Log_free() void logthis(const char *logstring, ...) { va_list argp; - char buf[STRSIZE + 2]; + char buf[STRSIZE + 1]; va_start(argp, logstring); vsnprintf(&buf[0], STRSIZE, logstring, argp); va_end(argp); - strcat(buf, "\n"); if (termprint) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); else - syslog(LOG_INFO, buf); + syslog(LOG_INFO, "%s", buf); } void Log_warn(const char *logstring, ...) { va_list argp; - char buf[STRSIZE + 2]; + char buf[STRSIZE + 1]; int offset = 0; va_start(argp, logstring); offset = sprintf(buf, "WARN: "); vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp); va_end(argp); - strcat(buf, "\n"); if (termprint) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); else - syslog(LOG_WARNING, buf); + syslog(LOG_WARNING, "%s", buf); } void Log_info(const char *logstring, ...) { va_list argp; - char buf[STRSIZE + 2]; + char buf[STRSIZE + 1]; int offset = 0; va_start(argp, logstring); offset = sprintf(buf, "INFO: "); vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp); va_end(argp); - strcat(buf, "\n"); if (termprint) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); else - syslog(LOG_INFO, buf); + syslog(LOG_INFO, "%s", buf); } void Log_info_client(client_t *client, const char *logstring, ...) { va_list argp; - char buf[STRSIZE + 2]; + char buf[STRSIZE + 1]; int offset = 0; va_start(argp, logstring); @@ -118,11 +115,10 @@ void Log_info_client(client_t *client, const char *logstring, ...) client->username == NULL ? "" : client->username, inet_ntoa(client->remote_tcp.sin_addr), ntohs(client->remote_tcp.sin_port)); - strcat(buf, "\n"); if (termprint) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); else - syslog(LOG_INFO, buf); + syslog(LOG_INFO, "%s", buf); } @@ -130,34 +126,32 @@ void Log_info_client(client_t *client, const char *logstring, ...) void Log_debug(const char *logstring, ...) { va_list argp; - char buf[STRSIZE + 2]; + char buf[STRSIZE + 1]; int offset = 0; va_start(argp, logstring); offset = sprintf(buf, "DEBUG: "); vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp); va_end(argp); - strcat(buf, "\n"); if (termprint) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); else - syslog(LOG_DEBUG, buf); + syslog(LOG_DEBUG, "%s", buf); } #endif void Log_fatal(const char *logstring, ...) { va_list argp; - char buf[STRSIZE + 2]; + char buf[STRSIZE + 1]; int offset = 0; va_start(argp, logstring); offset = sprintf(buf, "FATAL: "); vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp); va_end(argp); - strcat(buf, "\n"); if (termprint) - fprintf(stderr, "%s", buf); + fprintf(stderr, "%s\n", buf); else - syslog(LOG_CRIT, buf); + syslog(LOG_CRIT, "%s", buf); exit(1); }