summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authordeva <deva>2010-07-05 09:01:54 +0000
committerdeva <deva>2010-07-05 09:01:54 +0000
commitfbba835d7efaa4ee1d28bf5c7e2232e53d84af5e (patch)
tree5b71566f174143fea11e21e0c034bd6a1026c03d /server
parent71318f4e56dd1467b071404c61f686745cf3dfc4 (diff)
Remove PRACRO_ prefix from debug macros.
Diffstat (limited to 'server')
-rw-r--r--server/src/artefact.cc8
-rw-r--r--server/src/connection.cc8
-rw-r--r--server/src/database.cc8
-rw-r--r--server/src/database.h18
-rw-r--r--server/src/debug.cc145
-rw-r--r--server/src/debug.h146
-rw-r--r--server/src/entitylist.cc28
-rw-r--r--server/src/httpd.cc4
-rw-r--r--server/src/inotify.cc16
-rw-r--r--server/src/journal.cc14
-rw-r--r--server/src/journal_commit.cc15
-rw-r--r--server/src/luaquerymapper.cc10
-rw-r--r--server/src/luaresume.cc18
-rw-r--r--server/src/macroheaderparser.cc17
-rw-r--r--server/src/macrolist.cc6
-rw-r--r--server/src/macroparser.cc17
-rw-r--r--server/src/macrotool/macrotool.cc4
-rw-r--r--server/src/macrotool/macrotool_dump.cc2
-rw-r--r--server/src/macrotool/macrotool_fieldnames.cc2
-rw-r--r--server/src/macrotool/macrotool_filehandler.cc2
-rw-r--r--server/src/macrotool/macrotool_util.cc2
-rw-r--r--server/src/pracrod.cc6
-rw-r--r--server/src/pracrodaopgsql.cc81
-rw-r--r--server/src/pracrodaotest.cc36
-rw-r--r--server/src/queryhandlerpentominos.cc10
-rw-r--r--server/src/queryhandlerpracro.cc3
-rw-r--r--server/src/queryresult.h21
-rw-r--r--server/src/saxparser.cc8
-rw-r--r--server/src/server.cc2
-rw-r--r--server/src/sessionparser.cc10
-rw-r--r--server/src/tcpsocket.cc19
-rw-r--r--server/src/templateheaderparser.cc16
-rw-r--r--server/src/templatelist.cc6
-rw-r--r--server/src/templateparser.cc11
-rw-r--r--server/src/transactionhandler.cc12
-rw-r--r--server/src/transactionparser.cc16
-rw-r--r--server/src/widgetgenerator.cc6
-rw-r--r--server/src/widgetvalue.cc14
38 files changed, 414 insertions, 353 deletions
diff --git a/server/src/artefact.cc b/server/src/artefact.cc
index f3e739d..d8867c5 100644
--- a/server/src/artefact.cc
+++ b/server/src/artefact.cc
@@ -36,11 +36,11 @@ Artefact::Artefact()
{
#ifndef WITHOUT_ARTEFACT
- PRACRO_DEBUG(artefact, "Creating artefact connection %s : %d\n",
+ DEBUG(artefact, "Creating artefact connection %s : %d\n",
Conf::artefact_addr.c_str(), Conf::artefact_port);
atfh = atf_init();
- if(!atfh) PRACRO_ERR(artefact, "Out of memory!\n");
+ if(!atfh) ERR(artefact, "Out of memory!\n");
conn = atf_connect(atfh,
Conf::artefact_addr.c_str(),
@@ -102,7 +102,7 @@ QueryResult Artefact::exec(Query &query,
atf_id id;
if(query.attributes.find("class") == query.attributes.end()) {
- PRACRO_ERR(artefact, "Missing 'class' attribute!\n");
+ ERR(artefact, "Missing 'class' attribute!\n");
goto aaarg;
}
@@ -138,7 +138,7 @@ QueryResult Artefact::exec(Query &query,
goto cleanup;
aaarg:
- PRACRO_ERR(artefact, "Artefact comm error (%d)!\n", atf_get_last_error(atfh));
+ ERR(artefact, "Artefact comm error (%d)!\n", atf_get_last_error(atfh));
cleanup:
if(root) atf_free_result_node(root);
diff --git a/server/src/connection.cc b/server/src/connection.cc
index 17ec942..849a90c 100644
--- a/server/src/connection.cc
+++ b/server/src/connection.cc
@@ -47,7 +47,7 @@ static bool did_commit = false;
Connection::Connection(Environment &e, std::string sid, bool c, bool d)
: env(e), parser(&transaction)
{
- PRACRO_DEBUG(connection, "[%p] CREATE\n", this);
+ DEBUG(connection, "[%p] CREATE\n", this);
sessionid = sid;
docommit = c;
@@ -62,7 +62,7 @@ Connection::Connection(Environment &e, std::string sid, bool c, bool d)
Connection::~Connection()
{
- PRACRO_DEBUG(connection, "[%p] DESTROY\n", this);
+ DEBUG(connection, "[%p] DESTROY\n", this);
}
void Connection::commit(Session *session)
@@ -103,7 +103,7 @@ bool Connection::handle(const char *data, size_t size)
}
if(session == NULL) {
- PRACRO_ERR(connection, "New session could not be created.");
+ ERR(connection, "New session could not be created.");
response = error_box(xml_encode("New session could not be created."));
return true;
}
@@ -133,7 +133,7 @@ bool Connection::handle(const char *data, size_t size)
return true;
}
} catch(...) {
- PRACRO_ERR(server, "Failed to parse data!\n");
+ ERR(server, "Failed to parse data!\n");
response = error_box(xml_encode("XML Parse error."));
return true;
}
diff --git a/server/src/database.cc b/server/src/database.cc
index 47cd877..81b495f 100644
--- a/server/src/database.cc
+++ b/server/src/database.cc
@@ -39,19 +39,21 @@ Database::Database(std::string _backend, std::string _host, std::string _port, s
dao = NULL;
#ifndef WITHOUT_DB
if(_backend == "pgsql") {
- PRACRO_DEBUG(db, "construct(%s, %s, %s, %s, %s)\n", _host.c_str(), _port.c_str(), _user.c_str(), _passwd.c_str(), _dbname.c_str());
+ DEBUG(db, "construct(%s, %s, %s, %s, %s)\n",\
+ _host.c_str(), _port.c_str(), _user.c_str(),
+ _passwd.c_str(), _dbname.c_str());
dao = new PracroDAOPgsql(_host, _port, _user, _passwd, _dbname);
return;
}
#endif/*WITHOUT_DB*/
if(_backend == "testdb") {
- PRACRO_DEBUG(db, "Running with 'testdb'\n");
+ DEBUG(db, "Running with 'testdb'\n");
Data data;
dao = new PracroDAOTest(data, true);
return;
}
- PRACRO_ERR(db, "Cannot find database backend \"%s\"", _backend.c_str());
+ ERR(db, "Cannot find database backend \"%s\"", _backend.c_str());
}
Database::~Database()
diff --git a/server/src/database.h b/server/src/database.h
index 9b08801..ca0458d 100644
--- a/server/src/database.h
+++ b/server/src/database.h
@@ -50,9 +50,9 @@ public:
time_t now = time(NULL)) {
if(!dao) return;
mutex.lock();
- PRACRO_DEBUG(db, "%s, %s, %s,...\n",
- user.c_str(), patientid.c_str(),
- macro.attributes["name"].c_str());
+ DEBUG(db, "%s, %s, %s,...\n",
+ user.c_str(), patientid.c_str(),
+ macro.attributes["name"].c_str());
dao->commitTransaction(user, patientid, macro, fields, now);
mutex.unlock();
}
@@ -63,8 +63,8 @@ public:
time_t oldest = 0) {
if(!dao) return Values();
mutex.lock();
- PRACRO_DEBUG(db, "%s, <%u fieldnames>, %ld\n",
- patientid.c_str(), fieldnames.size(), oldest);
+ DEBUG(db, "%s, <%u fieldnames>, %ld\n",
+ patientid.c_str(), fieldnames.size(), oldest);
Values values = dao->getLatestValues(patientid, NULL, fieldnames, oldest);
mutex.unlock();
return values;
@@ -74,8 +74,8 @@ public:
bool checkMacro(std::string patientid,
std::string macro,
time_t oldest = 0) {
- PRACRO_DEBUG(db, "%s, %s, %ld\n",
- patientid.c_str(), macro.c_str(), oldest);
+ DEBUG(db, "%s, %s, %ld\n",
+ patientid.c_str(), macro.c_str(), oldest);
if(!dao) return false;
mutex.lock();
bool res = dao->nrOfCommits(patientid, macro, oldest) > 0;
@@ -85,8 +85,8 @@ public:
// Get latest resume of a given macro
std::string getResume(std::string patientid, Macro &macro, time_t oldest) {
- PRACRO_DEBUG(db, "%s, %s, %ld\n",
- patientid.c_str(), macro.attributes["name"].c_str(), oldest);
+ DEBUG(db, "%s, %s, %ld\n",
+ patientid.c_str(), macro.attributes["name"].c_str(), oldest);
if(!dao) return "";
Fieldnames fn;
fn.push_back("journal.resume");
diff --git a/server/src/debug.cc b/server/src/debug.cc
index 8bb45db..1affa23 100644
--- a/server/src/debug.cc
+++ b/server/src/debug.cc
@@ -27,27 +27,32 @@
*/
#include "debug.h"
-#include <config.h>
-
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#include "log.h"
+
+static FILE *logfp = stderr;
+
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
-struct __pracro_debug_channel
+struct __debug_channel
{
- char name[64];
- unsigned flags;
+ char name[16];
+ unsigned flags;
};
-static const char * const debug_class_str[] = { "fixme", "info", "warn", "err", "debug" };
-#define __PRACRO_DEBUG_CHANNEL_MAX 256
-static struct __pracro_debug_channel debug_channel[__PRACRO_DEBUG_CHANNEL_MAX];
+static const char * const debug_class_str[] =
+ { "fixme", "err", "warn", "info", "debug" };
+
+#define __DEBUG_CHANNEL_MAX 256
+
+static struct __debug_channel debug_channel[__DEBUG_CHANNEL_MAX];
static unsigned n_debug_channel = 0;
-static unsigned debug_flags = (1 << __pracro_class_err) | (1 << __pracro_class_fixme);
+static unsigned debug_flags = (1 << __class_err) | (1 << __class_fixme);
-static int __pracro_debug_enabled(const enum __pracro_debug_class cl, const char *ch)
+static int __debug_enabled(const enum __debug_class cl, const char *ch)
{
unsigned i;
for(i = 0; i < n_debug_channel; i++) {
@@ -60,79 +65,125 @@ static int __pracro_debug_enabled(const enum __pracro_debug_class cl, const char
#ifdef WITH_DEBUG
-int __pracro_debug(const char *func, const int line, const enum __pracro_debug_class cl, const char *ch, const char *fmt, ...)
+int __debug(const char *func, const int line,
+ const enum __debug_class cl,
+ const char *ch, const char *fmt, ...)
{
int ret = 0;
- if(__pracro_debug_enabled(cl, ch)) {
+ if(__debug_enabled(cl, ch)) {
if((unsigned)cl < NELEM(debug_class_str))
- ret += fprintf(stderr, "%s:%s:%s:%d ", debug_class_str[(unsigned)cl], ch, func, line);
+ ret += fprintf(logfp, "%s:%s:%s:%d ",
+ debug_class_str[(unsigned)cl], ch, func, line);
if(fmt) {
va_list va;
va_start(va, fmt);
- ret += vfprintf(stderr, fmt, va);
+ ret += vfprintf(logfp, fmt, va);
va_end(va);
}
}
- if(ret)
- fflush(stderr);
+ if(ret){
+ fflush(logfp);
+ }
return ret;
}
-int __pracro_debug_va(const char *func, const int line, const enum __pracro_debug_class cl, const char *ch, const char *fmt, va_list va)
+int __debug_va(const char *func, const int line,
+ const enum __debug_class cl,
+ const char *ch, const char *fmt, va_list va)
{
int ret = 0;
- if(__pracro_debug_enabled(cl, ch)) {
+ if(__debug_enabled(cl, ch)) {
if((unsigned)cl < NELEM(debug_class_str))
- ret += fprintf(stderr, "%s:%s:%s:%d ", debug_class_str[(unsigned)cl], ch, func, line);
+ ret += fprintf(logfp, "%s:%s:%s:%d ",
+ debug_class_str[(unsigned)cl], ch, func, line);
if(fmt)
- ret += vfprintf(stderr, fmt, va);
+ ret += vfprintf(logfp, fmt, va);
}
- if(ret)
- fflush(stderr);
+ if(ret) {
+ fflush(logfp);
+ }
return ret;
}
-void pracro_debug_init(void)
-{
-}
-
-#else
+#endif
-/* FIXME: should do syslog here... */
-int __pracro_log(const char *func, const int line, const enum __pracro_debug_class cl, const char *ch, const char *fmt, ...)
+int __log(const char *func, const int line, const enum __debug_class cl,
+ const char *ch, const char *fmt, ...)
{
+ std::string logmsg;
+ char str[8];
+
+#ifdef WITH_DEBUG
int ret = 0;
- if(__pracro_debug_enabled(cl, ch)) {
+#endif
+ if(__debug_enabled(cl, ch)) {
if((unsigned)cl < NELEM(debug_class_str))
- ret += fprintf(stderr, "%s:%s:%s:%d ", debug_class_str[(unsigned)cl], ch, func, line);
+ if((unsigned)cl < NELEM(debug_class_str))
+#ifdef WITH_DEBUG
+ ret = fprintf(logfp, "%s:%s:%s:%d ", debug_class_str[(unsigned)cl], ch, func, line);
+#endif
+ sprintf(str, "%d", line);
+ logmsg = std::string(debug_class_str[(unsigned)cl]) + ":" + ch + ":" + func + ":" + str;
if(fmt) {
va_list va;
va_start(va, fmt);
- ret += vfprintf(stderr, fmt, va);
+#ifdef WITH_DEBUG
+ ret += vfprintf(logfp, fmt, va);
+#endif
+ char* ptr;
+ if(vasprintf(&ptr, fmt, va) == -1) {}
+ logmsg += ptr;
va_end(va);
}
}
- return ret;
+#ifdef WITH_DEBUG
+ if(ret) {
+ fprintf(logfp, "\n");
+ fflush(logfp);
+ }
+#endif
+ log(logmsg);
+ return logmsg.size();
}
-/* FIXME: should do syslog here... */
-int __pracro_log_va(const char *func, const int line, const enum __pracro_debug_class cl, const char *ch, const char *fmt, va_list va)
+int __log_va(const char *func, const int line, const enum __debug_class cl,
+ const char *ch, const char *fmt, va_list va)
{
+ std::string logmsg;
+ char str[8];
+#ifdef WITH_DEBUG
int ret = 0;
- if(__pracro_debug_enabled(cl, ch)) {
+#endif
+ if(__debug_enabled(cl, ch)) {
if((unsigned)cl < NELEM(debug_class_str))
- ret += fprintf(stderr, "%s:%s:%s:%d ", debug_class_str[(unsigned)cl], ch, func, line);
- if(fmt)
- ret += vfprintf(stderr, fmt, va);
+#ifdef WITH_DEBUG
+ ret = fprintf(logfp, "%s:%s:%s:%d ", debug_class_str[(unsigned)cl], ch, func, line);
+#endif
+ sprintf(str, "%d", line);
+ logmsg = std::string(debug_class_str[(unsigned)cl]) + ":" + ch + ":" + func + ":" + str;
+ if(fmt) {
+#ifdef WITH_DEBUG
+ ret += vfprintf(logfp, fmt, va);
+#endif
+ char* ptr;
+ if(vasprintf(&ptr, fmt, va) == -1) {}
+ logmsg += ptr;
+ }
}
- return ret;
+#ifdef WITH_DEBUG
+ if(ret) {
+ fprintf(logfp, "\n");
+ fflush(logfp);
+ }
+#endif
+ return logmsg.size();
}
-void pracro_debug_init(void)
+void debug_init(FILE *fp)
{
+ logfp = fp;
}
-#endif
/*
* fmt := [set[,set]*]*
@@ -140,7 +191,7 @@ void pracro_debug_init(void)
* | class[+-]channel
* | [+-]all
*/
-void pracro_debug_parse(const char *fmt)
+void debug_parse(const char *fmt)
{
char *s;
char *next;
@@ -154,14 +205,14 @@ void pracro_debug_parse(const char *fmt)
unsigned i;
if((next = strchr(opt, ','))) *next++ = '\0';
char *p = opt + strcspn(opt, "+-");
- if(!*p) p = opt; /* All chars -> a channel name */
+ if(!*p) p = opt; // All chars -> a channel name
if(p > opt) {
- /* we have a class */
+ // we have a class
for(i = 0; i < NELEM(debug_class_str); i++) {
int n = strlen(debug_class_str[i]);
if(n != (p - opt)) continue;
if(!memcmp(opt, debug_class_str[i], n)) {
- /* Found the class */
+ // Found the class
if(*p == '+')
set = 1 << i;
else
@@ -188,7 +239,7 @@ void pracro_debug_parse(const char *fmt)
break;
}
}
- if(i == n_debug_channel && n_debug_channel < __PRACRO_DEBUG_CHANNEL_MAX) {
+ if(i == n_debug_channel && n_debug_channel < __DEBUG_CHANNEL_MAX) {
strcpy(debug_channel[i].name, p);
debug_channel[i].flags = (debug_flags & ~clr) | set;
n_debug_channel++;
diff --git a/server/src/debug.h b/server/src/debug.h
index 17dad10..a5f199d 100644
--- a/server/src/debug.h
+++ b/server/src/debug.h
@@ -16,19 +16,20 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * Pracro is distributed in the hope that it will be useful,
+ * Pentominos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Pracro; if not, write to the Free Software
+ * along with Pentominos; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#ifndef __PRACRO_DEBUG_H__
-#define __PRACRO_DEBUG_H__
+#ifndef __PENTOMINOS_DEBUG_H__
+#define __PENTOMINOS_DEBUG_H__
#include <stdarg.h>
+#include <stdio.h>
#ifdef HAVE_CONFIG_H
// For USE_EFENCE
@@ -51,83 +52,82 @@
#endif/*USE_EFENCE*/
#endif/*HAVE_CONFIG*/
-void pracro_debug_init(void);
-void pracro_debug_parse(const char *fmt);
+void debug_init(FILE *fp);
+void debug_parse(const char *fmt);
-enum __pracro_debug_class
+enum __debug_class
{
- __pracro_class_fixme,
- __pracro_class_info,
- __pracro_class_warn,
- __pracro_class_err,
- __pracro_class_debug
+ __class_fixme = 0,
+ __class_err = 1,
+ __class_warn = 2,
+ __class_info = 3,
+ __class_debug = 4
};
-#ifndef __GNUC__
-#error "Need gcc for special debug macro expansions. Please define for other compilers."
-#endif
-
#ifdef WITH_DEBUG
-int __pracro_debug(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, ...) __attribute__((format (printf,5,6)));
-int __pracro_debug_va(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, va_list va);
-
-/* gcc preprocessor magic ahead */
-#define __PRACRO_DEBUG_PRINT(cl, ch, fmt...) \
- do { __pracro_debug(__func__, __LINE__, cl, ch, fmt); } while(0)
-#define __PRACRO_DEBUG_PRINT_VA(cl, ch, fmt, a) \
- do { __pracro_debug_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
-#define __PRACRO_DEBUG(cl, ch, fmt...) __PRACRO_DEBUG_PRINT(__pracro_class##cl, #ch, fmt)
-#define __PRACRO_DEBUG_VA(cl, ch, fmt, a) __PRACRO_DEBUG_PRINT_VA(__pracro_class##cl, #ch, fmt, a)
-
-#define PRACRO_FIXME(ch, fmt...) __PRACRO_DEBUG(_fixme, ch, fmt)
-#define PRACRO_INFO(ch, fmt...) __PRACRO_DEBUG(_info, ch, fmt)
-#define PRACRO_WARN(ch, fmt...) __PRACRO_DEBUG(_warn, ch, fmt)
-#define PRACRO_ERR(ch, fmt...) __PRACRO_DEBUG(_err, ch, fmt)
-#define PRACRO_DEBUG(ch, fmt...) __PRACRO_DEBUG(_debug, ch, fmt)
-#define PRACRO_FIXME_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_fixme, ch, fmt, a)
-#define PRACRO_INFO_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_info, ch, fmt, a)
-#define PRACRO_WARN_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_warn, ch, fmt, a)
-#define PRACRO_ERR_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_err, ch, fmt, a)
-#define PRACRO_DEBUG_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_debug, ch, fmt, a)
-
-#define PRACRO_INFO_LOG(ch, fmt...) PRACRO_INFO(ch, fmt)
-#define PRACRO_WARN_LOG(ch, fmt...) PRACRO_WARN(ch, fmt)
-#define PRACRO_ERR_LOG(ch, fmt...) PRACRO_ERR(ch, fmt)
-#define PRACRO_INFO_LOG_VA(ch, fmt, a) PRACRO_INFO_VA(ch, fmt, a)
-#define PRACRO_WARN_LOG_VA(ch, fmt, a) PRACRO_WARN_VA(ch, fmt, a)
-#define PRACRO_ERR_LOG_VA(ch, fmt, a) PRACRO_ERR_VA(ch, fmt, a)
+int __debug(const char *func, const int line, enum __debug_class cl,
+ const char *ch, const char *fmt, ...)
+ __attribute__((format (printf,5,6)));
+
+int __debug_va(const char *func, const int line, enum __debug_class cl,
+ const char *ch, const char *fmt, va_list va);
+
+#define __DEBUG_PRINT(cl, ch, fmt...) \
+ do { __debug(__func__, __LINE__, cl, ch, fmt); } while(0)
+#define __DEBUG_PRINT_VA(cl, ch, fmt, a) \
+ do { __debug_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
+#define __DEBUG(cl, ch, fmt...) \
+ __DEBUG_PRINT(__class##cl, #ch, fmt)
+#define __DEBUG_VA(cl, ch, fmt, a) \
+ __DEBUG_PRINT_VA(__class##cl, #ch, fmt, a)
+
+#define FIXME(ch, fmt...) __DEBUG(_fixme, ch, fmt)
+#define ERR(ch, fmt...) __DEBUG(_err, ch, fmt)
+#define WARN(ch, fmt...) __DEBUG(_warn, ch, fmt)
+#define INFO(ch, fmt...) __DEBUG(_info, ch, fmt)
+#define DEBUG(ch, fmt...) __DEBUG(_debug, ch, fmt)
+
+#define FIXME_VA(ch, fmt, a) __DEBUG_VA(_fixme, ch, fmt, a)
+#define ERR_VA(ch, fmt, a) __DEBUG_VA(_err, ch, fmt, a)
+#define WARN_VA(ch, fmt, a) __DEBUG_VA(_warn, ch, fmt, a)
+#define INFO_VA(ch, fmt, a) __DEBUG_VA(_info, ch, fmt, a)
+#define DEBUG_VA(ch, fmt, a) __DEBUG_VA(_debug, ch, fmt, a)
#else
-/* If we compile without debug support, we want them all to go away */
-#define PRACRO_FIXME(ch, fmt...)
-#define PRACRO_INFO(ch, fmt...)
-#define PRACRO_WARN(ch, fmt...)
-#define PRACRO_ERR(ch, fmt...)
-#define PRACRO_DEBUG(ch, fmt...)
-#define PRACRO_FIXME_VA(ch, fmt...)
-#define PRACRO_INFO_VA(ch, fmt...)
-#define PRACRO_WARN_VA(ch, fmt...)
-#define PRACRO_ERR_VA(ch, fmt...)
-#define PRACRO_DEBUG_VA(ch, fmt...)
-
-int __pracro_log(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, ...) __attribute__((format (printf,5,6)));
-int __pracro_log_va(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, va_list va);
-
-#define __PRACRO_LOG_PRINT(cl, ch, fmt...) \
- do { __pracro_log(__func__, __LINE__, cl, ch, fmt); } while(0)
-#define __PRACRO_LOG_PRINT_VA(cl, ch, fmt, a) \
- do { __pracro_log_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
-#define __PRACRO_LOG(cl, ch, fmt...) __PRACRO_LOG_PRINT(__pracro_class##cl, #ch, fmt)
-#define __PRACRO_LOG_VA(cl, ch, fmt, a) __PRACRO_LOG_PRINT_VA(__pracro_class##cl, #ch, fmt, a)
-
-#define PRACRO_INFO_LOG(ch, fmt...) __PRACRO_LOG(_info, ch, fmt)
-#define PRACRO_WARN_LOG(ch, fmt...) __PRACRO_LOG(_warn, ch, fmt)
-#define PRACRO_ERR_LOG(ch, fmt...) __PRACRO_LOG(_err, ch, fmt)
-#define PRACRO_INFO_LOG_VA(ch, fmt, a) __PRACRO_LOG_VA(_info, ch, fmt, a)
-#define PRACRO_WARN_LOG_VA(ch, fmt, a) __PRACRO_LOG_VA(_warn, ch, fmt, a)
-#define PRACRO_ERR_LOG_VA(ch, fmt, a) __PRACRO_LOG_VA(_err, ch, fmt, a)
+// If we compile without debug support, we want them all to go away
+#define FIXME(ch, fmt...)
+#define INFO(ch, fmt...)
+#define WARN(ch, fmt...)
+#define ERR(ch, fmt...)
+#define DEBUG(ch, fmt...)
+#define FIXME_VA(ch, fmt...)
+#define INFO_VA(ch, fmt...)
+#define WARN_VA(ch, fmt...)
+#define ERR_VA(ch, fmt...)
+#define DEBUG_VA(ch, fmt...)
#endif/*WITH_DEBUG*/
-#endif/*__PRACRO_DEBUG_H__*/
+int __log(const char *func, const int line,
+ enum __debug_class cl, const char *ch, const char *fmt, ...)
+ __attribute__((format (printf,5,6)));
+
+int __log_va(const char *func, const int line, enum __debug_class cl,
+ const char *ch, const char *fmt, va_list va);
+
+#define __LOG_PRINT(cl, ch, fmt...) \
+ do { __log(__func__, __LINE__, cl, ch, fmt); } while(0)
+#define __LOG_PRINT_VA(cl, ch, fmt, a) \
+ do { __log_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
+#define __LOG(cl, ch, fmt...) __LOG_PRINT(__class##cl, #ch, fmt)
+#define __LOG_VA(cl, ch, fmt, a) __LOG_PRINT_VA(__class##cl, #ch, fmt, a)
+
+#define INFO_LOG(ch, fmt...) __LOG(_info, ch, fmt)
+#define WARN_LOG(ch, fmt...) __LOG(_warn, ch, fmt)
+#define ERR_LOG(ch, fmt...) __LOG(_err, ch, fmt)
+#define INFO_LOG_VA(ch, fmt, a) __LOG_VA(_info, ch, fmt, a)
+#define WARN_LOG_VA(ch, fmt, a) __LOG_VA(_warn, ch, fmt, a)
+#define ERR_LOG_VA(ch, fmt, a) __LOG_VA(_err, ch, fmt, a)
+
+#endif/*__PENTOMINOS_DEBUG_H__*/
diff --git a/server/src/entitylist.cc b/server/src/entitylist.cc
index 3ec15a5..23acbf4 100644
--- a/server/src/entitylist.cc
+++ b/server/src/entitylist.cc
@@ -56,7 +56,7 @@ static std::vector<std::string> listdir(std::string path)
DIR* dir = opendir(path.c_str());
if(!dir) {
- PRACRO_ERR(entitylist, "Could not open directory: %s\n", path.c_str());
+ ERR(entitylist, "Could not open directory: %s\n", path.c_str());
return files;
}
@@ -117,10 +117,10 @@ void EntityList::rescan()
while(i != end()) {
EntityListItem::iterator j = i->second.begin();
while(j != i->second.end()) {
- PRACRO_DEBUG(entitylist, "%s - v%s file: %s\n",
- i->first.c_str(),
- ((std::string)j->first).c_str(),
- j->second.c_str());
+ DEBUG(entitylist, "%s - v%s file: %s\n",
+ i->first.c_str(),
+ ((std::string)j->first).c_str(),
+ j->second.c_str());
j++;
}
i++;
@@ -136,7 +136,7 @@ bool EntityList::removeFile(std::string file)
EntityListItem::iterator j = i->second.begin();
while(j != i->second.end()) {
if(file == j->second) {
- PRACRO_DEBUG(entitylist, "Removing file: %s\n", file.c_str());
+ DEBUG(entitylist, "Removing file: %s\n", file.c_str());
i->second.erase(j);
if(i->second.size() == 0) erase(i);
return true;
@@ -160,10 +160,10 @@ void EntityList::updateList()
while(inotify.hasEvents()) {
INotify::Event event = inotify.getNextEvent();
- PRACRO_DEBUG(entitylist, "Handling event %s on %s, with param %s\n",
- event.maskstr().c_str(),
- event.name().c_str(),
- event.file().c_str());
+ DEBUG(entitylist, "Handling event %s on %s, with param %s\n",
+ event.maskstr().c_str(),
+ event.name().c_str(),
+ event.file().c_str());
if(event.isDir()) {
if(event.isCreateEvent()) {
@@ -206,10 +206,10 @@ std::string EntityList::getLatestVersion(std::string entity) throw(Exception)
throw Exception("Entity ("+entityname+") ["+entity+"] does not exist.");
}
- PRACRO_DEBUG(entitylist, "Search for %s - found %s v%s\n",
- entity.c_str(),
- mli.begin()->second.c_str(),
- ((std::string)mli.begin()->first).c_str());
+ DEBUG(entitylist, "Search for %s - found %s v%s\n",
+ entity.c_str(),
+ mli.begin()->second.c_str(),
+ ((std::string)mli.begin()->first).c_str());
return mli.begin()->second;
}
diff --git a/server/src/httpd.cc b/server/src/httpd.cc
index e3c287e..e47cefc 100644
--- a/server/src/httpd.cc
+++ b/server/src/httpd.cc
@@ -176,7 +176,7 @@ void Httpd::listen(unsigned short int port,
MHD_OPTION_END);
if(!d) {
- //PRACRO_ERR(server, "Failed to initialise MHD_start_daemon!\n");
+ //ERR(server, "Failed to initialise MHD_start_daemon!\n");
return;
}
}
@@ -198,7 +198,7 @@ void Httpd::listen_ssl(unsigned short int port,
MHD_OPTION_END);
if(!d_ssl) {
- // PRACRO_ERR(server, "Failed to initialise MHD_start_daemon!\n");
+ //ERR(server, "Failed to initialise MHD_start_daemon!\n");
return;
}
}
diff --git a/server/src/inotify.cc b/server/src/inotify.cc
index 1515387..dd5ec52 100644
--- a/server/src/inotify.cc
+++ b/server/src/inotify.cc
@@ -97,10 +97,10 @@ INotify::Event::Event(struct inotify_event *event, std::string name)
this->_file = "";
}
- PRACRO_DEBUG(inotify, "Event [%s] %s (%s)\n",
- mask2asc(_mask).c_str(),
- _name.c_str(),
- _file.c_str());
+ DEBUG(inotify, "Event [%s] %s (%s)\n",
+ mask2asc(_mask).c_str(),
+ _name.c_str(),
+ _file.c_str());
}
bool INotify::Event::isAttributeChangeEvent()
@@ -247,7 +247,7 @@ static inline bool isdir(std::string name)
void INotify::addDirectory(std::string name, depth_t depth, uint32_t mask)
{
- PRACRO_DEBUG(inotify, "Adding dir: %s\n", name.c_str());
+ DEBUG(inotify, "Adding dir: %s\n", name.c_str());
int depth_mask = 0;
if(depth == WATCH_DEEP || depth == WATCH_DEEP_FOLLOW) {
@@ -256,8 +256,8 @@ void INotify::addDirectory(std::string name, depth_t depth, uint32_t mask)
DIR *dir = opendir(name.c_str());
if(!dir) {
- PRACRO_ERR(inotify, "Could not open directory: %s - %s\n",
- name.c_str(), strerror(errno));
+ ERR(inotify, "Could not open directory: %s - %s\n",
+ name.c_str(), strerror(errno));
return;
}
@@ -277,7 +277,7 @@ void INotify::addDirectory(std::string name, depth_t depth, uint32_t mask)
int wd = inotify_add_watch(ifd, name.c_str(), mask | IN_ONLYDIR | depth_mask);
if(wd == -1) {
- PRACRO_ERR(inotify, "INotify: Add watch failed on %s\n", name.c_str());
+ ERR(inotify, "INotify: Add watch failed on %s\n", name.c_str());
return;
}
diff --git a/server/src/journal.cc b/server/src/journal.cc
index 288f7c2..1f79c9f 100644
--- a/server/src/journal.cc
+++ b/server/src/journal.cc
@@ -44,13 +44,13 @@ void Journal::addEntry(Transaction &transaction, Commit &commit,
}
if(index >= templ->macros.size()) {
- PRACRO_ERR(journal, "Could not find macro %s in template %s\n",
- commit.macro.c_str(), templ->attributes["name"].c_str());
+ ERR(journal, "Could not find macro %s in template %s\n",
+ commit.macro.c_str(), templ->attributes["name"].c_str());
// return;
} else {
- PRACRO_DEBUG(journal, "Found macro %s as index %u in template %s\n",
- commit.macro.c_str(), index,
- templ->attributes["name"].c_str());
+ DEBUG(journal, "Found macro %s as index %u in template %s\n",
+ commit.macro.c_str(), index,
+ templ->attributes["name"].c_str());
}
if(entrylist.size() == 0) {
@@ -58,8 +58,8 @@ void Journal::addEntry(Transaction &transaction, Commit &commit,
if(patientID() == "")setPatientID(transaction.cpr);
}
- PRACRO_DEBUG(journal, "addEntry: template(%s)\n",
- templ->attributes["name"].c_str());
+ DEBUG(journal, "addEntry: template(%s)\n",
+ templ->attributes["name"].c_str());
// Test if the username or the cpr has changed...
// if so, commit and clear the list.
diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc
index 9d76c8f..734afcf 100644
--- a/server/src/journal_commit.cc
+++ b/server/src/journal_commit.cc
@@ -65,11 +65,10 @@ static int mwrite(int sock, const char *fmt, ...)
va_end(args);
if(sock != -1 && write(sock, buffer, l) != l) {
- PRACRO_ERR_LOG(journal,
- "write did not write all the bytes in the buffer.\n");
+ ERR_LOG(journal, "write did not write all the bytes in the buffer.\n");
}
- PRACRO_DEBUG(journal, "%s", buffer);
+ DEBUG(journal, "%s", buffer);
free(buffer);
return l;
@@ -90,7 +89,7 @@ int journal_commit(const char *cpr, const char *user,
struct hostent *he;
he = gethostbyname(addr);
if(!he || !he->h_length) {
- PRACRO_ERR_LOG(journal, "gethostbyname(%s) failed (errno=%d)!\n", addr, errno);
+ ERR_LOG(journal, "gethostbyname(%s) failed (errno=%d)!\n", addr, errno);
return -1;
}
@@ -105,12 +104,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) {
- PRACRO_ERR_LOG(journal, "Socket() failed!\n");
+ ERR_LOG(journal, "Socket() failed!\n");
return -1;
}
if(connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- PRACRO_ERR_LOG(journal, "Connect() failed!\n");
+ ERR_LOG(journal, "Connect() failed!\n");
perror(":");
return -1;
}
@@ -133,9 +132,9 @@ int journal_commit(const char *cpr, const char *user,
// send body
if(sock != -1 && write(sock, resume.c_str(), resume.size()) != (ssize_t)resume.size()) {
- PRACRO_ERR_LOG(journal, "write did not write all the bytes in the buffer.\n");
+ ERR_LOG(journal, "write did not write all the bytes in the buffer.\n");
}
- PRACRO_DEBUG(journal, "%s\n", buf);
+ DEBUG(journal, "%s\n", buf);
#ifndef WITHOUT_UPLOADSERVER
// close socket
diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc
index fdb1248..8e154ed 100644
--- a/server/src/luaquerymapper.cc
+++ b/server/src/luaquerymapper.cc
@@ -76,7 +76,7 @@ void LUAQueryMapper::addQueryResult(QueryResult &result) throw(Exception)
{
std::string preload = loadresultstring(result);
- PRACRO_DEBUG(querymapper, "Preload:\n%s\n", preload.c_str());
+ DEBUG(querymapper, "Preload:\n%s\n", preload.c_str());
if(luaL_loadbuffer(L, preload.c_str(), preload.size(), "preload")) {
error(lua_tostring(L, lua_gettop(L)));
@@ -106,7 +106,7 @@ Value LUAQueryMapper::map(const std::string &mapper) throw(Exception)
return v;
}
- PRACRO_DEBUG(querymapper, "Mapper: %s\n", mapper.c_str());
+ DEBUG(querymapper, "Mapper: %s\n", mapper.c_str());
// Load the mapper
if(luaL_loadbuffer(L, mapper.c_str(), mapper.size(), "mapper")) {
@@ -150,8 +150,8 @@ Value LUAQueryMapper::map(const std::string &mapper) throw(Exception)
v.value = lua_tostring(L, lua_gettop(L));
lua_pop(L, 1);
- PRACRO_DEBUG(querymapper, "Result: value=%s, src=%s, time=%d\n",
- v.value.c_str(), v.source.c_str(), (int)v.timestamp);
+ DEBUG(querymapper, "Result: value=%s, src=%s, time=%d\n",
+ v.value.c_str(), v.source.c_str(), (int)v.timestamp);
return v;
}
@@ -189,7 +189,7 @@ std::string LUAQueryMapper::automap(const std::string &name)
"end\n"
"return value, timestamp, source\n";
- PRACRO_DEBUG(widget, "Automap:\n%s\n", automapstring.c_str());
+ DEBUG(widget, "Automap:\n%s\n", automapstring.c_str());
return automapstring;
}
diff --git a/server/src/luaresume.cc b/server/src/luaresume.cc
index 099c3bd..eb6d90b 100644
--- a/server/src/luaresume.cc
+++ b/server/src/luaresume.cc
@@ -62,7 +62,7 @@ LUAResume::LUAResume(Commit &c)
{
L = luaL_newstate();
if(L == NULL) {
- PRACRO_ERR(luaresume, "Could not create LUA state.\n");
+ ERR(luaresume, "Could not create LUA state.\n");
return;
}
@@ -82,7 +82,7 @@ LUAResume::~LUAResume()
std::string LUAResume::getValue(std::string name)
{
if(commit.fields.find(name) == commit.fields.end()) {
- PRACRO_ERR(luaresume, "LUAResume: No such field '%s'\n", name.c_str());
+ ERR(luaresume, "LUAResume: No such field '%s'\n", name.c_str());
return "";
}
@@ -92,11 +92,11 @@ std::string LUAResume::getValue(std::string name)
std::string LUAResume::run(std::string program)
{
if(L == NULL) {
- PRACRO_ERR(luaresume, "LUA state not initialized!");
+ ERR(luaresume, "LUA state not initialized!");
return false;
}
- PRACRO_DEBUG(luaresume, "Running %s\n", program.c_str());
+ DEBUG(luaresume, "Running %s\n", program.c_str());
/*
lua_pushstring(L, value.toStdString().c_str());
@@ -110,23 +110,23 @@ std::string LUAResume::run(std::string program)
if(luaL_loadbuffer(L, program.c_str(), program.size(),
"lua resume generator")) {
- PRACRO_ERR(luaresume, "loadbufer: %s\n", lua_tostring(L, lua_gettop(L)));
+ ERR(luaresume, "loadbufer: %s\n", lua_tostring(L, lua_gettop(L)));
return false;
}
// Run the loaded code
if(lua_pcall(L, 0, LUA_MULTRET, 0)) {
- PRACRO_ERR(luaresume, "pcall: %s\n" , lua_tostring(L, lua_gettop(L)));
+ ERR(luaresume, "pcall: %s\n" , lua_tostring(L, lua_gettop(L)));
return false;
}
if(top != lua_gettop(L) - 1) {
- PRACRO_ERR(luaresume, "Program did not return a single value.\n");
+ ERR(luaresume, "Program did not return a single value.\n");
return false;
}
if(lua_isstring(L, lua_gettop(L)) == false) {
- PRACRO_ERR(luaresume, "Program did not return a string value.\n");
+ ERR(luaresume, "Program did not return a string value.\n");
return false;
}
@@ -138,5 +138,5 @@ std::string LUAResume::run(std::string program)
void LUAResume::error(std::string message)
{
- PRACRO_ERR(luaresume, "LUA ERROR: %s\n", message.c_str());
+ ERR(luaresume, "LUA ERROR: %s\n", message.c_str());
}
diff --git a/server/src/macroheaderparser.cc b/server/src/macroheaderparser.cc
index 48ed381..0ad18d4 100644
--- a/server/src/macroheaderparser.cc
+++ b/server/src/macroheaderparser.cc
@@ -50,12 +50,12 @@
void MacroHeaderParser::error(const char* fmt, ...)
{
- PRACRO_ERR_LOG(macro, "Error in MacroHeaderParser: ");
+ ERR_LOG(macro, "Error in MacroHeaderParser: ");
{
va_list argp;
va_start(argp, fmt);
- PRACRO_ERR_LOG_VA(macro, fmt, argp);
+ ERR_LOG_VA(macro, fmt, argp);
va_end(argp);
fprintf(stderr, "\n");
@@ -80,7 +80,7 @@ MacroHeaderParser::MacroHeaderParser(std::string macrofile)
file = macrofile;
- PRACRO_DEBUG(macro, "Using macro file: %s\n", macrofile.c_str());
+ DEBUG(macro, "Using macro file: %s\n", macrofile.c_str());
fd = open(macrofile.c_str(), O_RDONLY);
if(fd == -1) error("Could not open file %s", macrofile.c_str());
@@ -110,12 +110,12 @@ int MacroHeaderParser::readData(char *data, size_t size)
// tag, and can dismiss the rest of the document.
if(fd == -1) {
- PRACRO_ERR_LOG(macro, "Invalid file descriptor.\n");
+ ERR_LOG(macro, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- PRACRO_ERR_LOG(macro, "Could not read...%s\n", strerror(errno));
+ ERR_LOG(macro, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -125,10 +125,11 @@ void MacroHeaderParser::parseError(const char *buf, size_t len, std::string erro
{
if(m) return; // Ignore "unclosed token" errors when the macro tag has been parsed.
- PRACRO_ERR_LOG(macro, "MacroHeaderParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str());
- PRACRO_ERR_LOG(macro, "\tBuffer %u bytes: [", len);
+ ERR_LOG(macro, "MacroHeaderParser[%s] error at line %d: %s\n",
+ file.c_str(), lineno, error.c_str());
+ ERR_LOG(macro, "\tBuffer %u bytes: [", len);
if(fwrite(buf, len, 1, stderr) != len) {}
- PRACRO_ERR_LOG(macro, "]\n");
+ ERR_LOG(macro, "]\n");
char *slineno;
if(asprintf(&slineno, " at line %d\n", lineno) != -1) {
diff --git a/server/src/macrolist.cc b/server/src/macrolist.cc
index 908de1e..2ce4d0c 100644
--- a/server/src/macrolist.cc
+++ b/server/src/macrolist.cc
@@ -43,11 +43,11 @@ MacroList::MacroList(std::string path)
void MacroList::addFile(std::string file)
{
if(file.substr(file.size() - 4) != ".xml") {
- PRACRO_DEBUG(macrolist, "Skipping file: %s\n", file.c_str());
+ DEBUG(macrolist, "Skipping file: %s\n", file.c_str());
return;
}
- PRACRO_DEBUG(macrolist, "Adding file: %s\n", file.c_str());
+ DEBUG(macrolist, "Adding file: %s\n", file.c_str());
MacroHeaderParser parser(file);
try {
parser.parse();
@@ -56,7 +56,7 @@ void MacroList::addFile(std::string file)
macro->attributes["version"],
file);
} catch(Exception &e) {
- PRACRO_WARN(macrolist, "Skipping %s: %s\n", file.c_str(), e.what());
+ WARN(macrolist, "Skipping %s: %s\n", file.c_str(), e.what());
}
}
diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc
index 863c52e..eca189e 100644
--- a/server/src/macroparser.cc
+++ b/server/src/macroparser.cc
@@ -54,12 +54,12 @@
void MacroParser::error(const char* fmt, ...)
{
- PRACRO_ERR_LOG(macro, "Error in MacroParser: ");
+ ERR_LOG(macro, "Error in MacroParser: ");
{
va_list argp;
va_start(argp, fmt);
- PRACRO_ERR_LOG_VA(macro, fmt, argp);
+ ERR_LOG_VA(macro, fmt, argp);
va_end(argp);
fprintf(stderr, "\n");
@@ -87,7 +87,7 @@ MacroParser::MacroParser(std::string macrofile)
file = macrofile;
- PRACRO_DEBUG(macro, "Using macro file: %s\n", file.c_str());
+ DEBUG(macro, "Using macro file: %s\n", file.c_str());
fd = open(file.c_str(), O_RDONLY);
if(fd == -1) error("Could not open file %s", file.c_str());
@@ -293,12 +293,12 @@ void MacroParser::endTag(std::string name)
int MacroParser::readData(char *data, size_t size)
{
if(fd == -1) {
- PRACRO_ERR_LOG(macro, "Invalid file descriptor.\n");
+ ERR_LOG(macro, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- PRACRO_ERR_LOG(macro, "Could not read...%s\n", strerror(errno));
+ ERR_LOG(macro, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -306,10 +306,11 @@ int MacroParser::readData(char *data, size_t size)
void MacroParser::parseError(const char *buf, size_t len, std::string error, int lineno)
{
- PRACRO_ERR_LOG(macro, "MacroParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str());
- PRACRO_ERR_LOG(macro, "\tBuffer %u bytes: [", len);
+ ERR_LOG(macro, "MacroParser[%s] error at line %d: %s\n",
+ file.c_str(), lineno, error.c_str());
+ ERR_LOG(macro, "\tBuffer %u bytes: [", len);
if(fwrite(buf, len, 1, stderr) != len) {}
- PRACRO_ERR_LOG(macro, "]\n");
+ ERR_LOG(macro, "]\n");
char *slineno;
if(asprintf(&slineno, " at line %d\n", lineno) != -1) {
diff --git a/server/src/macrotool/macrotool.cc b/server/src/macrotool/macrotool.cc
index 40ca845..c41bc9a 100644
--- a/server/src/macrotool/macrotool.cc
+++ b/server/src/macrotool/macrotool.cc
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
char *xml_basedir = NULL;
char *debugstr = NULL;
- pracro_debug_init();
+ debug_init(stderr);
int option_index = 0;
while(1) {
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
}
if(debugstr) {
- pracro_debug_parse(debugstr);
+ debug_parse(debugstr);
}
// Load config
diff --git a/server/src/macrotool/macrotool_dump.cc b/server/src/macrotool/macrotool_dump.cc
index 7e7d06f..30d0fd5 100644
--- a/server/src/macrotool/macrotool_dump.cc
+++ b/server/src/macrotool/macrotool_dump.cc
@@ -298,7 +298,7 @@ void macrotool_dump(std::vector<std::string> params)
return;
}
- PRACRO_DEBUG(fieldnames, "dump: %s\n", params[0].c_str());
+ DEBUG(fieldnames, "dump: %s\n", params[0].c_str());
if(params[0] == "fields") {
if(params.size() != 1) {
diff --git a/server/src/macrotool/macrotool_fieldnames.cc b/server/src/macrotool/macrotool_fieldnames.cc
index 2a9681a..8d90323 100644
--- a/server/src/macrotool/macrotool_fieldnames.cc
+++ b/server/src/macrotool/macrotool_fieldnames.cc
@@ -165,7 +165,7 @@ void macrotool_fieldnames(std::vector<std::string> params)
return;
}
- PRACRO_DEBUG(fieldnames, "fieldnames: %s\n", params[0].c_str());
+ DEBUG(fieldnames, "fieldnames: %s\n", params[0].c_str());
if(params[0] == "list") {
if(params.size() != 1) {
diff --git a/server/src/macrotool/macrotool_filehandler.cc b/server/src/macrotool/macrotool_filehandler.cc
index c52921a..f9a9b45 100644
--- a/server/src/macrotool/macrotool_filehandler.cc
+++ b/server/src/macrotool/macrotool_filehandler.cc
@@ -194,7 +194,7 @@ void macrotool_filehandler(std::vector<std::string> params)
return;
}
- PRACRO_DEBUG(filehandler, "filehandler: %s\n", params[0].c_str());
+ DEBUG(filehandler, "filehandler: %s\n", params[0].c_str());
if(params[0] == "add") {
if(params.size() != 2) {
diff --git a/server/src/macrotool/macrotool_util.cc b/server/src/macrotool/macrotool_util.cc
index 3c18ab7..075a9e0 100644
--- a/server/src/macrotool/macrotool_util.cc
+++ b/server/src/macrotool/macrotool_util.cc
@@ -40,7 +40,7 @@ static std::vector<std::string> listdir(std::string path)
DIR* dir = opendir(path.c_str());
if(!dir) {
- PRACRO_ERR(dump, "Could not open directory: %s\n", path.c_str());
+ ERR(dump, "Could not open directory: %s\n", path.c_str());
return files;
}
diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc
index e15b0f0..b8cbf13 100644
--- a/server/src/pracrod.cc
+++ b/server/src/pracrod.cc
@@ -182,7 +182,7 @@ int main(int argc, char *argv[])
char *debugstr = NULL;
std::string database;
- pracro_debug_init();
+ debug_init(stderr);
int option_index = 0;
while(1) {
@@ -237,7 +237,7 @@ int main(int argc, char *argv[])
case 's':
#ifdef WITHOUT_SSL
- PRACRO_ERR(server, "Pracro was not compiled with SSL support!\n");
+ ERR(server, "Pracro was not compiled with SSL support!\n");
return 1;
#else
Conf::use_ssl = true;
@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
}
if(debugstr) {
- pracro_debug_parse(debugstr);
+ debug_parse(debugstr);
}
// Load config
diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc
index 6d7afe8..ee544df 100644
--- a/server/src/pracrodaopgsql.cc
+++ b/server/src/pracrodaopgsql.cc
@@ -65,16 +65,16 @@ PracroDAOPgsql::PracroDAOPgsql(std::string _host, std::string _port,
std::string ts;
try {
ts = "BEGIN;";
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
pqxx::result R = W->exec(ts);
} catch(...) {
}
} catch(std::exception &e) {
- PRACRO_ERR_LOG(db, "Postgresql init failed: %s\n", e.what());
+ ERR_LOG(db, "Postgresql init failed: %s\n", e.what());
conn = NULL;
}
- PRACRO_DEBUG(db, "Pgsql connection %p (%s)\n", conn, cs.c_str());
+ DEBUG(db, "Pgsql connection %p (%s)\n", conn, cs.c_str());
}
PracroDAOPgsql::~PracroDAOPgsql()
@@ -91,12 +91,12 @@ void PracroDAOPgsql::commitTransaction(std::string user,
Fields &fields,
time_t now)
{
- PRACRO_DEBUG(db, "(%s, %s, %s, <%u fields>, %ld)\n",
- user.c_str(), patientid.c_str(),
- _macro.attributes["name"].c_str(),
- fields.size(), now);
-
- if(!conn) PRACRO_DEBUG(db, "No pgsql connection\n");
+ DEBUG(db, "(%s, %s, %s, <%u fields>, %ld)\n",
+ user.c_str(), patientid.c_str(),
+ _macro.attributes["name"].c_str(),
+ fields.size(), now);
+
+ if(!conn) DEBUG(db, "No pgsql connection\n");
if(fields.size() == 0) return;
std::string version = _macro.attributes["version"];
@@ -115,7 +115,7 @@ void PracroDAOPgsql::commitTransaction(std::string user,
" '" + W->esc(user) + "' "
");"
;
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
pqxx::result R = W->exec(ts);
statements += ts + "\n";
@@ -130,19 +130,19 @@ void PracroDAOPgsql::commitTransaction(std::string user,
i++;
}
ts += ");";
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
R = W->exec(ts);
// statements += ts + "\n";
- PRACRO_DEBUG(db, "input fields: %d, output fields: %lu\n",
- fields.size(), R.size());
+ DEBUG(db, "input fields: %d, output fields: %lu\n",
+ fields.size(), R.size());
// Store known fields
pqxx::result::const_iterator ri = R.begin();
if(ri != R.end()) {
std::string name = (*ri)[0].c_str();
- PRACRO_DEBUG(db, "Storing: %s with value %s\n",
- name.c_str(), fields[name].c_str());
+ DEBUG(db, "Storing: %s with value %s\n",
+ name.c_str(), fields[name].c_str());
ts = "INSERT INTO fields (transaction, name, value) "
"VALUES ( currval('trseq'), '" + W->esc(name) + "', '" +
W->esc(fields[name]) + "')";
@@ -150,15 +150,15 @@ void PracroDAOPgsql::commitTransaction(std::string user,
while(ri != R.end()) {
name = (*ri)[0].c_str();
- PRACRO_DEBUG(db, "Storing: %s with value %s\n",
- name.c_str(), fields[name].c_str());
+ DEBUG(db, "Storing: %s with value %s\n",
+ name.c_str(), fields[name].c_str());
ts += ", (currval('trseq'), '" + W->esc(name) + "', '" +
W->esc(fields[name]) + "')";
ri++;
}
ts += ";";
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
W->exec(ts);
statements += ts + "\n";
@@ -166,7 +166,7 @@ void PracroDAOPgsql::commitTransaction(std::string user,
}
// W->commit();
} catch(std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -197,11 +197,11 @@ Values PracroDAOPgsql::getLatestValues(std::string patientid,
Fieldnames &fieldnames,
time_t oldest)
{
- PRACRO_DEBUG(db, "(%s, %s, <%u fieldnames>, %ld)\n",
- patientid.c_str(),
- macro ? macro->attributes["name"].c_str() : "(null)",
- fieldnames.size(), oldest);
- if(!conn) PRACRO_DEBUG(db, "No pgsql connection\n");
+ DEBUG(db, "(%s, %s, <%u fieldnames>, %ld)\n",
+ patientid.c_str(),
+ macro ? macro->attributes["name"].c_str() : "(null)",
+ fieldnames.size(), oldest);
+ if(!conn) DEBUG(db, "No pgsql connection\n");
Values values;
std::string query;
@@ -244,7 +244,7 @@ Values PracroDAOPgsql::getLatestValues(std::string patientid,
query += " AND tt.version = '" + macro->attributes["version"] + "'";
}
- PRACRO_DEBUG(sql, "Query: %s\n", query.c_str());
+ DEBUG(sql, "Query: %s\n", query.c_str());
pqxx::result R = W->exec(query);
pqxx::result::const_iterator ri = R.begin();
while(ri != R.end()) {
@@ -255,7 +255,7 @@ Values PracroDAOPgsql::getLatestValues(std::string patientid,
ri++;
}
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
}
return values;
@@ -274,18 +274,18 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string patientid,
" AND macro = '" + W->esc(macroname) + "' "
" AND timestamp >= " + soldest.str()
;
- PRACRO_DEBUG(sql, "Query: %s\n", query.c_str());
+ DEBUG(sql, "Query: %s\n", query.c_str());
pqxx::result R = W->exec(query);
if(R.size() != 1) {
- PRACRO_ERR_LOG(db, "No result set; expected one row with one column\n");
+ ERR_LOG(db, "No result set; expected one row with one column\n");
return 0;
}
unsigned n = (unsigned)atol((*R.begin())[0].c_str());
- PRACRO_DEBUG(db, "Found %u commits for %s(%s) from %ld\n",
+ DEBUG(db, "Found %u commits for %s(%s) from %ld\n",
n, patientid.c_str(), macroname.c_str(), oldest);
return n;
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
}
return 0;
@@ -302,11 +302,11 @@ void PracroDAOPgsql::addFieldname(std::string name, std::string description)
" '" + W->esc(timestamp.str()) + "' "
")"
;
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
pqxx::result R = W->exec(ts);
W->commit();
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -316,23 +316,23 @@ void PracroDAOPgsql::delFieldname(std::string name)
try {
ts = "DELETE FROM fieldnames WHERE name="
"'" + W->esc(name) + "' ";
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
pqxx::result R = W->exec(ts);
W->commit();
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
}
std::vector<Fieldname> PracroDAOPgsql::getFieldnames()
{
- if(!conn) PRACRO_DEBUG(db, "No pgsql connection\n");
+ if(!conn) DEBUG(db, "No pgsql connection\n");
std::vector<Fieldname> fieldnames;
std::string query;
try {
query = "SELECT * FROM fieldnames";
- PRACRO_DEBUG(sql, "Query: %s\n", query.c_str());
+ DEBUG(sql, "Query: %s\n", query.c_str());
pqxx::result R = W->exec(query);
pqxx::result::const_iterator ri = R.begin();
while(ri != R.end()) {
@@ -344,7 +344,7 @@ std::vector<Fieldname> PracroDAOPgsql::getFieldnames()
ri++;
}
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
}
return fieldnames;
@@ -357,7 +357,7 @@ void PracroDAOPgsql::commit()
W->commit();
statements = "";
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Commit failed: %s: %s\n", e.what(), ts.c_str());
+ ERR_LOG(db, "Commit failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -368,8 +368,7 @@ void PracroDAOPgsql::discard()
W->abort();
statements = "";
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Abort (rollback) failed: %s: %s\n",
- e.what(), ts.c_str());
+ ERR_LOG(db, "Abort (rollback) failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -382,7 +381,7 @@ void PracroDAOPgsql::restore(const std::string &data)
{
std::string ts;
try {
- PRACRO_DEBUG(sql, "Restore: %s\n", data.c_str());
+ DEBUG(sql, "Restore: %s\n", data.c_str());
pqxx::result R = W->exec(data);
statements = data;
} catch( ... ) {
diff --git a/server/src/pracrodaotest.cc b/server/src/pracrodaotest.cc
index 86e5941..7e77eb5 100644
--- a/server/src/pracrodaotest.cc
+++ b/server/src/pracrodaotest.cc
@@ -37,23 +37,23 @@ PracroDAOTest::PracroDAOTest(Data &data, bool ignore_fieldnames)
{
this->data = data;
this->ignore_fieldnames = ignore_fieldnames;
- PRACRO_DEBUG(db, "New test (memory only) database\n");
+ DEBUG(db, "New test (memory only) database\n");
}
PracroDAOTest::~PracroDAOTest()
{
- PRACRO_DEBUG(db, "Delete test (memory only) database\n");
+ DEBUG(db, "Delete test (memory only) database\n");
}
void PracroDAOTest::commitTransaction(std::string user, std::string patientid,
Macro &_macro, Fields &fields, time_t now)
{
- PRACRO_DEBUG(db, "(%s, %s, %s, <%u fields>, %ld)\n",
- user.c_str(),
- patientid.c_str(),
- _macro.attributes["name"].c_str(),
- fields.size(),
- now);
+ DEBUG(db, "(%s, %s, %s, <%u fields>, %ld)\n",
+ user.c_str(),
+ patientid.c_str(),
+ _macro.attributes["name"].c_str(),
+ fields.size(),
+ now);
if(fields.size() == 0) return;
std::string version = _macro.attributes["version"];
@@ -107,10 +107,10 @@ Values PracroDAOTest::getLatestValues(std::string patientid, Macro *macro,
Fieldnames &fieldnames, time_t oldest)
{
std::string macro_name = macro ? macro->attributes["name"].c_str() : "(null)";
- PRACRO_DEBUG(db, "(%s, %s, <%u fieldnames>, %ld)\n",
- patientid.c_str(),
- macro_name.c_str(), fieldnames.size(),
- oldest);
+ DEBUG(db, "(%s, %s, <%u fieldnames>, %ld)\n",
+ patientid.c_str(),
+ macro_name.c_str(), fieldnames.size(),
+ oldest);
Values values;
// TODO: Take Macro* into account. If supplied (not NULL) the macro name, and
@@ -190,11 +190,11 @@ void PracroDAOTest::addFieldname(std::string name, std::string description)
" '" + W.esc(timestamp.str()) + "' "
")"
;
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
pqxx::result R = W.exec(ts);
W.commit();
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
*/
}
@@ -209,11 +209,11 @@ void PracroDAOTest::delFieldname(std::string name)
pqxx::work W(*conn);
ts = "DELETE FROM fieldnames WHERE name="
"'" + W.esc(name) + "' ";
- PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str());
+ DEBUG(sql, "Query: %s\n", ts.c_str());
pqxx::result R = W.exec(ts);
W.commit();
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
*/
}
@@ -228,7 +228,7 @@ std::vector<Fieldname> PracroDAOTest::getFieldnames()
try {
pqxx::work W(*conn);
query = "SELECT * FROM fieldnames";
- PRACRO_DEBUG(sql, "Query: %s\n", query.c_str());
+ DEBUG(sql, "Query: %s\n", query.c_str());
pqxx::result R = W.exec(query);
pqxx::result::const_iterator ri = R.begin();
while(ri != R.end()) {
@@ -240,7 +240,7 @@ std::vector<Fieldname> PracroDAOTest::getFieldnames()
ri++;
}
} catch (std::exception &e) {
- PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
+ ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
}
*/
return fieldnames;
diff --git a/server/src/queryhandlerpentominos.cc b/server/src/queryhandlerpentominos.cc
index b67f731..41573e5 100644
--- a/server/src/queryhandlerpentominos.cc
+++ b/server/src/queryhandlerpentominos.cc
@@ -164,7 +164,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query)
artefact.socket.write(header, strlen(header));
#endif/*WITHOUT_PENTOMINOS*/
- PRACRO_DEBUG(queryhandler, "%s", header);
+ DEBUG(queryhandler, "%s", header);
sprintf(buf, " <pentominos:entry replyformat=\"xml\"\n"
" cpr=\"%s\"\n"
@@ -188,7 +188,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query)
artefact.socket.write(buf, strlen(buf));
#endif/*WITHOUT_PENTOMINOS*/
- PRACRO_DEBUG(queryhandler, "%s", buf);
+ DEBUG(queryhandler, "%s", buf);
sprintf(buf, " <pentominos:query device_id=\"%s\"\n"
" device_type=\"%s\"\n"
@@ -201,7 +201,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query)
artefact.socket.write(buf, strlen(buf));
#endif/*WITHOUT_PENTOMINOS*/
- PRACRO_DEBUG(queryhandler, "%s", buf);
+ DEBUG(queryhandler, "%s", buf);
sprintf(buf, "</artefact>");
@@ -209,7 +209,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query)
artefact.socket.write(buf, strlen(buf));
#endif/*WITHOUT_PENTOMINOS*/
- PRACRO_DEBUG(queryhandler, "%s", buf);
+ DEBUG(queryhandler, "%s", buf);
QueryResult result;
@@ -227,7 +227,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query)
result = parser.result;
#endif/*WITHOUT_PENTOMINOS*/
- PRACRO_INFO(queryhandler, "Done handling query\n");
+ INFO(queryhandler, "Done handling query\n");
result.print();
diff --git a/server/src/queryhandlerpracro.cc b/server/src/queryhandlerpracro.cc
index ae2f0f6..6868e47 100644
--- a/server/src/queryhandlerpracro.cc
+++ b/server/src/queryhandlerpracro.cc
@@ -66,7 +66,8 @@ QueryResult QueryHandlerPracro::exec(Query &query)
result.values[field] = value;
result.source = "pracrodb";
- PRACRO_DEBUG(queryhandler,"%s => %s (%lu)\n", field.c_str(), value.c_str(), timestamp);
+ DEBUG(queryhandler,"%s => %s (%lu)\n",
+ field.c_str(), value.c_str(), timestamp);
}
return result;
diff --git a/server/src/queryresult.h b/server/src/queryresult.h
index de95a49..f734303 100644
--- a/server/src/queryresult.h
+++ b/server/src/queryresult.h
@@ -41,18 +41,21 @@ public:
std::map< std::string, QueryResult > groups;
void print(std::string tabs = "") {
- PRACRO_DEBUG(queryhandler,"%sTimestamp: %d\n", tabs.c_str(), (int)timestamp);
- PRACRO_DEBUG(queryhandler,"%sSource: %s\n", tabs.c_str(), source.c_str());
- PRACRO_DEBUG(queryhandler,"%sValues:\n", tabs.c_str());
- for(std::map< std::string, std::string >::iterator i = values.begin(); i != values.end(); i++) {
- PRACRO_DEBUG(queryhandler,"%s[%s] => [%s]\n", tabs.c_str(), i->first.c_str(), i->second.c_str());
+ DEBUG(queryhandler,"%sTimestamp: %d\n", tabs.c_str(), (int)timestamp);
+ DEBUG(queryhandler,"%sSource: %s\n", tabs.c_str(), source.c_str());
+ DEBUG(queryhandler,"%sValues:\n", tabs.c_str());
+ for(std::map< std::string, std::string >::iterator i = values.begin();
+ i != values.end(); i++) {
+ DEBUG(queryhandler,"%s[%s] => [%s]\n",
+ tabs.c_str(), i->first.c_str(), i->second.c_str());
}
- PRACRO_DEBUG(queryhandler,"%s{\n", tabs.c_str());
- for(std::map< std::string, QueryResult >::iterator i = groups.begin(); i != groups.end(); i++) {
- PRACRO_DEBUG(queryhandler,"%s[%s] =>:\n", tabs.c_str(), i->first.c_str());
+ DEBUG(queryhandler,"%s{\n", tabs.c_str());
+ for(std::map< std::string, QueryResult >::iterator i = groups.begin();
+ i != groups.end(); i++) {
+ DEBUG(queryhandler,"%s[%s] =>:\n", tabs.c_str(), i->first.c_str());
i->second.print(tabs +" ");
}
- PRACRO_DEBUG(queryhandler,"%s}\n", tabs.c_str());
+ DEBUG(queryhandler,"%s}\n", tabs.c_str());
}
};
diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc
index 4a1657c..72f0fe4 100644
--- a/server/src/saxparser.cc
+++ b/server/src/saxparser.cc
@@ -75,7 +75,7 @@ SAXParser::SAXParser()
{
p = XML_ParserCreate(NULL);
if(!p) {
- PRACRO_ERR(sax, "Couldn't allocate memory for parser\n");
+ ERR(sax, "Couldn't allocate memory for parser\n");
// throw Exception(...);
return;
}
@@ -128,7 +128,7 @@ bool SAXParser::parse(const char *data, size_t size)
{
std::string xml;
xml.append(data, size);
- PRACRO_DEBUG(sax, "parse %d bytes [%s]\n", size, xml.c_str());
+ DEBUG(sax, "parse %d bytes [%s]\n", size, xml.c_str());
bufferbytes = size;
totalbytes += bufferbytes;
@@ -155,8 +155,8 @@ bool SAXParser::parse(const char *data, size_t size)
}
}
- if(done) PRACRO_DEBUG(sax, "Got END_OF_DOCUMENT [%s] at %ld\n",
- outertag.c_str(), XML_GetCurrentByteIndex(p));
+ if(done) DEBUG(sax, "Got END_OF_DOCUMENT [%s] at %ld\n",
+ outertag.c_str(), XML_GetCurrentByteIndex(p));
return done;
}
diff --git a/server/src/server.cc b/server/src/server.cc
index 9177c79..bb0b6d0 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -117,7 +117,7 @@ void server()
while(pracro_is_running) sleep(1);
- PRACRO_DEBUG(server, "Server gracefully shut down.\n");
+ DEBUG(server, "Server gracefully shut down.\n");
}
#ifdef TEST_SERVER
diff --git a/server/src/sessionparser.cc b/server/src/sessionparser.cc
index fef0f09..f449ba5 100644
--- a/server/src/sessionparser.cc
+++ b/server/src/sessionparser.cc
@@ -57,7 +57,7 @@ void SessionParser::characterData(std::string &data)
void SessionParser::startTag(std::string name,
std::map<std::string, std::string> attributes)
{
- PRACRO_DEBUG(sessionparser, "<%s>\n", name.c_str());
+ DEBUG(sessionparser, "<%s>\n", name.c_str());
if(name == "session") {
sessionid = attributes["id"];
@@ -98,14 +98,14 @@ void SessionParser::endTag(std::string name)
void SessionParser::parseError(const char *buf, size_t len,
std::string error, int lineno)
{
- PRACRO_ERR(sessionnparser, "SessionParser error at line %d: %s\n",
- lineno, error.c_str());
+ ERR(sessionnparser, "SessionParser error at line %d: %s\n",
+ lineno, error.c_str());
std::string xml;
if(buf && len) xml.append(buf, len);
- PRACRO_ERR(sessionparser, "\tBuffer %u bytes: [%s]\n",
- len, xml.c_str());
+ ERR(sessionparser, "\tBuffer %u bytes: [%s]\n",
+ len, xml.c_str());
fflush(stderr);
diff --git a/server/src/tcpsocket.cc b/server/src/tcpsocket.cc
index f748e0a..70722ed 100644
--- a/server/src/tcpsocket.cc
+++ b/server/src/tcpsocket.cc
@@ -90,12 +90,13 @@ TCPSocket::TCPSocket(std::string name, int sock)
isconnected = false;
this->sock = sock;
- PRACRO_DEBUG(socket, "TCPSocket %s: %p %d (%d)\n", name.c_str(), this, sock, getpid());
+ DEBUG(socket, "TCPSocket %s: %p %d (%d)\n", name.c_str(), this, sock, getpid());
}
TCPSocket::~TCPSocket()
{
- PRACRO_DEBUG(socket, "~TCPSocket %s: %p %d (%d)\n", name.c_str(), this, sock, getpid());
+ DEBUG(socket, "~TCPSocket %s: %p %d (%d)\n",
+ name.c_str(), this, sock, getpid());
disconnect();
}
@@ -152,7 +153,7 @@ TCPSocket *TCPSocket::accept()
FD_SET(sock, &fset);
if( (ret = select (sock+1, &fset, NULL, NULL, NULL)) < 0) {
if(errno == EINTR) {
- PRACRO_DEBUG(socket, "Accept got interrupt!\n");
+ DEBUG(socket, "Accept got interrupt!\n");
return NULL; // a signal caused select to return. That is OK with me
} else {
throw TCPAcceptException("Select on socket failed.");
@@ -168,7 +169,8 @@ TCPSocket *TCPSocket::accept()
child->isconnected = true;
return child;
} else {
- PRACRO_ERR_LOG(socket, "Accept returned with no socket - This should not happen!\n");
+ ERR_LOG(socket,
+ "Accept returned with no socket - This should not happen!\n");
return NULL;
}
}
@@ -219,7 +221,8 @@ void TCPSocket::connect(std::string addr, unsigned short int port)
void TCPSocket::disconnect()
{
if(sock != -1) {
- PRACRO_DEBUG(socket, "Closing TCPSocket %s: %p %d (%d)\n", name.c_str(), this, sock, getpid());
+ DEBUG(socket, "Closing TCPSocket %s: %p %d (%d)\n",
+ name.c_str(), this, sock, getpid());
int ret = close(sock);
if(ret == -1) {
perror(name.c_str());
@@ -269,7 +272,7 @@ int TCPSocket::read(char *buf, int size, long timeout)
switch(ret) {
case -1:
if(errno == EINTR) {
- PRACRO_DEBUG(socket, "EINTR - got interrupt\n");
+ DEBUG(socket, "EINTR - got interrupt\n");
return -1; // a signal caused select to return. That is OK with me
} else {
throw TCPReadException("Select on socket (read) failed.");
@@ -278,7 +281,7 @@ int TCPSocket::read(char *buf, int size, long timeout)
case 0:
// timeout
- PRACRO_DEBUG(socket, "Timeout\n");
+ DEBUG(socket, "Timeout\n");
break;
default:
@@ -288,7 +291,7 @@ int TCPSocket::read(char *buf, int size, long timeout)
throw TCPReadException(strerror(errno));
}
} else {
- PRACRO_DEBUG(socket, "FD_ISSET failed (timeout?)\n");
+ DEBUG(socket, "FD_ISSET failed (timeout?)\n");
return 0;
}
}
diff --git a/server/src/templateheaderparser.cc b/server/src/templateheaderparser.cc
index 848b05c..2cb3e84 100644
--- a/server/src/templateheaderparser.cc
+++ b/server/src/templateheaderparser.cc
@@ -50,12 +50,12 @@
void TemplateHeaderParser::error(const char* fmt, ...)
{
- PRACRO_ERR_LOG(templateparser, "Error in TemplateHeaderParser: ");
+ ERR_LOG(templateparser, "Error in TemplateHeaderParser: ");
{
va_list argp;
va_start(argp, fmt);
- PRACRO_ERR_LOG_VA(templateparser, fmt, argp);
+ ERR_LOG_VA(templateparser, fmt, argp);
va_end(argp);
fprintf(stderr, "\n");
@@ -80,7 +80,7 @@ TemplateHeaderParser::TemplateHeaderParser(std::string templatefile)
file = templatefile;
- PRACRO_DEBUG(templateparser, "Using template file: %s\n", templatefile.c_str());
+ DEBUG(templateparser, "Using template file: %s\n", templatefile.c_str());
fd = open(templatefile.c_str(), O_RDONLY);
if(fd == -1) error("Could not open file %s", templatefile.c_str());
@@ -110,12 +110,12 @@ int TemplateHeaderParser::readData(char *data, size_t size)
// tag, and can dismiss the rest of the document.
if(fd == -1) {
- PRACRO_ERR_LOG(templateparser, "Invalid file descriptor.\n");
+ ERR_LOG(templateparser, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- PRACRO_ERR_LOG(templateparser, "Could not read...%s\n", strerror(errno));
+ ERR_LOG(templateparser, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -125,10 +125,10 @@ void TemplateHeaderParser::parseError(const char *buf, size_t len, std::string e
{
if(t) return; // Ignore "unclosed token" errors when the template tag has been parsed.
- PRACRO_ERR_LOG(templateparser, "TemplateHeaderParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str());
- PRACRO_ERR_LOG(templateparser, "\tBuffer %u bytes: [", len);
+ ERR_LOG(templateparser, "TemplateHeaderParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str());
+ ERR_LOG(templateparser, "\tBuffer %u bytes: [", len);
if(fwrite(buf, len, 1, stderr) != len) {}
- PRACRO_ERR_LOG(templateparser, "]\n");
+ ERR_LOG(templateparser, "]\n");
char *slineno;
if(asprintf(&slineno, " at line %d\n", lineno) != -1) {
diff --git a/server/src/templatelist.cc b/server/src/templatelist.cc
index af03586..c7a951c 100644
--- a/server/src/templatelist.cc
+++ b/server/src/templatelist.cc
@@ -40,11 +40,11 @@ TemplateList::TemplateList(std::string path)
void TemplateList::addFile(std::string file)
{
if(file.substr(file.size() - 4) != ".xml") {
- PRACRO_DEBUG(templatelist, "Skipping file: %s\n", file.c_str());
+ DEBUG(templatelist, "Skipping file: %s\n", file.c_str());
return;
}
- PRACRO_DEBUG(templatelist, "Adding file: %s\n", file.c_str());
+ DEBUG(templatelist, "Adding file: %s\n", file.c_str());
TemplateHeaderParser parser(file);
try {
parser.parse();
@@ -53,7 +53,7 @@ void TemplateList::addFile(std::string file)
templ->attributes["version"],
file);
} catch(Exception &e) {
- PRACRO_WARN(templatelist, "Skipping %s: %s\n", file.c_str(), e.what());
+ WARN(templatelist, "Skipping %s: %s\n", file.c_str(), e.what());
}
}
diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc
index b3eda22..b34f280 100644
--- a/server/src/templateparser.cc
+++ b/server/src/templateparser.cc
@@ -54,7 +54,7 @@ void TemplateParser::error(const char* fmt, ...)
va_start(argp, fmt);
vasprintf(&p, fmt, argp);
va_end(argp);
- PRACRO_ERR_LOG(template, "Error in TemplateParser: %s\n", p);
+ ERR_LOG(template, "Error in TemplateParser: %s\n", p);
throw Exception(std::string("Error in TemplateParser: ") + p);
free(p);
}
@@ -67,7 +67,7 @@ TemplateParser::TemplateParser(std::string templatefile)
file = templatefile;
- PRACRO_DEBUG(template, "Using template file: %s\n", file.c_str());
+ DEBUG(template, "Using template file: %s\n", file.c_str());
fd = open(file.c_str(), O_RDONLY);
if(fd == -1) error("Could not open file %s", file.c_str());
@@ -128,12 +128,12 @@ void TemplateParser::endTag(std::string name)
int TemplateParser::readData(char *data, size_t size)
{
if(fd == -1) {
- PRACRO_ERR_LOG(template, "Invalid file descriptor.\n");
+ ERR_LOG(template, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- PRACRO_ERR_LOG(template, "Could not read...%s\n", strerror(errno));
+ ERR_LOG(template, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -141,7 +141,8 @@ int TemplateParser::readData(char *data, size_t size)
void TemplateParser::parseError(const char *buf, size_t len, std::string error, int lineno)
{
- fprintf(stderr, "TemplateParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str());
+ fprintf(stderr, "TemplateParser[%s] error at line %d: %s\n",
+ file.c_str(), lineno, error.c_str());
fprintf(stderr, "\tBuffer %u bytes: [", len);
if(fwrite(buf, len, 1, stderr) != len) {}
fprintf(stderr, "]\n");
diff --git a/server/src/transactionhandler.cc b/server/src/transactionhandler.cc
index 967b7e9..f549192 100644
--- a/server/src/transactionhandler.cc
+++ b/server/src/transactionhandler.cc
@@ -102,8 +102,8 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
while(i != transaction.requests.end()) {
Request &request = *i;
- PRACRO_DEBUG(server, "Handling request - macro: %s, template: %s\n",
- request.macro.c_str(), request.templ.c_str());
+ DEBUG(server, "Handling request - macro: %s, template: %s\n",
+ request.macro.c_str(), request.templ.c_str());
// Read and parse the template file.
TemplateParser tp(env.templatelist.getLatestVersion(request.templ));
@@ -270,21 +270,21 @@ std::string handleTransaction(Transaction &transaction, Environment &env,
try {
answer += handleCommits(transaction, env, session);
} catch( std::exception &e ) {
- PRACRO_ERR(server, "Commit error: %s\n", e.what());
+ ERR(server, "Commit error: %s\n", e.what());
return error_box(xml_encode(e.what()));
}
try {
answer += handleRequest(transaction, env, session);
} catch( std::exception &e ) {
- PRACRO_ERR(server, "Request error: %s\n", e.what());
+ ERR(server, "Request error: %s\n", e.what());
return error_box(xml_encode(e.what()));
}
answer += "</pracro>\n";
- PRACRO_DEBUG(server, "Done handling transaction\n");
- PRACRO_DEBUG(serverxml, "%s\n", answer.c_str());
+ DEBUG(server, "Done handling transaction\n");
+ DEBUG(serverxml, "%s\n", answer.c_str());
return answer;
}
diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc
index b33cac6..f78e562 100644
--- a/server/src/transactionparser.cc
+++ b/server/src/transactionparser.cc
@@ -46,7 +46,7 @@ TransactionParser::TransactionParser(Transaction *transaction)
void TransactionParser::startTag(std::string name,
std::map<std::string, std::string> attributes)
{
- PRACRO_DEBUG(transactionparser, "<%s>\n", name.c_str());
+ DEBUG(transactionparser, "<%s>\n", name.c_str());
if(name == "pracro") {
transaction->user = attributes["user"];
@@ -71,17 +71,17 @@ void TransactionParser::startTag(std::string name,
if(name == "field") {
if(!transaction->commits.size()) {
- PRACRO_ERR(transactionparser, "Field without a commit tag!");
+ ERR(transactionparser, "Field without a commit tag!");
throw std::exception();
}
if(attributes.find("name") == attributes.end()) {
- PRACRO_ERR(transactionparser, "Field is missing 'name' attribute");
+ ERR(transactionparser, "Field is missing 'name' attribute");
throw std::exception();
}
if(attributes.find("value") == attributes.end()) {
- PRACRO_ERR(transactionparser, "Field is missing 'value' attribute");
+ ERR(transactionparser, "Field is missing 'value' attribute");
throw std::exception();
}
@@ -93,14 +93,14 @@ void TransactionParser::startTag(std::string name,
void TransactionParser::parseError(const char *buf, size_t len,
std::string error, int lineno)
{
- PRACRO_ERR(transactionparser, "TransactionParser error at line %d: %s\n",
- lineno, error.c_str());
+ ERR(transactionparser, "TransactionParser error at line %d: %s\n",
+ lineno, error.c_str());
std::string xml;
xml.append(buf, len);
- PRACRO_ERR(transactionparser, "\tBuffer %u bytes: [%s]\n",
- len, xml.c_str());
+ ERR(transactionparser, "\tBuffer %u bytes: [%s]\n",
+ len, xml.c_str());
throw std::exception();
}
diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc
index f257228..aa5786d 100644
--- a/server/src/widgetgenerator.cc
+++ b/server/src/widgetgenerator.cc
@@ -41,9 +41,9 @@ static std::string getWidgetString(Macro &macro,
result = tabs + "<" + widget.attributes["tagname"];
attr_t::iterator p = widget.attributes.begin();
- PRACRO_DEBUG(prefill, "TAG: %s - NAME: %s\n",
- widget.attributes["tagname"].c_str(),
- widget.attributes["name"].c_str());
+ DEBUG(prefill, "TAG: %s - NAME: %s\n",
+ widget.attributes["tagname"].c_str(),
+ widget.attributes["name"].c_str());
Value value;
if(getValue(value, widget.attributes, macro.maps, mapper, values)) {
diff --git a/server/src/widgetvalue.cc b/server/src/widgetvalue.cc
index ddb0e9c..053eecc 100644
--- a/server/src/widgetvalue.cc
+++ b/server/src/widgetvalue.cc
@@ -59,9 +59,9 @@ static bool getMapValue(Value &value,
// Value too old?
if(value.timestamp < time(NULL) - Conf::pentominos_max_ttl) return false;
- PRACRO_DEBUG(prefill, "map: (%s, %d)\n",
- value.value.c_str(),
- (int)value.timestamp);
+ DEBUG(prefill, "map: (%s, %d)\n",
+ value.value.c_str(),
+ (int)value.timestamp);
}
@@ -126,10 +126,10 @@ bool getValue(Value &value,
std::map<time_t, Value>::iterator i = prio.begin();
while(i != prio.end()) {
- PRACRO_DEBUG(prefill, "% 11ld - \"%s\" (src: '%s')\n",
- i->second.timestamp,
- i->second.value.c_str(),
- i->second.source.c_str());
+ DEBUG(prefill, "% 11ld - \"%s\" (src: '%s')\n",
+ i->second.timestamp,
+ i->second.value.c_str(),
+ i->second.source.c_str());
i++;
}