From bbe2b5f899a9c1bd7c99181f8702ec03c60f3028 Mon Sep 17 00:00:00 2001 From: bertho Date: Tue, 10 Feb 2009 13:39:25 +0000 Subject: - Rewrite part of the database backend setup and abstraction - Fix some printf's into debug statements --- server/src/journal_commit.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'server/src/journal_commit.cc') diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc index c10e8c7..cb9769e 100644 --- a/server/src/journal_commit.cc +++ b/server/src/journal_commit.cc @@ -28,6 +28,8 @@ #include +#include "debug.h" + // for gethostbyname #include @@ -57,15 +59,12 @@ static int mwrite(int sock, const char *fmt, ...) va_end(args); if(sock != -1 && write(sock, buffer, l) != l) { - fprintf(stderr, "write did not write all the bytes in the buffer.\n"); + PRACRO_ERR_LOG(journal, "write did not write all the bytes in the buffer.\n"); } + PRACRO_DEBUG(journal, "%s", buffer); free(buffer); -#ifdef WITH_DEBUG - printf(buffer); -#endif/*WITH_DEBUG*/ - return l; } @@ -84,8 +83,7 @@ int journal_commit(const char *cpr, const char *user, struct hostent *he; he = gethostbyname(addr); if(!he || !he->h_length) { - fprintf(stderr, "gethostbyname(%s) failed!\n", addr); - perror(":"); + PRACRO_ERR_LOG(journal, "gethostbyname(%s) failed (errno=%d)!\n", addr, errno); return -1; } @@ -100,12 +98,12 @@ int journal_commit(const char *cpr, const char *user, sin.sin_port = htons(port); if( (sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - fprintf(stderr, "Socket() failed!\n"); + PRACRO_ERR_LOG(journal, "Socket() failed!\n"); return -1; } if(connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { - fprintf(stderr, "Connect() failed!\n"); + PRACRO_ERR_LOG(journal, "Connect() failed!\n"); perror(":"); return -1; } @@ -123,11 +121,9 @@ int journal_commit(const char *cpr, const char *user, // send body if(sock != -1 && write(sock, buf, size) != (ssize_t)size) { - fprintf(stderr, "write did not write all the bytes in the buffer.\n"); + PRACRO_ERR_LOG(journal, "write did not write all the bytes in the buffer.\n"); } -#ifdef WITH_DEBUG - printf(buf); -#endif/*WITH_DEBUG*/ + PRACRO_DEBUG(journal, "%s", buf); #ifndef WITHOUT_UPLOADSERVER // close socket -- cgit v1.2.3