From e829b175730fb93081612392c9da8332c8d66586 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 5 Mar 2014 11:28:19 +0100 Subject: Use hugin module instead of old debug code. --- server/src/Makefile.am | 14 +- server/src/admin_connection.cc | 2 +- server/src/admin_export.cc | 2 +- server/src/artefact.cc | 2 +- server/src/courselist.cc | 2 +- server/src/courseparser.cc | 8 +- server/src/database.cc | 2 +- server/src/database.h | 2 +- server/src/debug.cc | 287 ----------------------------------- server/src/debug.h | 134 ---------------- server/src/entitylist.cc | 2 +- server/src/exception.cc | 2 +- server/src/fieldnamescanner.cc | 2 +- server/src/httpd.cc | 2 +- server/src/inotify.cc | 2 +- server/src/journal.cc | 2 +- server/src/journal_commit.cc | 12 +- server/src/log.cc | 2 +- server/src/luaoncommit.cc | 2 +- server/src/luapraxisd.cc | 2 +- server/src/luaresume.cc | 2 +- server/src/luascript.cc | 2 +- server/src/luautil.cc | 2 +- server/src/macroheaderparser.cc | 24 +-- server/src/macrolist.cc | 2 +- server/src/macroparser.cc | 24 +-- server/src/macrotool/dump.cc | 2 +- server/src/macrotool/export.cc | 2 +- server/src/macrotool/fieldnames.cc | 2 +- server/src/macrotool/filehandler.cc | 2 +- server/src/macrotool/macrotool.cc | 2 +- server/src/pgwork.cc | 2 +- server/src/pracrod.cc | 48 +++--- server/src/pracrodaopgsql.cc | 34 ++--- server/src/pracrodaotest.cc | 4 +- server/src/queryhandlerpentominos.cc | 2 +- server/src/queryhandlerpracro.cc | 2 +- server/src/queryresult.h | 2 +- server/src/saxparser.cc | 2 +- server/src/server.cc | 6 - server/src/sessionheaderparser.cc | 24 +-- server/src/sessionparser.cc | 2 +- server/src/tcpsocket.cc | 4 +- server/src/templateheaderparser.cc | 24 +-- server/src/templatelist.cc | 2 +- server/src/templateparser.cc | 8 +- server/src/transactionparser.cc | 2 +- server/src/utf8.cc | 2 +- server/src/util.cc | 2 +- server/src/widgetvalue.cc | 2 +- 50 files changed, 136 insertions(+), 589 deletions(-) delete mode 100644 server/src/debug.cc delete mode 100644 server/src/debug.h diff --git a/server/src/Makefile.am b/server/src/Makefile.am index 855bec2..5edec4e 100644 --- a/server/src/Makefile.am +++ b/server/src/Makefile.am @@ -8,7 +8,10 @@ pracrod_LDADD = $(LD_EFENCE) $(PQ_LIBS) $(CONFIG_LIBS) \ pracrod_CXXFLAGS = $(PQ_CFLAGS) $(CONFIG_CXXFLAGS) \ $(LUA_CFLAGS) $(HTTPD_CFLAGS) $(EXPAT_CFLAGS) \ - $(PTHREAD_CFLAGS) $(ATF_CFLAGS) $(CURL_CFLAGS) + $(PTHREAD_CFLAGS) $(ATF_CFLAGS) $(CURL_CFLAGS) \ + -I$(top_srcdir)/../hugin -DWITH_HUG_FILTER + +pracrod_CFLAGS = -DWITH_HUG_FILTER pracrod_SOURCES = \ pracrod.cc \ @@ -25,7 +28,6 @@ pracrod_SOURCES = \ courselist.cc \ daemon.cc \ database.cc \ - debug.cc \ entitylist.cc \ environment.cc \ exception.cc \ @@ -72,7 +74,9 @@ pracrod_SOURCES = \ versionstr.cc \ widgetvalue.cc \ widgetgenerator.cc \ - xml_encode_decode.cc + xml_encode_decode.cc \ + $(top_srcdir)/../hugin/hugin.c \ + $(top_srcdir)/../hugin/hugin_filter.c EXTRA_DIST = \ artefact.h \ @@ -89,7 +93,6 @@ EXTRA_DIST = \ daemon.h \ database.h \ dbtypes.h \ - debug.h \ environment.h \ entitylist.h \ exception.h \ @@ -140,7 +143,8 @@ EXTRA_DIST = \ versionstr.h \ widgetvalue.h \ widgetgenerator.h \ - xml_encode_decode.h + xml_encode_decode.h \ + $(top_srcdir)/../hugin/hugin.h ################ # Test Section # diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc index 76c88ea..75b41e7 100644 --- a/server/src/admin_connection.cc +++ b/server/src/admin_connection.cc @@ -32,7 +32,7 @@ #include "admin_rc.h" #include "admin_export.h" -#include "debug.h" +#include #include "configuration.h" #include "sessionserialiser.h" diff --git a/server/src/admin_export.cc b/server/src/admin_export.cc index 6f5ecba..2212a6a 100644 --- a/server/src/admin_export.cc +++ b/server/src/admin_export.cc @@ -29,7 +29,7 @@ #include #include -#include "debug.h" +#include #ifndef WITHOUT_DB diff --git a/server/src/artefact.cc b/server/src/artefact.cc index 48b8174..84d190b 100644 --- a/server/src/artefact.cc +++ b/server/src/artefact.cc @@ -27,7 +27,7 @@ */ #include "artefact.h" -#include "debug.h" +#include #include "configuration.h" #include "queryparser.h" diff --git a/server/src/courselist.cc b/server/src/courselist.cc index b2a33c5..84760ca 100644 --- a/server/src/courselist.cc +++ b/server/src/courselist.cc @@ -29,7 +29,7 @@ #include "courseparser.h" -#include "debug.h" +#include CourseList::CourseList(std::string path) : EntityList(path, "course") diff --git a/server/src/courseparser.cc b/server/src/courseparser.cc index 79501f3..1a94e8b 100644 --- a/server/src/courseparser.cc +++ b/server/src/courseparser.cc @@ -45,7 +45,7 @@ #include #include "configuration.h" -#include "debug.h" +#include #include "exception.h" void CourseParser::error(const char* fmt, ...) @@ -55,7 +55,7 @@ void CourseParser::error(const char* fmt, ...) va_start(argp, fmt); vasprintf(&p, fmt, argp); va_end(argp); - ERR_LOG(course, "Error in CourseParser: %s\n", p); + ERR(course, "Error in CourseParser: %s\n", p); throw Exception(std::string("Error in CourseParser: ") + p); free(p); } @@ -126,12 +126,12 @@ void CourseParser::endTag(std::string name) int CourseParser::readData(char *data, size_t size) { if(fd == -1) { - ERR_LOG(course, "Invalid file descriptor.\n"); + ERR(course, "Invalid file descriptor.\n"); return 0; } ssize_t r = read(fd, data, size); if(r == -1) { - ERR_LOG(course, "Could not read...%s\n", strerror(errno)); + ERR(course, "Could not read...%s\n", strerror(errno)); return 0; } return r; diff --git a/server/src/database.cc b/server/src/database.cc index 27e903f..761f82a 100644 --- a/server/src/database.cc +++ b/server/src/database.cc @@ -30,7 +30,7 @@ #include #include -#include "debug.h" +#include #include "pracrodaopgsql.h" #include "pracrodaotest.h" diff --git a/server/src/database.h b/server/src/database.h index 7249233..41362cd 100644 --- a/server/src/database.h +++ b/server/src/database.h @@ -33,7 +33,7 @@ #include "transaction.h" #include "template.h" #include "mutex.h" -#include "debug.h" +#include class Database { public: diff --git a/server/src/debug.cc b/server/src/debug.cc deleted file mode 100644 index e42baae..0000000 --- a/server/src/debug.cc +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * debug.cc - * - * Wed Feb 11 11:22:12 CET 2009 - * Copyright 2009 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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, - * 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 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include "debug.h" - -#include -#include -#include -#include - -#include "log.h" - -#include - -#include "mutex.h" - -static Mutex mutex; - -static unsigned int gettid() -{ - return (unsigned int)pthread_self(); -} - -static FILE *logfp = stderr; - -#define NELEM(x) (sizeof(x)/sizeof((x)[0])) -struct __debug_channel -{ - char name[32]; - unsigned flags; -}; - -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 << __class_err) | (1 << __class_fixme); - -static int __debug_enabled(const enum __debug_class cl, const char *ch) -{ - unsigned i; - for(i = 0; i < n_debug_channel; i++) { - if(!strcmp(ch, debug_channel[i].name)) { - return (debug_channel[i].flags & (1 << cl)) != 0; - } - } - return debug_flags & (1 << cl); -} - - -#ifdef WITH_DEBUG -int __debug(const char *func, const int line, - const enum __debug_class cl, - const char *ch, const char *fmt, ...) -{ - MutexAutolock m(mutex); - int ret = 0; - if(__debug_enabled(cl, ch)) { - if((unsigned)cl < NELEM(debug_class_str)) - ret += fprintf(logfp, "%u %s:%s:%s:%d ", - gettid(), debug_class_str[(unsigned)cl], ch, func, line); - if(fmt) { - va_list va; - va_start(va, fmt); - ret += vfprintf(logfp, fmt, va); - va_end(va); - } - } - if(ret){ - fflush(logfp); - } - return ret; -} - -int __debug_va(const char *func, const int line, - const enum __debug_class cl, - const char *ch, const char *fmt, va_list va) -{ - MutexAutolock m(mutex); - int ret = 0; - if(__debug_enabled(cl, ch)) { - if((unsigned)cl < NELEM(debug_class_str)) - ret += fprintf(logfp, "%u %s:%s:%s:%d ", - gettid(), debug_class_str[(unsigned)cl], ch, func, line); - if(fmt) - ret += vfprintf(logfp, fmt, va); - } - if(ret) { - fflush(logfp); - } - return ret; -} - -#endif - -int __log(const char *func, const int line, const enum __debug_class cl, - const char *ch, const char *fmt, ...) -{ - MutexAutolock m(mutex); - - std::string logmsg; - char str[8]; - -#ifdef WITH_DEBUG - int ret = 0; -#endif - if(__debug_enabled(cl, ch)) { - if((unsigned)cl < NELEM(debug_class_str)) - if((unsigned)cl < NELEM(debug_class_str)) -#ifdef WITH_DEBUG - ret = fprintf(logfp, "%u %s:%s:%s:%d ", - gettid(), 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); -#ifdef WITH_DEBUG - ret += vfprintf(logfp, fmt, va); -#endif - char* ptr; - if(vasprintf(&ptr, fmt, va) == -1) {} - logmsg += ptr; - va_end(va); - } - } -#ifdef WITH_DEBUG - if(ret) { - fprintf(logfp, "\n"); - fflush(logfp); - } -#endif - log(logmsg); - return logmsg.size(); -} - -int __log_va(const char *func, const int line, const enum __debug_class cl, - const char *ch, const char *fmt, va_list va) -{ - MutexAutolock m(mutex); - - std::string logmsg; - char str[8]; -#ifdef WITH_DEBUG - int ret = 0; -#endif - if(__debug_enabled(cl, ch)) { - if((unsigned)cl < NELEM(debug_class_str)) -#ifdef WITH_DEBUG - ret = fprintf(logfp, "%u %s:%s:%s:%d ", - gettid(), 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; - } - } -#ifdef WITH_DEBUG - if(ret) { - fprintf(logfp, "\n"); - fflush(logfp); - } -#endif - return logmsg.size(); -} - -void debug_init(FILE *fp) -{ - mutex.name = "debug"; - MutexAutolock m(mutex); - logfp = fp; -} - -void debug_reinit(const char *logfile) -{ - MutexAutolock m(mutex); - - if(logfp != stderr) { - fclose(logfp); - logfp = fopen(logfile, "a"); - if(!logfp) { - fprintf(stderr, "Could not write to logfile: '%s'\n", logfile); - logfp = stderr; - } - } -} - - -/* - * fmt := [set[,set]*]* - * set := [+-]channel - * | class[+-]channel - * | [+-]all - */ -void debug_parse(const char *fmt) -{ - MutexAutolock m(mutex); - char *s; - char *next; - char *opt; - - if(!(s = strdup(fmt))) return; - - for(opt = s; opt; opt = next) { - int set = 0; - int clr = 0; - unsigned i; - if((next = strchr(opt, ','))) *next++ = '\0'; - char *p = opt + strcspn(opt, "+-"); - if(!*p) p = opt; // All chars -> a channel name - if(p > opt) { - // 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 - if(*p == '+') - set = 1 << i; - else - clr = 1 << i; - break; - } - } - if(i == NELEM(debug_class_str)) continue; - } else { - if(*p == '-') - clr = ~0; - else - set = ~0; - } - if(*p == '+' || *p == '-') p++; - if(!*p) continue; - if(!strcmp("all", p)) { - debug_flags = (debug_flags & ~clr) | set; - } else { - if(strlen(p) >= sizeof(debug_channel[0].name)) continue; - for(i = 0; i < n_debug_channel; i++) { - if(!strcmp(p, debug_channel[i].name)) { - debug_channel[i].flags = (debug_channel[i].flags & ~clr) | set; - break; - } - } - 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++; - } - } - } - free(s); -} - diff --git a/server/src/debug.h b/server/src/debug.h deleted file mode 100644 index 838d83f..0000000 --- a/server/src/debug.h +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * debug.h - * - * Wed Feb 11 11:22:12 CET 2009 - * Copyright 2009 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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 Pentominos; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#ifndef __PENTOMINOS_DEBUG_H__ -#define __PENTOMINOS_DEBUG_H__ - -#include -#include - -#ifdef HAVE_CONFIG_H -// For USE_EFENCE -#include -#ifdef USE_EFENCE -#include -#include -#include -#include - -// Lazy static alocations makes efence freak out. -// Use this to use hardcoded values instead. -// Currently it disables: -// - gethostbyname -// - getsockname -// - getpeername -// - iconv -//#define BYPASS_STATICALLOCATIONS - -#endif/*USE_EFENCE*/ -#endif/*HAVE_CONFIG*/ - -void debug_init(FILE *fp); -void debug_reinit(const char *file); -void debug_parse(const char *fmt); - -enum __debug_class -{ - __class_fixme = 0, - __class_err = 1, - __class_warn = 2, - __class_info = 3, - __class_debug = 4 -}; - -#ifdef WITH_DEBUG -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 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*/ - -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 2f8d82d..bb216cc 100644 --- a/server/src/entitylist.cc +++ b/server/src/entitylist.cc @@ -34,7 +34,7 @@ #include -#include "debug.h" +#include static inline bool isdir(std::string name) { diff --git a/server/src/exception.cc b/server/src/exception.cc index a2bbf95..8dab4ec 100644 --- a/server/src/exception.cc +++ b/server/src/exception.cc @@ -26,7 +26,7 @@ */ #include "exception.h" -#include "debug.h" +#include #include "log.h" diff --git a/server/src/fieldnamescanner.cc b/server/src/fieldnamescanner.cc index d8b10f1..419b8fb 100644 --- a/server/src/fieldnamescanner.cc +++ b/server/src/fieldnamescanner.cc @@ -37,7 +37,7 @@ #include "exception.h" #include "macrolist.h" -#include "debug.h" +#include fieldnames_t getFields(Widget &widget) { diff --git a/server/src/httpd.cc b/server/src/httpd.cc index 7bb2828..a412cf9 100644 --- a/server/src/httpd.cc +++ b/server/src/httpd.cc @@ -40,7 +40,7 @@ #include #include -#include "debug.h" +#include // for inet_ntop #include diff --git a/server/src/inotify.cc b/server/src/inotify.cc index 14a47bc..aed5981 100644 --- a/server/src/inotify.cc +++ b/server/src/inotify.cc @@ -27,7 +27,7 @@ */ #include "inotify.h" -#include "debug.h" +#include #include #include diff --git a/server/src/journal.cc b/server/src/journal.cc index 971e747..ff10fd1 100644 --- a/server/src/journal.cc +++ b/server/src/journal.cc @@ -27,7 +27,7 @@ */ #include "journal.h" -#include "debug.h" +#include Journal::Journal() {} diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc index 1bfd9e8..9460ce2 100644 --- a/server/src/journal_commit.cc +++ b/server/src/journal_commit.cc @@ -28,7 +28,7 @@ #include -#include "debug.h" +#include #include @@ -65,7 +65,7 @@ static int mwrite(int sock, const char *fmt, ...) va_end(args); if(sock != -1 && write(sock, buffer, l) != l) { - ERR_LOG(journal, "write did not write all the bytes in the buffer.\n"); + ERR(journal, "write did not write all the bytes in the buffer.\n"); } DEBUG(journal, "%s", buffer); @@ -89,7 +89,7 @@ int journal_commit(const char *cpr, const char *user, struct hostent *he; he = gethostbyname(addr); if(!he || !he->h_length) { - ERR_LOG(journal, "gethostbyname(%s) failed (errno=%d)!\n", addr, errno); + ERR(journal, "gethostbyname(%s) failed (errno=%d)!\n", addr, errno); return -1; } @@ -104,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) { - ERR_LOG(journal, "Socket() failed!\n"); + ERR(journal, "Socket() failed!\n"); return -1; } if(connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { - ERR_LOG(journal, "Connect() failed: %s!\n", strerror(errno)); + ERR(journal, "Connect() failed: %s!\n", strerror(errno)); return -1; } #else @@ -131,7 +131,7 @@ 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()) { - ERR_LOG(journal, "write did not write all the bytes in the buffer.\n"); + ERR(journal, "write did not write all the bytes in the buffer.\n"); return -1; } DEBUG(journal, "%s\n", buf); diff --git a/server/src/log.cc b/server/src/log.cc index fe72422..6519031 100644 --- a/server/src/log.cc +++ b/server/src/log.cc @@ -26,7 +26,7 @@ */ #include "log.h" -#include "debug.h" +#include #include diff --git a/server/src/luaoncommit.cc b/server/src/luaoncommit.cc index aa15cdb..de7962a 100644 --- a/server/src/luaoncommit.cc +++ b/server/src/luaoncommit.cc @@ -33,7 +33,7 @@ #include "luautil.h" #include "luapraxisd.h" -#include "debug.h" +#include #include diff --git a/server/src/luapraxisd.cc b/server/src/luapraxisd.cc index b12eace..39cb0eb 100644 --- a/server/src/luapraxisd.cc +++ b/server/src/luapraxisd.cc @@ -32,7 +32,7 @@ #include #include -#include "debug.h" +#include #define luaL_checkbool(L, i) \ (lua_isboolean(L,i) ? lua_toboolean(L,i) : luaL_checkint(L,i)) diff --git a/server/src/luaresume.cc b/server/src/luaresume.cc index a0a3ade..f7918f3 100644 --- a/server/src/luaresume.cc +++ b/server/src/luaresume.cc @@ -31,7 +31,7 @@ #include "luautil.h" -#include "debug.h" +#include #include diff --git a/server/src/luascript.cc b/server/src/luascript.cc index e46aa8d..22b0e94 100644 --- a/server/src/luascript.cc +++ b/server/src/luascript.cc @@ -28,7 +28,7 @@ #include "luascript.h" #include "configuration.h" -#include "debug.h" +#include #include "luautil.h" #include "luapraxisd.h" diff --git a/server/src/luautil.cc b/server/src/luautil.cc index 1042d8f..f5e32a5 100644 --- a/server/src/luautil.cc +++ b/server/src/luautil.cc @@ -26,7 +26,7 @@ */ #include "luautil.h" -#include "debug.h" +#include #include diff --git a/server/src/macroheaderparser.cc b/server/src/macroheaderparser.cc index 84efaee..a09686c 100644 --- a/server/src/macroheaderparser.cc +++ b/server/src/macroheaderparser.cc @@ -44,28 +44,20 @@ #include #include -#include "debug.h" +#include #include "configuration.h" #include "exception.h" void MacroHeaderParser::error(const char* fmt, ...) { - ERR_LOG(macro, "Error in MacroHeaderParser: "); - - { - va_list argp; - va_start(argp, fmt); - ERR_LOG_VA(macro, fmt, argp); - va_end(argp); - - fprintf(stderr, "\n"); - } + ERR(macro, "Error in MacroHeaderParser: "); { char *p; va_list argp; va_start(argp, fmt); if(vasprintf(&p, fmt, argp) != -1) { + ERR(macro, "%s", p); throw Exception("Error in MacroHeaderParser: " + std::string(p)); free(p); } @@ -112,12 +104,12 @@ int MacroHeaderParser::readData(char *data, size_t size) // tag, and can dismiss the rest of the document. if(fd == -1) { - ERR_LOG(macro, "Invalid file descriptor.\n"); + ERR(macro, "Invalid file descriptor.\n"); return 0; } ssize_t r = read(fd, data, size); if(r == -1) { - ERR_LOG(macro, "Could not read...%s\n", strerror(errno)); + ERR(macro, "Could not read...%s\n", strerror(errno)); return 0; } return r; @@ -127,11 +119,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. - ERR_LOG(macro, "MacroHeaderParser[%s] error at line %d: %s\n", + ERR(macro, "MacroHeaderParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str()); - ERR_LOG(macro, "\tBuffer %u bytes: [", (int)len); + ERR(macro, "\tBuffer %u bytes: [", (int)len); if(fwrite(buf, len, 1, stderr) != len) {} - ERR_LOG(macro, "]\n"); + ERR(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 935c403..a8ada46 100644 --- a/server/src/macrolist.cc +++ b/server/src/macrolist.cc @@ -31,7 +31,7 @@ #include "macroheaderparser.h" -#include "debug.h" +#include MacroList::MacroList(std::string path) : EntityList(path, "macro") diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc index 683c1d5..263d2c3 100644 --- a/server/src/macroparser.cc +++ b/server/src/macroparser.cc @@ -24,7 +24,7 @@ * along with Pracro; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "debug.h" +#include #include "macroparser.h" #include "configuration.h" @@ -54,22 +54,14 @@ void MacroParser::error(const char* fmt, ...) { - ERR_LOG(macro, "Error in MacroParser: "); - - { - va_list argp; - va_start(argp, fmt); - ERR_LOG_VA(macro, fmt, argp); - va_end(argp); - - fprintf(stderr, "\n"); - } + ERR(macro, "Error in MacroParser: "); { char *p; va_list argp; va_start(argp, fmt); if(vasprintf(&p, fmt, argp) != -1) { + ERR(macro, "%p", p); throw Exception("Error in MacroParser: " + std::string(p)); free(p); } @@ -360,12 +352,12 @@ void MacroParser::endTag(std::string name) int MacroParser::readData(char *data, size_t size) { if(fd == -1) { - ERR_LOG(macro, "Invalid file descriptor.\n"); + ERR(macro, "Invalid file descriptor.\n"); return 0; } ssize_t r = read(fd, data, size); if(r == -1) { - ERR_LOG(macro, "Could not read...%s\n", strerror(errno)); + ERR(macro, "Could not read...%s\n", strerror(errno)); return 0; } return r; @@ -373,11 +365,11 @@ int MacroParser::readData(char *data, size_t size) void MacroParser::parseError(const char *buf, size_t len, std::string error, int lineno) { - ERR_LOG(macro, "MacroParser[%s] error at line %d: %s\n", + ERR(macro, "MacroParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str()); - ERR_LOG(macro, "\tBuffer %u bytes: [", (int)len); + ERR(macro, "\tBuffer %u bytes: [", (int)len); if(fwrite(buf, len, 1, stderr) != len) {} - ERR_LOG(macro, "]\n"); + ERR(macro, "]\n"); char *slineno; if(asprintf(&slineno, " at line %d\n", lineno) != -1) { diff --git a/server/src/macrotool/dump.cc b/server/src/macrotool/dump.cc index 3d28181..29d7c4a 100644 --- a/server/src/macrotool/dump.cc +++ b/server/src/macrotool/dump.cc @@ -37,7 +37,7 @@ #include "util.h" -#include "debug.h" +#include #include "macroparser.h" #include "templateparser.h" diff --git a/server/src/macrotool/export.cc b/server/src/macrotool/export.cc index f42cd34..165cda4 100644 --- a/server/src/macrotool/export.cc +++ b/server/src/macrotool/export.cc @@ -29,7 +29,7 @@ #include #include -#include "debug.h" +#include #ifndef WITHOUT_DB diff --git a/server/src/macrotool/fieldnames.cc b/server/src/macrotool/fieldnames.cc index f348ef4..898b50c 100644 --- a/server/src/macrotool/fieldnames.cc +++ b/server/src/macrotool/fieldnames.cc @@ -33,7 +33,7 @@ #include "util.h" #include "macroparser.h" -#include "debug.h" +#include #include "database.h" #include "configuration.h" diff --git a/server/src/macrotool/filehandler.cc b/server/src/macrotool/filehandler.cc index 738b687..a45a66e 100644 --- a/server/src/macrotool/filehandler.cc +++ b/server/src/macrotool/filehandler.cc @@ -36,7 +36,7 @@ #include "macroparser.h" #include "template.h" -#include "debug.h" +#include #include "util.h" diff --git a/server/src/macrotool/macrotool.cc b/server/src/macrotool/macrotool.cc index 0445927..60f8302 100644 --- a/server/src/macrotool/macrotool.cc +++ b/server/src/macrotool/macrotool.cc @@ -40,7 +40,7 @@ #include "configurationparser.h" #include "configuration.h" -#include "debug.h" +#include #include "dump.h" #include "fieldnames.h" diff --git a/server/src/pgwork.cc b/server/src/pgwork.cc index 948bb5f..663795a 100644 --- a/server/src/pgwork.cc +++ b/server/src/pgwork.cc @@ -29,7 +29,7 @@ #include -#include "debug.h" +#include /** * Convert list of tuples to list of string arrays. diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc index b68cf07..a67ce7d 100644 --- a/server/src/pracrod.cc +++ b/server/src/pracrod.cc @@ -62,7 +62,7 @@ #include "tcpsocket.h" -#include "debug.h" +#include static const char version_str[] = "Pracro server v" VERSION "\n" @@ -115,13 +115,14 @@ void childwait(int) } } -static FILE *logfp = stderr; -std::string logfile; -bool logfile_reload = false; - void reload(int) { - logfile_reload = true; + printf("Reopening logfile...\n"); + if(hugin_reopen_log() != HUG_STATUS_OK) { + fprintf(stderr, "Could not reopen logfile!\n"); + return; + } + DEBUG(pracro, "Reopened log\n"); } class PracroDaemon : public Daemon { @@ -172,13 +173,16 @@ E0OPPYamkDI/+6Hx2KECQHF9xV1XatyXuFmfRAInK2BtfGY5UIvJaLxVD3Z1+i6q\n\ int main(int argc, char *argv[]) { + const char *hugin_filter = "+all"; + const char *logfile = NULL; + unsigned int hugin_flags = 0; + int c; char *configfile = NULL; char *user = NULL; char *group = NULL; bool foreground = false; char *xml_basedir = NULL; - char *debugstr = NULL; std::string database; std::string pidfile; std::string sessionpath; @@ -239,7 +243,8 @@ int main(int argc, char *argv[]) break; case 'L': - logfile = optarg; + hugin_flags |= HUG_FLAG_OUTPUT_TO_FILE; + logfile = strdup(optarg); break; case 'S': @@ -247,7 +252,8 @@ int main(int argc, char *argv[]) break; case 'D': - debugstr = strdup(optarg); + hugin_flags |= HUG_FLAG_USE_FILTER; + hugin_filter = optarg; break; case 's': @@ -277,17 +283,15 @@ int main(int argc, char *argv[]) } } - if(logfile != "") { - logfp = fopen(logfile.c_str(), "a"); - if(!logfp) { - fprintf(stderr, "Could not write to logfile: '%s'\n", optarg); - logfp = stderr; - } - debug_init(logfp); - } + if(logfile == NULL) hugin_flags |= HUG_FLAG_OUTPUT_TO_STDOUT; - if(debugstr) { - debug_parse(debugstr); + hug_status_t status = hug_init(hugin_flags, + HUG_OPTION_FILTER, hugin_filter, + HUG_OPTION_FILENAME, logfile, + HUG_OPTION_END); + if(status != HUG_STATUS_OK) { + printf("Error: %d\n", status); + return 1; } // Load config @@ -295,10 +299,10 @@ int main(int argc, char *argv[]) if(configfile) configparser = new ConfigurationParser(configfile); else configparser = new ConfigurationParser(ETC"/pracrod.conf"); } catch(ConfigurationParser::ParseException &e) { - ERR_LOG(pracrod, "Config file parse error: %s.\n", e.what()); + ERR(pracrod, "Config file parse error: %s.\n", e.what()); return 1; } catch(ConfigurationParser::ReadException &e) { - ERR_LOG(pracrod, "Config file read error: %s.\n", e.what()); + ERR(pracrod, "Config file read error: %s.\n", e.what()); return 1; } @@ -340,7 +344,5 @@ int main(int argc, char *argv[]) if(user) free(user); if(group) free(group); - if(logfp != stderr) fclose(logfp); - return 0; } diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc index aa1c8bd..6f4d659 100644 --- a/server/src/pracrodaopgsql.cc +++ b/server/src/pracrodaopgsql.cc @@ -46,7 +46,7 @@ #include #include -#include "debug.h" +#include #include "pgwork.h" @@ -66,7 +66,7 @@ PracroDAOPgsql::PracroDAOPgsql(std::string _host, std::string _port, conn = PQconnectdb(cs.c_str()); if(conn == NULL || PQstatus(conn) == CONNECTION_BAD) { - ERR_LOG(db, "Postgresql init failed: %s\n", PQerrorMessage(conn)); + ERR(db, "Postgresql init failed: %s\n", PQerrorMessage(conn)); conn = NULL; return; } @@ -100,7 +100,7 @@ std::string PracroDAOPgsql::newSessionId() ERR(db, "Something wrong with the session counter.\n"); } catch(std::exception &e) { - ERR_LOG(db, "Session counter failed: %s\n", e.what()); + ERR(db, "Session counter failed: %s\n", e.what()); } return ""; @@ -154,7 +154,7 @@ void PracroDAOPgsql::commitTransaction(std::string sessionid, if(ri != R.end()) { std::string status = (*ri)[0].c_str(); if(status == "committed") { - ERR_LOG(db, "Attempt to add to committed session %s blocked!\n", + ERR(db, "Attempt to add to committed session %s blocked!\n", sessionid.c_str()); return; } @@ -165,7 +165,7 @@ void PracroDAOPgsql::commitTransaction(std::string sessionid, /*result_t R = */W.exec(ts); } } catch(std::exception &e) { - ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); return; } @@ -229,7 +229,7 @@ void PracroDAOPgsql::commitTransaction(std::string sessionid, W.commit(); } catch(std::exception &e) { - ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); } } @@ -391,7 +391,7 @@ Values PracroDAOPgsql::getLatestValues(std::string sessionid, } #endif/*NEW*/ } catch (std::exception &e) { - ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str()); + ERR(db, "Query failed: %s: %s\n", e.what(), query.c_str()); } return values; @@ -424,7 +424,7 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string sessionid, DEBUG(sql, "Query: %s\n", query.c_str()); result_t R = W.exec(query); if(R.size() != 1) { - ERR_LOG(db, "No result set; expected one row with one column\n"); + ERR(db, "No result set; expected one row with one column\n"); return 0; } unsigned n = (unsigned)atol((*R.begin())[0].c_str()); @@ -432,7 +432,7 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string sessionid, n, patientid.c_str(), macroname.c_str(), oldest); return n; } catch (std::exception &e) { - ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str()); + ERR(db, "Query failed: %s: %s\n", e.what(), query.c_str()); } return 0; @@ -470,7 +470,7 @@ void PracroDAOPgsql::addFieldname(std::string name, std::string description) result_t R = W.exec(ts); W.commit(); } catch (std::exception &e) { - ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); } } @@ -490,7 +490,7 @@ void PracroDAOPgsql::delFieldname(std::string name) result_t R = W.exec(ts); W.commit(); } catch (std::exception &e) { - ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); } } @@ -519,7 +519,7 @@ std::vector PracroDAOPgsql::getFieldnames() ri++; } } catch (std::exception &e) { - ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str()); + ERR(db, "Query failed: %s: %s\n", e.what(), query.c_str()); } return fieldnames; @@ -540,7 +540,7 @@ void PracroDAOPgsql::commit(std::string sessionid) W.commit(); } catch (std::exception &e) { - ERR_LOG(db, "Commit failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "Commit failed: %s: %s\n", e.what(), ts.c_str()); } } @@ -559,7 +559,7 @@ void PracroDAOPgsql::nocommit(std::string sessionid) W.commit(); } catch (std::exception &e) { - ERR_LOG(db, "NoCommit failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "NoCommit failed: %s: %s\n", e.what(), ts.c_str()); } } @@ -577,7 +577,7 @@ void PracroDAOPgsql::discard(std::string sessionid) /*result_t R = */W.exec(ts); W.commit(); } catch (std::exception &e) { - ERR_LOG(db, "Abort (rollback) failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "Abort (rollback) failed: %s: %s\n", e.what(), ts.c_str()); } } @@ -598,7 +598,7 @@ bool PracroDAOPgsql::idle(std::string sessionid) return status == "idle"; } } catch (std::exception &e) { - ERR_LOG(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str()); } return false; @@ -625,7 +625,7 @@ void PracroDAOPgsql::setIdle(std::string sessionid, bool idle) W.commit(); } catch (std::exception &e) { - ERR_LOG(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str()); + ERR(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str()); } } diff --git a/server/src/pracrodaotest.cc b/server/src/pracrodaotest.cc index a98a9fe..27e0158 100644 --- a/server/src/pracrodaotest.cc +++ b/server/src/pracrodaotest.cc @@ -30,7 +30,7 @@ #include #include -#include "debug.h" +#include static dbtable_t::iterator select(dbtable_t &table, std::string key, std::string value) @@ -97,7 +97,7 @@ void PracroDAOTest::commitTransaction(std::string sessionid, } else { dbrow_t &c = *ci; if(c["status"] == "committed") { - ERR_LOG(db, "Attempt to resume committed session %s blocked!\n", + ERR(db, "Attempt to resume committed session %s blocked!\n", sessionid.c_str()); return; } diff --git a/server/src/queryhandlerpentominos.cc b/server/src/queryhandlerpentominos.cc index 698fc2e..6d461e3 100644 --- a/server/src/queryhandlerpentominos.cc +++ b/server/src/queryhandlerpentominos.cc @@ -26,7 +26,7 @@ */ #include "queryhandlerpentominos.h" -#include "debug.h" +#include #include diff --git a/server/src/queryhandlerpracro.cc b/server/src/queryhandlerpracro.cc index 1187c06..931353d 100644 --- a/server/src/queryhandlerpracro.cc +++ b/server/src/queryhandlerpracro.cc @@ -26,7 +26,7 @@ */ #include "queryhandlerpracro.h" -#include "debug.h" +#include #include diff --git a/server/src/queryresult.h b/server/src/queryresult.h index f734303..7a0ad1a 100644 --- a/server/src/queryresult.h +++ b/server/src/queryresult.h @@ -31,7 +31,7 @@ #include #include -#include "debug.h" +#include class QueryResult { public: diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc index 22907a0..2453a20 100644 --- a/server/src/saxparser.cc +++ b/server/src/saxparser.cc @@ -25,7 +25,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "saxparser.h" -#include "debug.h" +#include #include #include diff --git a/server/src/server.cc b/server/src/server.cc index 8592ad9..ae050d0 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -60,12 +60,6 @@ public: headers_t &getargs, headers_t &headers) { - if(logfile_reload) { - DEBUG(pracrod, "Reopen log file %s\n", logfile.c_str()); - debug_reinit(logfile.c_str()); - logfile_reload = false; - } - Connection *connection = NULL; if(headers.find("User-Agent") != headers.end() && diff --git a/server/src/sessionheaderparser.cc b/server/src/sessionheaderparser.cc index afdaa65..b62e122 100644 --- a/server/src/sessionheaderparser.cc +++ b/server/src/sessionheaderparser.cc @@ -54,28 +54,20 @@ #include #include -#include "debug.h" +#include #include "configuration.h" #include "exception.h" void SessionHeaderParser::error(const char* fmt, ...) { - ERR_LOG(session, "Error in SessionHeaderParser: "); - - { - va_list argp; - va_start(argp, fmt); - ERR_LOG_VA(session, fmt, argp); - va_end(argp); - - fprintf(stderr, "\n"); - } + ERR(session, "Error in SessionHeaderParser: "); { char *p; va_list argp; va_start(argp, fmt); if(vasprintf(&p, fmt, argp) != -1) { + ERR(session, "%s", p); throw Exception("Error in SessionHeaderParser: " + std::string(p)); free(p); } @@ -129,12 +121,12 @@ int SessionHeaderParser::readData(char *data, size_t size) // for and can dismiss the rest of the document. if(fd == -1) { - ERR_LOG(session, "Invalid file descriptor.\n"); + ERR(session, "Invalid file descriptor.\n"); return 0; } ssize_t r = read(fd, data, size); if(r == -1) { - ERR_LOG(session, "Could not read...%s\n", strerror(errno)); + ERR(session, "Could not read...%s\n", strerror(errno)); return 0; } return r; @@ -145,11 +137,11 @@ void SessionHeaderParser::parseError(const char *buf, size_t len, std::string er if(done) return; // If done is true we already found what we were looking // for and can dismiss the rest of the document. - ERR_LOG(session, "SessionHeaderParser[%s] error at line %d: %s\n", + ERR(session, "SessionHeaderParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str()); - ERR_LOG(session, "\tBuffer %u bytes: [", (int)len); + ERR(session, "\tBuffer %u bytes: [", (int)len); if(fwrite(buf, len, 1, stderr) != len) {} - ERR_LOG(session, "]\n"); + ERR(session, "]\n"); char *slineno; if(asprintf(&slineno, " at line %d\n", lineno) != -1) { diff --git a/server/src/sessionparser.cc b/server/src/sessionparser.cc index 349b17b..7674ea1 100644 --- a/server/src/sessionparser.cc +++ b/server/src/sessionparser.cc @@ -29,7 +29,7 @@ #include -#include "debug.h" +#include SessionParser::SessionParser() { diff --git a/server/src/tcpsocket.cc b/server/src/tcpsocket.cc index fc4dab2..ddbedd2 100644 --- a/server/src/tcpsocket.cc +++ b/server/src/tcpsocket.cc @@ -28,7 +28,7 @@ #include "tcpsocket.h" -#include "debug.h" +#include //#define WITH_DEBUG @@ -169,7 +169,7 @@ TCPSocket *TCPSocket::accept() child->isconnected = true; return child; } else { - ERR_LOG(socket, + ERR(socket, "Accept returned with no socket - This should not happen!\n"); return NULL; } diff --git a/server/src/templateheaderparser.cc b/server/src/templateheaderparser.cc index 3c327fd..7274af8 100644 --- a/server/src/templateheaderparser.cc +++ b/server/src/templateheaderparser.cc @@ -44,28 +44,20 @@ #include #include -#include "debug.h" +#include #include "configuration.h" #include "exception.h" void TemplateHeaderParser::error(const char* fmt, ...) { - ERR_LOG(templateparser, "Error in TemplateHeaderParser: "); - - { - va_list argp; - va_start(argp, fmt); - ERR_LOG_VA(templateparser, fmt, argp); - va_end(argp); - - fprintf(stderr, "\n"); - } + ERR(templateparser, "Error in TemplateHeaderParser: "); { char *p; va_list argp; va_start(argp, fmt); if(vasprintf(&p, fmt, argp) != -1) { + ERR(templateparser, "%s", p); throw Exception("Error in TemplateHeaderParser: " + std::string(p)); free(p); } @@ -115,12 +107,12 @@ int TemplateHeaderParser::readData(char *data, size_t size) if(t) return 0; if(fd == -1) { - ERR_LOG(templateparser, "Invalid file descriptor.\n"); + ERR(templateparser, "Invalid file descriptor.\n"); return 0; } ssize_t r = read(fd, data, size); if(r == -1) { - ERR_LOG(templateparser, "Could not read...%s\n", strerror(errno)); + ERR(templateparser, "Could not read...%s\n", strerror(errno)); return 0; } return r; @@ -132,11 +124,11 @@ void TemplateHeaderParser::parseError(const char *buf, size_t len, // Ignore "unclosed token" errors when the template tag has been parsed. if(t) return; - ERR_LOG(templateparser, "TemplateHeaderParser[%s] error at line %d: %s\n", + ERR(templateparser, "TemplateHeaderParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str()); - ERR_LOG(templateparser, "\tBuffer %u bytes: [", (int)len); + ERR(templateparser, "\tBuffer %u bytes: [", (int)len); if(fwrite(buf, len, 1, stderr) != len) {} - ERR_LOG(templateparser, "]\n"); + ERR(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 48dbab5..cf44dda 100644 --- a/server/src/templatelist.cc +++ b/server/src/templatelist.cc @@ -29,7 +29,7 @@ #include "templateheaderparser.h" -#include "debug.h" +#include TemplateList::TemplateList(std::string path) : EntityList(path, "template") diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index 770d8d7..7c35518 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -44,7 +44,7 @@ #include #include "configuration.h" -#include "debug.h" +#include #include "exception.h" void TemplateParser::error(const char* fmt, ...) @@ -54,7 +54,7 @@ void TemplateParser::error(const char* fmt, ...) va_start(argp, fmt); vasprintf(&p, fmt, argp); va_end(argp); - ERR_LOG(template, "Error in TemplateParser: %s\n", p); + ERR(template, "Error in TemplateParser: %s\n", p); throw Exception(std::string("Error in TemplateParser: ") + p); free(p); } @@ -191,12 +191,12 @@ void TemplateParser::endTag(std::string name) int TemplateParser::readData(char *data, size_t size) { if(fd == -1) { - ERR_LOG(template, "Invalid file descriptor.\n"); + ERR(template, "Invalid file descriptor.\n"); return 0; } ssize_t r = read(fd, data, size); if(r == -1) { - ERR_LOG(template, "Could not read...%s\n", strerror(errno)); + ERR(template, "Could not read...%s\n", strerror(errno)); return 0; } return r; diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc index 0340d74..f1e1aee 100644 --- a/server/src/transactionparser.cc +++ b/server/src/transactionparser.cc @@ -33,7 +33,7 @@ #include #include -#include "debug.h" +#include #include "exception.h" TransactionParser::TransactionParser(Transaction *transaction) diff --git a/server/src/utf8.cc b/server/src/utf8.cc index f43d858..51eba94 100644 --- a/server/src/utf8.cc +++ b/server/src/utf8.cc @@ -26,7 +26,7 @@ */ #include "utf8.h" -#include "debug.h" +#include #include diff --git a/server/src/util.cc b/server/src/util.cc index d1085a4..1c431dc 100644 --- a/server/src/util.cc +++ b/server/src/util.cc @@ -31,7 +31,7 @@ #include #include -#include "debug.h" +#include #include "configuration.h" static std::vector listdir(std::string path) diff --git a/server/src/widgetvalue.cc b/server/src/widgetvalue.cc index 7e176bb..f1310f5 100644 --- a/server/src/widgetvalue.cc +++ b/server/src/widgetvalue.cc @@ -27,7 +27,7 @@ */ #include "widgetvalue.h" -#include "debug.h" +#include #include "configuration.h" static bool getMapValue(Value &value, -- cgit v1.2.3