aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-01-08 23:22:08 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:43 +0100
commitc02151f78b732c49f2ccb138860f5eec3da3a602 (patch)
tree2629ba1f3f48e0549cea9b5eb3d6c9855a17bf4f /src
parent6a379cc5e990c3e199fb59377661b934db45a204 (diff)
downloadusdx-c02151f78b732c49f2ccb138860f5eec3da3a602.tar.gz
usdx-c02151f78b732c49f2ccb138860f5eec3da3a602.tar.xz
usdx-c02151f78b732c49f2ccb138860f5eec3da3a602.zip
added logging using log4cxx
Diffstat (limited to 'src')
-rw-r--r--src/base/database.cpp14
-rw-r--r--src/base/database.hpp7
2 files changed, 13 insertions, 8 deletions
diff --git a/src/base/database.cpp b/src/base/database.cpp
index a6ae3c06..0e1ba92d 100644
--- a/src/base/database.cpp
+++ b/src/base/database.cpp
@@ -36,6 +36,7 @@ namespace usdx
const char usdx_statistics_info[] = "us_statistics_info";
StatDatabase* StatDatabase::instance;
+ log4cxx::LoggerPtr StatDatabase::log = log4cxx::Logger::getLogger("usdx.base.StatDatabase");
StatDatabase::StatDatabase(const std::string filename)
{
@@ -50,8 +51,7 @@ namespace usdx
StatDatabase::~StatDatabase(void)
{
/* frees database */
- // TODO: LOG
- // Log->get_instance()->info("StatDatabase::~StatDatabase") << "~StatDatabase" << endl;
+ LOG4CXX_DEBUG(log, "Closing Database");
sqlite3_close(database);
database = NULL;
@@ -64,8 +64,7 @@ namespace usdx
void StatDatabase::init(const std::string filename)
{
- // TODO: LOG
- // Log->get_instance()->status("StatDatabase::init") << "Initializing database: \"" << filename->to_native() << "\"" << endl;
+ LOG4CXX_DEBUG(log, "Initializing Database: " << filename);
instance = new StatDatabase(filename);
// TODO
@@ -79,6 +78,8 @@ namespace usdx
if (SQLITE_OK != sqlite3_prepare_v2(database, sqlStatement, strlen(sqlStatement), &sqliteStatement, NULL)) {
sqlite3_finalize(sqliteStatement);
+
+ LOG4CXX_ERROR(log, "Error '" << sqlite3_errmsg(database) << "' in SQL '" << sqlStatement << "'");
throw "Error preparing statement.";
}
@@ -102,8 +103,7 @@ namespace usdx
if (SQLITE_OK != sqlite3_prepare_v2(database, sqlStatement.c_str(), sqlStatement.length(), &sqliteStatement, NULL)) {
sqlite3_finalize(sqliteStatement);
- // TODO: LOG
- // std::cerr << sqlite3_errmsg(database) << std::endl;
+ LOG4CXX_ERROR(log, "Error '" << sqlite3_errmsg(database) << "' in SQL '" << sqlStatement << "'");
throw "Error preparing statement.";
}
@@ -308,6 +308,8 @@ namespace usdx
if (SQLITE_OK != sqlite3_prepare_v2(database, sqlStatement.c_str(), sqlStatement.length(), &sqliteStatement, NULL)) {
sqlite3_finalize(sqliteStatement);
+
+ LOG4CXX_ERROR(log, "Error '" << sqlite3_errmsg(database) << "' in SQL '" << sqlStatement << "'");
throw "Error preparing statement.";
}
diff --git a/src/base/database.hpp b/src/base/database.hpp
index 687537cc..0c4b65d6 100644
--- a/src/base/database.hpp
+++ b/src/base/database.hpp
@@ -27,10 +27,11 @@
#ifndef DATABASE_HPP
#define DATABASE_HPP
-#include <time.h>
-#include <sqlite3.h>
+#include <ctime>
#include <iostream>
#include <string>
+#include <sqlite3.h>
+#include <log4cxx/logger.h>
namespace usdx
{
@@ -40,6 +41,8 @@ namespace usdx
class StatDatabase
{
private:
+ static log4cxx::LoggerPtr log;
+
std::string filename;
sqlite3 *database;