From 8a6d1f13b7680bc8f15ce57b8065a9bc774aa891 Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 11 Feb 2009 10:04:09 +0000 Subject: Changed all printf debug outputs to new debug interface (PRACRO_DEBUG and friends). --- server/src/luaquerymapper.cc | 7 ++++--- server/src/queryhandlerpentominos.cc | 24 ++++++++---------------- server/src/queryhandlerpracro.cc | 4 +++- server/src/queryresult.h | 16 +++++++++------- 4 files changed, 24 insertions(+), 27 deletions(-) (limited to 'server/src') diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc index 6a7282f..bec9640 100644 --- a/server/src/luaquerymapper.cc +++ b/server/src/luaquerymapper.cc @@ -76,7 +76,7 @@ void LUAQueryMapper::addQueryResult(QueryResult &result) { std::string preload = loadresultstring(result); - printf("Preload:\n%s\n", preload.c_str()); + PRACRO_DEBUG(querymapper, "Preload:\n%s\n", preload.c_str()); if(luaL_loadbuffer(L, preload.c_str(), preload.size(), "preload")) { @@ -107,7 +107,7 @@ Value LUAQueryMapper::map(const std::string &mapper) return v; } - printf("Mapper: %s\n", mapper.c_str()); + PRACRO_DEBUG(querymapper, "Mapper: %s\n", mapper.c_str()); // Load the mapper if(luaL_loadbuffer(L, mapper.c_str(), mapper.size(), "mapper")) { @@ -157,7 +157,8 @@ Value LUAQueryMapper::map(const std::string &mapper) v.value = lua_tostring(L, lua_gettop(L)); lua_pop(L, 1); - printf("Result: value=%s, src=%s, time=%d\n", v.value.c_str(), v.source.c_str(), (int)v.timestamp); + PRACRO_DEBUG(querymapper, "Result: value=%s, src=%s, time=%d\n", + v.value.c_str(), v.source.c_str(), (int)v.timestamp); return v; } diff --git a/server/src/queryhandlerpentominos.cc b/server/src/queryhandlerpentominos.cc index 4b98768..9d39407 100644 --- a/server/src/queryhandlerpentominos.cc +++ b/server/src/queryhandlerpentominos.cc @@ -26,6 +26,8 @@ */ #include "queryhandlerpentominos.h" +#include "debug.h" + #include // For time @@ -63,7 +65,6 @@ typedef struct { unsigned short int count; } UID; - #define SIOCGIFCONF 0x8912 // get iface list static in_addr_t getIP(const char *interface) @@ -157,9 +158,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query) socket->write(header, strlen(header)); #endif/*WITHOUT_PENTOMINOS*/ -#ifdef WITH_DEBUG - printf(header); -#endif/*WITH_DEBUG*/ + PRACRO_DEBUG(queryhandler, header); sprintf(buf, " write(buf, strlen(buf)); #endif/*WITHOUT_PENTOMINOS*/ -#ifdef WITH_DEBUG - printf(buf); -#endif/*WITH_DEBUG*/ + PRACRO_DEBUG(queryhandler, buf); sprintf(buf, " write(buf, strlen(buf)); #endif/*WITHOUT_PENTOMINOS*/ -#ifdef WITH_DEBUG - printf(buf); -#endif/*WITH_DEBUG*/ + PRACRO_DEBUG(queryhandler, buf); sprintf(buf, ""); @@ -206,10 +201,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query) socket->write(buf, strlen(buf)); #endif/*WITHOUT_PENTOMINOS*/ -#ifdef WITH_DEBUG - printf(buf); - fflush(stdout); -#endif/*WITH_DEBUG*/ + PRACRO_DEBUG(queryhandler, buf); QueryResult result; @@ -220,14 +212,14 @@ QueryResult QueryHandlerPentominos::exec(Query &query) // Read until we've got the entire result. while((size = socket->read(buf, sizeof(buf))) > 0) { - fwrite(buf, size, 1, stdout); fflush(stdout); + // fwrite(buf, size, 1, stdout); fflush(stdout); if(parser.parse(buf, size)) break; } result = parser.result; #endif/*WITHOUT_PENTOMINOS*/ - printf("Done handling query\n"); + PRACRO_INFO(queryhandler, "Done handling query\n"); result.print(); diff --git a/server/src/queryhandlerpracro.cc b/server/src/queryhandlerpracro.cc index 99c31b3..8219461 100644 --- a/server/src/queryhandlerpracro.cc +++ b/server/src/queryhandlerpracro.cc @@ -26,6 +26,8 @@ */ #include "queryhandlerpracro.h" +#include "debug.h" + QueryHandlerPracro::QueryHandlerPracro(Database *db, std::string cpr) { this->cpr = cpr; @@ -52,7 +54,7 @@ QueryResult QueryHandlerPracro::exec(Query &query) result.values[field] = value; result.source = "pracro"; - printf("QHP: %s => %s (%lu)\n", field.c_str(), value.c_str(), timestamp); + PRACRO_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 649f975..de95a49 100644 --- a/server/src/queryresult.h +++ b/server/src/queryresult.h @@ -31,6 +31,8 @@ #include #include +#include "debug.h" + class QueryResult { public: time_t timestamp; @@ -39,18 +41,18 @@ public: std::map< std::string, QueryResult > groups; void print(std::string tabs = "") { - printf("%sTimestamp: %d\n", tabs.c_str(), (int)timestamp); - printf("%sSource: %s\n", tabs.c_str(), source.c_str()); - printf("%sValues:\n", tabs.c_str()); + 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++) { - printf("%s[%s] => [%s]\n", tabs.c_str(), i->first.c_str(), i->second.c_str()); + PRACRO_DEBUG(queryhandler,"%s[%s] => [%s]\n", tabs.c_str(), i->first.c_str(), i->second.c_str()); } - printf("%s{\n", tabs.c_str()); + PRACRO_DEBUG(queryhandler,"%s{\n", tabs.c_str()); for(std::map< std::string, QueryResult >::iterator i = groups.begin(); i != groups.end(); i++) { - printf("%s[%s] =>:\n", tabs.c_str(), i->first.c_str()); + PRACRO_DEBUG(queryhandler,"%s[%s] =>:\n", tabs.c_str(), i->first.c_str()); i->second.print(tabs +" "); } - printf("%s}\n", tabs.c_str()); + PRACRO_DEBUG(queryhandler,"%s}\n", tabs.c_str()); } }; -- cgit v1.2.3