From 1fce1358a45d5402146ec3154d2f171172ba2ca2 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Fri, 5 Jul 2013 19:43:15 +0200 Subject: [PATCH] refactor of logging --- other/mysqlclient_main.cpp | 24 +++++++++++++----------- src/MysqlClient.cpp | 2 ++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/other/mysqlclient_main.cpp b/other/mysqlclient_main.cpp index 26c95b3..d4a398c 100644 --- a/other/mysqlclient_main.cpp +++ b/other/mysqlclient_main.cpp @@ -99,14 +99,12 @@ void printResults(std::list &results) { TRACE_STATIC; - LOG ( Logger::DEBUG, std::string("Got query result number of rows: "). - append(TToStr(results.size())).c_str() ); + LOG_BEGIN(Logger::DEBUG) + LOG_PROP("Number of rows", results.size()) + LOG_END_STATIC("Got query results."); - for (std::list::const_iterator it = results.begin(); - it != results.end(); - ++it ) { - LOG ( Logger::DEBUG, (*it).c_str() ); - } + for (std::list::const_iterator it = results.begin(); it != results.end(); ++it ) + LOG_STATIC ( Logger::DEBUG, (*it).c_str() ); } @@ -142,12 +140,16 @@ int main(int argc, char* argv[] ) // work - std::list results; MysqlClient *c = cp.acquire(); - if ( !c->querty("SELECT * FROM seats", results) ) { - LOG ( Logger::ERR, "Could not execute query." ); + MYSQL_RES *result; + std::string queryLine("SELECT * FROM seats"); + if ( !c->querty(queryLine.c_str(), queryLine.length(), &result) ) { + LOG_STATIC ( Logger::ERR, "Could not execute query." ); } else { - printResults(results); + std::list resultList; + c->queryResultToStringList(result, resultList); + printResults(resultList); + mysql_free_result(result); } cp.release(c); diff --git a/src/MysqlClient.cpp b/src/MysqlClient.cpp index 01507ae..3dce371 100644 --- a/src/MysqlClient.cpp +++ b/src/MysqlClient.cpp @@ -1,5 +1,7 @@ #include "MysqlClient.hpp" +#include + #include #include "Logger.hpp"