summaryrefslogtreecommitdiff
path: root/server/src/journal_commit.cc
diff options
context:
space:
mode:
authorbertho <bertho>2009-02-10 13:39:25 +0000
committerbertho <bertho>2009-02-10 13:39:25 +0000
commitbbe2b5f899a9c1bd7c99181f8702ec03c60f3028 (patch)
tree6da04c039a0e04930bb1c7e4fea5b14e52f9bc57 /server/src/journal_commit.cc
parent3f1b036458bf9b348b65c36fa30ecb177800d703 (diff)
- Rewrite part of the database backend setup and abstraction
- Fix some printf's into debug statements
Diffstat (limited to 'server/src/journal_commit.cc')
-rw-r--r--server/src/journal_commit.cc22
1 files changed, 9 insertions, 13 deletions
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 <config.h>
+#include "debug.h"
+
// for gethostbyname
#include <netdb.h>
@@ -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