diff options
author | Andrey Oleynik <AOleynik@luxoft.com> | 2014-07-16 18:51:11 +0300 |
---|---|---|
committer | Andrey Oleynik <AOleynik@luxoft.com> | 2014-07-16 18:51:11 +0300 |
commit | 91f7605133a8cba52aa6dfdbf92ac61c24c6cdfa (patch) | |
tree | 065afb88892c900a2a42f0cd1a5adc97344a811f | |
parent | 25606765d83de962ecca2b40a0efadc30009a7fc (diff) | |
download | sdl_core-91f7605133a8cba52aa6dfdbf92ac61c24c6cdfa.tar.gz |
APPLINK-8175. Extended error logging added for policy DB backup.
6 files changed, 13 insertions, 8 deletions
diff --git a/customer-specific/pasa/src/components/policy/src/policy/qdb_wrapper/src/makefile b/customer-specific/pasa/src/components/policy/src/policy/qdb_wrapper/src/makefile index 87bcdc8936..a7feacd9a7 100644 --- a/customer-specific/pasa/src/components/policy/src/policy/qdb_wrapper/src/makefile +++ b/customer-specific/pasa/src/components/policy/src/policy/qdb_wrapper/src/makefile @@ -34,6 +34,7 @@ INCLUDES = \ $(CC_IFLAG)./ \
$(CC_IFLAG)../include \
$(CC_IFLAG)../../../../../utils/include \
+ $(CC_IFLAG)../../../../../../3rd_party/log4cxx/include \
$(DEPENDS_INCLUDES)
diff --git a/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_database.h b/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_database.h index 297b461b79..f99dc5a146 100644 --- a/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_database.h +++ b/src/components/policy/src/policy/qdb_wrapper/include/qdb_wrapper/sql_database.h @@ -89,7 +89,7 @@ class SQLDatabase { /** * Call backup for opened DB */ - bool BackupDB(); + bool Backup(); protected: /** * Gets connection to the SQLite database diff --git a/src/components/policy/src/policy/qdb_wrapper/src/sql_database.cc b/src/components/policy/src/policy/qdb_wrapper/src/sql_database.cc index fdaca18316..cb22c9dbda 100644 --- a/src/components/policy/src/policy/qdb_wrapper/src/sql_database.cc +++ b/src/components/policy/src/policy/qdb_wrapper/src/sql_database.cc @@ -30,11 +30,15 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <cstring> #include "qdb_wrapper/sql_database.h" +#include "utils/logger.h" namespace policy { namespace dbms { +CREATE_LOGGERPTR_GLOBAL(logger_, "SQLDatabase") + SQLDatabase::SQLDatabase(const std::string& db_name) : conn_(NULL), db_name_(db_name), @@ -96,13 +100,13 @@ qdb_hdl_t* SQLDatabase::conn() const { return conn_; } -bool SQLDatabase::BackupDB() { +bool SQLDatabase::Backup() { if (qdb_backup(conn_, QDB_ATTACH_DEFAULT) == -1) { error_ = Error::ERROR; - printf("Backup_err\n"); + LOG4CXX_ERROR(logger_, "Backup returned error: " << std::strerror(errno)); return false; } - printf("Backup_ok\n"); + LOG4CXX_INFO(logger_, "Backup was successful."); return true; } diff --git a/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h b/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h index 55a27d969b..b7608e41f0 100644 --- a/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h +++ b/src/components/policy/src/policy/sqlite_wrapper/include/sqlite_wrapper/sql_database.h @@ -97,7 +97,8 @@ class SQLDatabase { /** * Call backup for opened DB */ - bool BackupDB(); + bool Backup(); + protected: /** * Gets connection to the SQLite database diff --git a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc index 3c5ee8d8d4..423d266b47 100644 --- a/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc +++ b/src/components/policy/src/policy/sqlite_wrapper/src/sql_database.cc @@ -98,7 +98,7 @@ void SQLDatabase::set_path(const std::string& path) { databasename_ = path + databasename_; } -bool SQLDatabase::BackupDB() { +bool SQLDatabase::Backup() { return true; } } // namespace dbms diff --git a/src/components/policy/src/policy/src/sql_pt_representation.cc b/src/components/policy/src/policy/src/sql_pt_representation.cc index 125c62e502..82e3bdd3b1 100644 --- a/src/components/policy/src/policy/src/sql_pt_representation.cc +++ b/src/components/policy/src/policy/src/sql_pt_representation.cc @@ -74,8 +74,7 @@ SQLPTRepresentation::SQLPTRepresentation() } SQLPTRepresentation::~SQLPTRepresentation() { - printf("~SQLPTRepresentation\n"); - db_->BackupDB(); + db_->Backup(); db_->Close(); delete db_; } |