summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authordeva <deva>2009-02-11 10:04:09 +0000
committerdeva <deva>2009-02-11 10:04:09 +0000
commit8a6d1f13b7680bc8f15ce57b8065a9bc774aa891 (patch)
treed07a45e761efb1422fad7c07def6fa77bc67b1a4 /server
parent794100bb1d29d06b379b25899053f997013332e4 (diff)
Changed all printf debug outputs to new debug interface (PRACRO_DEBUG and friends).
Diffstat (limited to 'server')
-rw-r--r--server/src/luaquerymapper.cc7
-rw-r--r--server/src/queryhandlerpentominos.cc24
-rw-r--r--server/src/queryhandlerpracro.cc4
-rw-r--r--server/src/queryresult.h16
4 files changed, 24 insertions, 27 deletions
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 <config.h>
// 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, " <pentominos:entry cpr=\"%s\"\n"
" src_addr=\"%s\"\n"
@@ -180,9 +179,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query)
socket->write(buf, strlen(buf));
#endif/*WITHOUT_PENTOMINOS*/
-#ifdef WITH_DEBUG
- printf(buf);
-#endif/*WITH_DEBUG*/
+ PRACRO_DEBUG(queryhandler, buf);
sprintf(buf, " <pentominos:query format=\"pracroxml\"\n"
" device_id=\"%s\"\n"
@@ -196,9 +193,7 @@ QueryResult QueryHandlerPentominos::exec(Query &query)
socket->write(buf, strlen(buf));
#endif/*WITHOUT_PENTOMINOS*/
-#ifdef WITH_DEBUG
- printf(buf);
-#endif/*WITH_DEBUG*/
+ PRACRO_DEBUG(queryhandler, buf);
sprintf(buf, "</artefact>");
@@ -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 <string>
#include <map>
+#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());
}
};