add log for debugging
authorHyunjin Park <hj.na.park@samsung.com>
Tue, 2 Jun 2015 02:43:44 +0000 (11:43 +0900)
committerHyunjin Park <hj.na.park@samsung.com>
Tue, 2 Jun 2015 02:43:44 +0000 (11:43 +0900)
- badge, contact

Change-Id: If4021b1d63df86d32b87a9abc95df32a9ef5f316

src/badge/badge_instance.cc
src/badge/badge_manager.cc
src/contact/addressbook.cc
src/contact/contact_manager.cc
src/contact/contact_util.cc
src/contact/person.cc

index c9eb4df..9984e21 100755 (executable)
@@ -25,6 +25,7 @@ using namespace common;
 using namespace extension::badge;
 
 BadgeInstance::BadgeInstance() : manager_(*this) {
+  LoggerD("Enter");
   using std::placeholders::_1;
   using std::placeholders::_2;
 
@@ -39,10 +40,13 @@ BadgeInstance::BadgeInstance() : manager_(*this) {
 #undef REGISTER_SYNC
 }
 
-BadgeInstance::~BadgeInstance() {}
+BadgeInstance::~BadgeInstance() {
+  LoggerD("Enter");
+}
 
 void BadgeInstance::BadgeManagerSetBadgeCount(const JsonValue& args,
                                               JsonObject& out) {
+  LoggerD("Enter");
   std::string app_id =
       common::FromJson<std::string>(args.get<JsonObject>(), "appId");
   const double count = args.get("count").get<double>();
@@ -57,6 +61,7 @@ void BadgeInstance::BadgeManagerSetBadgeCount(const JsonValue& args,
 
 void BadgeInstance::BadgeManagerGetBadgeCount(const JsonValue& args,
                                               JsonObject& out) {
+  LoggerD("Enter");
   std::string app_id =
       common::FromJson<std::string>(args.get<JsonObject>(), "appId");
 
@@ -71,6 +76,7 @@ void BadgeInstance::BadgeManagerGetBadgeCount(const JsonValue& args,
 
 void BadgeInstance::BadgeManagerAddChangeListener(const JsonValue& args,
                                                   JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status =
       manager_.AddChangeListener(args.get<JsonObject>());
 
@@ -82,6 +88,7 @@ void BadgeInstance::BadgeManagerAddChangeListener(const JsonValue& args,
 
 void BadgeInstance::BadgeManagerRemoveChangeListener(const JsonValue& args,
                                                      JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status =
       manager_.RemoveChangeListener(args.get<JsonObject>());
 
index ca17f95..d17bbd0 100755 (executable)
@@ -38,6 +38,7 @@ BadgeManager::BadgeManager(BadgeInstance& instance)
 }
 
 BadgeManager::~BadgeManager() {
+  LoggerD("Enter");
   if (is_cb_registered_) {
     if (!watched_applications_.empty()) watched_applications_.clear();
     int ret = badge_unregister_changed_cb(badge_changed_cb);
@@ -120,6 +121,7 @@ PlatformResult BadgeManager::GetBadgeCount(const std::string& app_id,
 }
 
 PlatformResult BadgeManager::AddChangeListener(const JsonObject &obj) {
+  LoggerD("Enter");
   auto &items = FromJson<picojson::array>(obj, "appIdList");
   for (auto item : items) {
     watched_applications_.insert(common::JsonCast<std::string>(item));
@@ -139,6 +141,7 @@ PlatformResult BadgeManager::AddChangeListener(const JsonObject &obj) {
 }
 
 PlatformResult BadgeManager::RemoveChangeListener(const JsonObject &obj) {
+  LoggerD("Enter");
   auto &items = FromJson<picojson::array>(obj, "appIdList");
   for (auto item : items) {
     watched_applications_.erase(common::JsonCast<std::string>(item));
@@ -158,6 +161,7 @@ PlatformResult BadgeManager::RemoveChangeListener(const JsonObject &obj) {
 
 void BadgeManager::badge_changed_cb(unsigned int action, const char *pkgname,
                                     unsigned int count, void *user_data) {
+  LoggerD("Enter");
   BadgeManager* that = static_cast<BadgeManager*>(user_data);
   if (action != BADGE_ACTION_SERVICE_READY &&
       that->watched_applications_.find(pkgname) != that->watched_applications_.end()) {
index d02e873..04d2199 100755 (executable)
@@ -49,6 +49,7 @@ inline bool IsUnified(long id) { return id == kUnifiedAddressBookId; }
 }  // anonymous namespace
 
 PlatformResult AddressBookGet(const JsonObject& args, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -78,6 +79,7 @@ PlatformResult AddressBookGet(const JsonObject& args, JsonObject& out) {
 }
 
 PlatformResult AddressBookAdd(const JsonObject& args, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -131,6 +133,7 @@ PlatformResult AddressBookAdd(const JsonObject& args, JsonObject& out) {
 }
 
 PlatformResult AddressBookUpdate(const JsonObject& args, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -306,6 +309,7 @@ PlatformResult AddressBookAddBatch(const JsonObject& args, JsonArray& out) {
 PlatformResult AddressBookBatchFunc(NativeFunction impl,
                                     const char* single_arg_name,
                                     const JsonObject& args, JsonArray& out) {
+  LoggerD("Enter");
   const JsonArray& batch_args = FromJson<JsonArray>(args, "batchArgs");
   const JsonObject& address_book = FromJson<JsonObject>(args, "addressBook");
 
@@ -413,6 +417,7 @@ PlatformResult AddressBookFind(const JsonObject& args, JsonArray& array) {
 }
 
 PlatformResult AddressBookAddGroup(const JsonObject& args, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -456,6 +461,7 @@ PlatformResult AddressBookAddGroup(const JsonObject& args, JsonObject& out) {
 }
 
 PlatformResult AddressBookGetGroup(const JsonObject& args, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -498,6 +504,7 @@ PlatformResult AddressBookGetGroup(const JsonObject& args, JsonObject& out) {
 }
 
 PlatformResult AddressBookUpdateGroup(const JsonObject& args, JsonObject&) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -560,6 +567,7 @@ PlatformResult AddressBookUpdateGroup(const JsonObject& args, JsonObject&) {
 }
 
 PlatformResult AddressBookRemoveGroup(const JsonObject& args, JsonObject&) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -601,6 +609,7 @@ PlatformResult AddressBookRemoveGroup(const JsonObject& args, JsonObject&) {
 }
 
 PlatformResult AddressBookGetGroups(const JsonObject& args, JsonArray& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -842,6 +851,7 @@ void AddressBookListenerCallback(const char* view_uri, void* user_data) {
 }
 
 PlatformResult AddressBookStartListening(ContactInstance& instance, const JsonObject&, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
   int current_state = 0;
@@ -871,6 +881,7 @@ PlatformResult AddressBookStartListening(ContactInstance& instance, const JsonOb
 }
 
 PlatformResult AddressBookStopListening(ContactInstance& instance) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
index 77ce87a..bf965c4 100755 (executable)
@@ -40,6 +40,7 @@ using namespace common;
 
 PlatformResult ContactManagerGetAddressBooks(const JsonObject& args,
                                              JsonArray& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -119,6 +120,7 @@ PlatformResult ContactManagerGetAddressBooks(const JsonObject& args,
 
 PlatformResult ContactManagerGetAddressBook(const JsonObject& args,
                                             JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -163,6 +165,7 @@ PlatformResult ContactManagerGetAddressBook(const JsonObject& args,
 
 namespace {
 PlatformResult ContactManagerGetInternal(int person_id, JsonObject* out) {
+  LoggerD("Enter");
   contacts_record_h contacts_record = nullptr;
 
   int error_code = contacts_db_get_record(_contacts_person._uri, person_id,
@@ -185,6 +188,7 @@ PlatformResult ContactManagerGetInternal(int person_id, JsonObject* out) {
 
 PlatformResult ContactManagerAddAddressBook(const JsonObject& args,
                                             JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -239,6 +243,7 @@ PlatformResult ContactManagerAddAddressBook(const JsonObject& args,
 
 PlatformResult ContactManagerRemoveAddressBook(const JsonObject& args,
                                                JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -267,6 +272,7 @@ PlatformResult ContactManagerRemoveAddressBook(const JsonObject& args,
 }
 
 PlatformResult ContactManagerGet(const JsonObject& args, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -276,6 +282,7 @@ PlatformResult ContactManagerGet(const JsonObject& args, JsonObject& out) {
 }
 
 PlatformResult ContactManagerUpdate(const JsonObject& args, JsonObject&) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -306,6 +313,7 @@ PlatformResult ContactManagerUpdate(const JsonObject& args, JsonObject&) {
 }
 
 PlatformResult ContactManagerRemove(const JsonObject& args, JsonObject&) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -326,6 +334,7 @@ PlatformResult ContactManagerRemove(const JsonObject& args, JsonObject&) {
 }
 
 PlatformResult ContactManagerFind(const JsonObject& args, JsonArray& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -756,6 +765,7 @@ PlatformResult ContactManagerFind(const JsonObject& args, JsonArray& out) {
 
 PlatformResult ContactManagerImportFromVCard(const JsonObject& args,
                                              JsonObject& out) {
+  LoggerD("Enter");
   // I'm not sure how to call it. Should it be 'Contact', 'vCard' or what?
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
@@ -810,6 +820,8 @@ bool IsNumeric(const char* s) {
 
 void ContactManagerListenerCallback(const char* view_uri, char* changes,
                                     void* user_data) {
+  LoggerD("ContactManagerListenerCallback");
+
   (void)view_uri;
 
   if (nullptr == changes) {
@@ -890,6 +902,7 @@ void ContactManagerListenerCallback(const char* view_uri, char* changes,
 
 PlatformResult ContactManagerStartListening(ContactInstance& instance, const JsonObject& /*args*/,
                                             JsonObject& /*out*/) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -907,6 +920,7 @@ PlatformResult ContactManagerStartListening(ContactInstance& instance, const Jso
 
 PlatformResult ContactManagerStopListening(ContactInstance& instance, const JsonObject& /*args*/,
                                            JsonObject& /*out*/) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
index 6fde056..d8a5eaa 100755 (executable)
@@ -136,6 +136,7 @@ static const char kContactInstantMessageTypeCustom[] = "CUSTOM";
 }
 
 PlatformResult ErrorChecker(int err, const char* message) {
+  LoggerD("Enter");
   if (CONTACTS_ERROR_NONE != err) {
     LoggerE("%s, error code: %i", message, err);
     return PlatformResult(ErrorCode::UNKNOWN_ERR, message);
@@ -146,6 +147,7 @@ PlatformResult ErrorChecker(int err, const char* message) {
 
 PlatformResult GetStrFromRecord(contacts_record_h record,
                                 unsigned int property_id, char** value) {
+  LoggerD("Enter");
   int err = contacts_record_get_str_p(record, property_id, value);
   if (CONTACTS_ERROR_NONE != err) {
     LoggerE("Error during getting contact record, error code: %i", err);
@@ -158,6 +160,7 @@ PlatformResult GetStrFromRecord(contacts_record_h record,
 
 PlatformResult GetIntFromRecord(contacts_record_h record,
                                 unsigned int property_id, int* value) {
+  LoggerD("Enter");
   int err = contacts_record_get_int(record, property_id, value);
   if (CONTACTS_ERROR_NONE != err) {
     LoggerE("Error during getting contact record, error code: %i", err);
@@ -170,6 +173,7 @@ PlatformResult GetIntFromRecord(contacts_record_h record,
 
 PlatformResult GetBoolFromRecord(contacts_record_h record,
                                  unsigned int property_id, bool* value) {
+  LoggerD("Enter");
   int err = contacts_record_get_bool(record, property_id, value);
   if (CONTACTS_ERROR_NONE != err) {
     LoggerE("Error during getting contact record, error code: %i", err);
@@ -182,6 +186,7 @@ PlatformResult GetBoolFromRecord(contacts_record_h record,
 
 PlatformResult SetStrInRecord(contacts_record_h record,
                               unsigned int property_id, const char* value) {
+  LoggerD("Enter");
   int err = contacts_record_set_str(record, property_id, value);
   if (CONTACTS_ERROR_NONE != err) {
     LoggerE("Error during setting str contact record property, error code: %i",
@@ -195,6 +200,7 @@ PlatformResult SetStrInRecord(contacts_record_h record,
 
 PlatformResult SetIntInRecord(contacts_record_h record,
                               unsigned int property_id, int value) {
+  LoggerD("Enter");
   int err = contacts_record_set_int(record, property_id, value);
   if (CONTACTS_ERROR_NONE != err) {
     LoggerE("Error during getting contact record, error code: %i", err);
@@ -207,6 +213,7 @@ PlatformResult SetIntInRecord(contacts_record_h record,
 
 PlatformResult SetBoolInRecord(contacts_record_h record,
                                unsigned int property_id, bool value) {
+  LoggerD("Enter");
   int err = contacts_record_set_bool(record, property_id, value);
   if (CONTACTS_ERROR_NONE != err) {
     LoggerE("Error during getting contact record, error code: %i", err);
@@ -219,6 +226,7 @@ PlatformResult SetBoolInRecord(contacts_record_h record,
 
 PlatformResult ClearAllContactRecord(contacts_record_h contacts_record,
                                      unsigned int property_id) {
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -229,7 +237,10 @@ PlatformResult ClearAllContactRecord(contacts_record_h contacts_record,
   int record_count;
   PlatformResult status =
       GetNumberOfChildRecord(contacts_record, property_id, &record_count);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   for (unsigned int i = 0; i < record_count; ++i) {
     unsigned int actual_index = record_count - 1 - i;
@@ -238,13 +249,19 @@ PlatformResult ClearAllContactRecord(contacts_record_h contacts_record,
         contacts_record, property_id, actual_index, &phone_record);
     PlatformResult status =
         ContactUtil::ErrorChecker(err, "Error during getting phone record");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     err = contacts_record_remove_child_record(contacts_record, property_id,
                                               phone_record);
     status =
         ContactUtil::ErrorChecker(err, "Error during getting phone record");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   return PlatformResult(ErrorCode::NO_ERROR);
@@ -253,6 +270,7 @@ PlatformResult ClearAllContactRecord(contacts_record_h contacts_record,
 PlatformResult GetNumberOfChildRecord(contacts_record_h contacts_record,
                                       unsigned int property_id,
                                       int* child_count) {
+  LoggerD("Enter");
   assert(child_count);
 
   int err = CONTACTS_ERROR_NONE;
@@ -269,6 +287,7 @@ PlatformResult GetNumberOfChildRecord(contacts_record_h contacts_record,
 PlatformResult ImportContactNameFromContactsRecord(
     contacts_record_h contacts_record, JsonObject* out_ptr,
     bool* is_contact_name) {
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   if (!contacts_record) {
     LoggerW("Contacts record is null");
@@ -280,7 +299,10 @@ PlatformResult ImportContactNameFromContactsRecord(
                                                _contacts_contact.name, &count);
   PlatformResult status =
       ContactUtil::ErrorChecker(err, "Contacts child record get count error");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (count > 1) {
     LoggerE("More than one ContactName for one Contact");
@@ -299,7 +321,10 @@ PlatformResult ImportContactNameFromContactsRecord(
       contacts_record, _contacts_contact.name, 0, &contact_name);
   status =
       ContactUtil::ErrorChecker(err, "Contacts name record get childerror");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Documentation says:
   //  child_record MUST NOT be released by you.
@@ -309,56 +334,80 @@ PlatformResult ImportContactNameFromContactsRecord(
   char* char_value = nullptr;
   status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.prefix,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("prefix",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.suffix,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("suffix",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.first,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("firstName",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.addition,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("middleName",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.last,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("lastName",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(
       contact_name, _contacts_name.phonetic_first, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("phoneticFirstName",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(
       contact_name, _contacts_name.phonetic_middle, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("phoneticMiddleName",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(
       contact_name, _contacts_name.phonetic_last, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("phoneticLastName",
                             char_value ? JsonValue{char_value} : JsonValue{}));
@@ -367,7 +416,10 @@ PlatformResult ImportContactNameFromContactsRecord(
       contacts_record, _contacts_contact.nickname, &count);
   status =
       ContactUtil::ErrorChecker(err, "Contacts child record get count error");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   JsonArray nicknames;
   for (unsigned int i = 0; i < count; ++i) {
@@ -376,11 +428,17 @@ PlatformResult ImportContactNameFromContactsRecord(
         contacts_record, _contacts_contact.nickname, i, &nickname);
     status = ContactUtil::ErrorChecker(
         err, "Contacts nicknames record get child error");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     status = ContactUtil::GetStrFromRecord(nickname, _contacts_nickname.name,
                                            &char_value);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     if (char_value) {
       nicknames.push_back(JsonValue{char_value});
@@ -394,6 +452,8 @@ PlatformResult ImportContactNameFromContactsRecord(
 
 PlatformResult ExportContactNameToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -410,7 +470,10 @@ PlatformResult ExportContactNameToContactsRecord(
     err = contacts_record_create(_contacts_name._uri, &contact_name);
     PlatformResult status =
         ContactUtil::ErrorChecker(err, "Contacts record create error");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     update = false;
   }
@@ -421,49 +484,73 @@ PlatformResult ExportContactNameToContactsRecord(
     PlatformResult status =
         ContactUtil::SetStrInRecord(*contacts_name_ptr, _contacts_name.prefix,
                                     FromJson<JsonString>(in, "prefix").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "suffix")) {
     PlatformResult status =
         ContactUtil::SetStrInRecord(*contacts_name_ptr, _contacts_name.suffix,
                                     FromJson<JsonString>(in, "suffix").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "firstName")) {
     PlatformResult status = ContactUtil::SetStrInRecord(
         *contacts_name_ptr, _contacts_name.first,
         FromJson<JsonString>(in, "firstName").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "middleName")) {
     PlatformResult status = ContactUtil::SetStrInRecord(
         *contacts_name_ptr, _contacts_name.addition,
         FromJson<JsonString>(in, "middleName").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "lastName")) {
     PlatformResult status = ContactUtil::SetStrInRecord(
         *contacts_name_ptr, _contacts_name.last,
         FromJson<JsonString>(in, "lastName").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "phoneticFirstName")) {
     PlatformResult status = ContactUtil::SetStrInRecord(
         *contacts_name_ptr, _contacts_name.phonetic_first,
         FromJson<JsonString>(in, "phoneticFirstName").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "phoneticMiddleName")) {
     PlatformResult status = ContactUtil::SetStrInRecord(
         *contacts_name_ptr, _contacts_name.phonetic_middle,
         FromJson<JsonString>(in, "phoneticMiddleName").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "phoneticLastName")) {
     PlatformResult status = ContactUtil::SetStrInRecord(
         *contacts_name_ptr, _contacts_name.phonetic_last,
         FromJson<JsonString>(in, "phoneticLastName").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   // contact_name is being added as a child to contacts_record
@@ -473,7 +560,10 @@ PlatformResult ExportContactNameToContactsRecord(
         contacts_record, _contacts_contact.name, *contacts_name_ptr);
     PlatformResult status =
         ContactUtil::ErrorChecker(err, "Contacts record add child error");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   // and now unique_ptr can be released - contacts_name is protected
   // by its parent (contacts_record)
@@ -489,7 +579,10 @@ PlatformResult ExportContactNameToContactsRecord(
       err = contacts_record_create(_contacts_nickname._uri, &nickname_record);
       PlatformResult status =
           ContactUtil::ErrorChecker(err, "Contacts record create error");
-      if (status.IsError()) return status;
+      if (status.IsError()) {
+        LoggerE("Error: %s", status.message().c_str());
+        return status;
+      }
 
       update = false;
     }
@@ -498,14 +591,20 @@ PlatformResult ExportContactNameToContactsRecord(
     PlatformResult status =
         ContactUtil::SetStrInRecord(*nickname_ptr, _contacts_nickname.name,
                                     JsonCast<JsonString>(nickname).c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     if (!update) {
       err = contacts_record_add_child_record(
           contacts_record, _contacts_contact.nickname, *nickname_ptr);
       PlatformResult status =
           ContactUtil::ErrorChecker(err, "Contacts record add child error");
-      if (status.IsError()) return status;
+      if (status.IsError()) {
+        LoggerE("Error: %s", status.message().c_str());
+        return status;
+      }
     }
     // Do not delete record, it is passed to the platform
     nickname_ptr.release();
@@ -519,6 +618,8 @@ PlatformResult ExportContactNameToContactsRecord(
 PlatformResult ImportContactEmailAddressFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index,
     JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -538,7 +639,10 @@ PlatformResult ImportContactEmailAddressFromContactsRecord(
   char* email = nullptr;
   PlatformResult status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_email.email, &email);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!email) {
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -548,21 +652,30 @@ PlatformResult ImportContactEmailAddressFromContactsRecord(
   bool is_default = false;
   status = ContactUtil::GetBoolFromRecord(
       child_record, _contacts_email.is_default, &is_default);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("isDefault", JsonValue{is_default}));
 
   char* label = nullptr;
   status = ContactUtil::GetStrFromRecord(child_record, _contacts_email.label,
                                          &label);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("label", label ? JsonValue{label} : JsonValue{}));
 
   int type = 0;
   status =
       ContactUtil::GetIntFromRecord(child_record, _contacts_email.type, &type);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   JsonArray types;
   if (type & CONTACTS_EMAIL_TYPE_HOME) {
@@ -589,6 +702,8 @@ PlatformResult ImportContactEmailAddressFromContactsRecord(
 
 PlatformResult ExportContactEmailAddressToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   contacts_record_h c_email_record_h = nullptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -601,25 +716,37 @@ PlatformResult ExportContactEmailAddressToContactsRecord(
   err = contacts_record_create(_contacts_email._uri, &c_email_record_h);
   PlatformResult status = ContactUtil::ErrorChecker(
       err, "Failed to create email record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&c_email_record_h, ContactsDeleter);
 
   status =
       ContactUtil::SetStrInRecord(c_email_record_h, _contacts_email.email,
                                   FromJson<JsonString>(in, "email").c_str());
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   status =
       ContactUtil::SetBoolInRecord(c_email_record_h, _contacts_email.is_default,
                                    FromJson<bool>(in, "isDefault"));
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!IsNull(in, "label")) {
     status =
         ContactUtil::SetStrInRecord(c_email_record_h, _contacts_email.label,
                                     FromJson<JsonString>(in, "label").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   int type_to_set = 0;
@@ -639,13 +766,19 @@ PlatformResult ExportContactEmailAddressToContactsRecord(
   }
   status = ContactUtil::SetIntInRecord(c_email_record_h, _contacts_email.type,
                                        type_to_set);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   err = contacts_record_add_child_record(
       contacts_record, _contacts_contact.email, c_email_record_h);
   status =
       ContactUtil::ErrorChecker(err, "Fail to save email record into database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Do not delete record, it is passed to the platform
   record.release();
@@ -656,6 +789,8 @@ PlatformResult ExportContactEmailAddressToContactsRecord(
 PlatformResult ImportContactPhoneNumberFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index,
     JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   contacts_record_h child_record = nullptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
@@ -674,20 +809,29 @@ PlatformResult ImportContactPhoneNumberFromContactsRecord(
   char* phone = nullptr;
   PlatformResult status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_number.number, &phone);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("number", JsonValue{phone}));
 
   bool is_default = false;
   status = ContactUtil::GetBoolFromRecord(
       child_record, _contacts_number.is_default, &is_default);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("isDefault", JsonValue{is_default}));
   int type = 0;
   status =
       ContactUtil::GetIntFromRecord(child_record, _contacts_number.type, &type);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   JsonArray types;
   if (type & CONTACTS_NUMBER_TYPE_HOME) {
@@ -746,7 +890,10 @@ PlatformResult ImportContactPhoneNumberFromContactsRecord(
   char* label = nullptr;
   status = ContactUtil::GetStrFromRecord(child_record, _contacts_number.label,
                                          &label);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out["label"] = label ? JsonValue{label} : JsonValue{};
 
@@ -755,6 +902,8 @@ PlatformResult ImportContactPhoneNumberFromContactsRecord(
 
 PlatformResult ExportContactPhoneNumberToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   contacts_record_h phone_record = nullptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -766,25 +915,37 @@ PlatformResult ExportContactPhoneNumberToContactsRecord(
   int err = contacts_record_create(_contacts_number._uri, &phone_record);
   PlatformResult status =
       ContactUtil::ErrorChecker(err, "Fail to create phone_record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&phone_record, ContactsDeleter);
 
   status =
       ContactUtil::SetStrInRecord(phone_record, _contacts_number.number,
                                   FromJson<JsonString>(in, "number").c_str());
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   status =
       ContactUtil::SetBoolInRecord(phone_record, _contacts_number.is_default,
                                    FromJson<bool>(in, "isDefault"));
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!IsNull(in, "label")) {
     status =
         ContactUtil::SetStrInRecord(phone_record, _contacts_address.label,
                                     FromJson<JsonString>(in, "label").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   int type_to_set = 0;
@@ -830,13 +991,19 @@ PlatformResult ExportContactPhoneNumberToContactsRecord(
 
   status = ContactUtil::SetIntInRecord(phone_record, _contacts_number.type,
                                        type_to_set);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   err = contacts_record_add_child_record(
       contacts_record, _contacts_contact.number, phone_record);
   status = ContactUtil::ErrorChecker(
       err, "Fail to set number value to phone_record");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Do not delete record, it is passed to the platform
   record.release();
@@ -847,6 +1014,8 @@ PlatformResult ExportContactPhoneNumberToContactsRecord(
 PlatformResult ImportContactOrganizationFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index,
     JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -866,35 +1035,50 @@ PlatformResult ImportContactOrganizationFromContactsRecord(
   char* char_value = nullptr;
   PlatformResult status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_company.name, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("name", char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_company.department, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("department",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_company.job_title, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("title",
                             char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(child_record, _contacts_company.role,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("role", char_value ? JsonValue{char_value} : JsonValue{}));
 
   status = ContactUtil::GetStrFromRecord(child_record, _contacts_company.logo,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("logoURI",
                             char_value ? JsonValue{char_value} : JsonValue{}));
@@ -904,6 +1088,8 @@ PlatformResult ImportContactOrganizationFromContactsRecord(
 
 PlatformResult ExportContactOrganizationToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -916,7 +1102,10 @@ PlatformResult ExportContactOrganizationToContactsRecord(
   err = contacts_record_create(_contacts_company._uri, &organization_record);
   PlatformResult status = ContactUtil::ErrorChecker(
       err, "Failed to create organization record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&organization_record, ContactsDeleter);
 
@@ -924,39 +1113,57 @@ PlatformResult ExportContactOrganizationToContactsRecord(
     status =
         ContactUtil::SetStrInRecord(organization_record, _contacts_company.name,
                                     FromJson<JsonString>(in, "name").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "department")) {
     status = ContactUtil::SetStrInRecord(
         organization_record, _contacts_company.department,
         FromJson<JsonString>(in, "department").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "title")) {
     status = ContactUtil::SetStrInRecord(
         organization_record, _contacts_company.job_title,
         FromJson<JsonString>(in, "title").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "role")) {
     status =
         ContactUtil::SetStrInRecord(organization_record, _contacts_company.role,
                                     FromJson<JsonString>(in, "role").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "logoURI")) {
     std::string path =
         ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "logoURI"));
     status = ContactUtil::SetStrInRecord(organization_record,
                                          _contacts_company.logo, path.c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   err = contacts_record_add_child_record(
       contacts_record, _contacts_contact.company, organization_record);
   status = ContactUtil::ErrorChecker(
       err, "Fail to set company value to child_record");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Do not delete record, it is passed to the platform
   record.release();
@@ -967,6 +1174,8 @@ PlatformResult ExportContactOrganizationToContactsRecord(
 PlatformResult ImportContactWebSiteFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index,
     JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -986,7 +1195,10 @@ PlatformResult ImportContactWebSiteFromContactsRecord(
   char* char_value = nullptr;
   PlatformResult status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_url.url, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair(std::string("logoURI"),
       picojson::value(char_value ? char_value : "")));
@@ -994,7 +1206,10 @@ PlatformResult ImportContactWebSiteFromContactsRecord(
   int type = 0;
   status =
       ContactUtil::GetIntFromRecord(child_record, _contacts_url.type, &type);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair(std::string("logoURI"),
         picojson::value((CONTACTS_URL_TYPE_HOME == type)
@@ -1006,6 +1221,8 @@ PlatformResult ImportContactWebSiteFromContactsRecord(
 
 PlatformResult ExportContactWebSiteToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -1029,13 +1246,19 @@ PlatformResult ExportContactWebSiteToContactsRecord(
   err = contacts_record_create(_contacts_url._uri, &website_record_h);
   PlatformResult status = ContactUtil::ErrorChecker(
       err, "Fail to create website record in database.");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&website_record_h, ContactsDeleter);
 
   status = ContactUtil::SetStrInRecord(website_record_h, _contacts_url.url,
                                        url.c_str());
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   int type_to_set =
       (FromJson<JsonString>(in, "type") == kContactWebSiteTypeHomePage)
@@ -1044,13 +1267,19 @@ PlatformResult ExportContactWebSiteToContactsRecord(
 
   status = ContactUtil::SetIntInRecord(website_record_h, _contacts_url.type,
                                        type_to_set);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   err = contacts_record_add_child_record(contacts_record, _contacts_contact.url,
                                          website_record_h);
   status = ContactUtil::ErrorChecker(
       err, "Problem during saving WebSite urls into database.");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Do not delete record, it is passed to the platform
   record.release();
@@ -1061,6 +1290,8 @@ PlatformResult ExportContactWebSiteToContactsRecord(
 PlatformResult ImportContactAnniversariesFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index, JsonObject* out_ptr,
     bool* ret) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -1081,7 +1312,10 @@ PlatformResult ImportContactAnniversariesFromContactsRecord(
   int value = 0;
   PlatformResult status =
       ContactUtil::GetIntFromRecord(child_record, _contacts_event.type, &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (CONTACTS_EVENT_TYPE_BIRTH == value) {
     *ret = false;
@@ -1091,14 +1325,20 @@ PlatformResult ImportContactAnniversariesFromContactsRecord(
   if (CONTACTS_EVENT_TYPE_ANNIVERSARY == value) {
     status = ContactUtil::GetIntFromRecord(child_record, _contacts_event.date,
                                            &value);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     out.insert(std::make_pair("date", JsonValue{static_cast<double>(value)}));
 
     char* label = nullptr;
     status = ContactUtil::GetStrFromRecord(child_record, _contacts_event.label,
                                            &label);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     out.insert(std::make_pair("label", label ? JsonValue{label} : JsonValue{}));
   }
@@ -1109,6 +1349,8 @@ PlatformResult ImportContactAnniversariesFromContactsRecord(
 
 PlatformResult ExportContactAnniversariesToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -1126,30 +1368,45 @@ PlatformResult ExportContactAnniversariesToContactsRecord(
   err = contacts_record_create(_contacts_event._uri, &anniversary_record);
   PlatformResult status = ContactUtil::ErrorChecker(
       err, "Failed to create anniversary record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&anniversary_record, ContactsDeleter);
 
   status = ContactUtil::SetIntInRecord(anniversary_record, _contacts_event.type,
                                        CONTACTS_EVENT_TYPE_ANNIVERSARY);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   status = ContactUtil::SetIntInRecord(anniversary_record, _contacts_event.date,
                                        date);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!IsNull(in, "label")) {
     status =
         ContactUtil::SetStrInRecord(anniversary_record, _contacts_event.label,
                                     FromJson<JsonString>(in, "label").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   err = contacts_record_add_child_record(
       contacts_record, _contacts_contact.event, anniversary_record);
   status = ContactUtil::ErrorChecker(
       err, "Fail to save anniversary record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Do not delete record, it is passed to the platform
   record.release();
@@ -1160,6 +1417,8 @@ PlatformResult ExportContactAnniversariesToContactsRecord(
 PlatformResult ImportContactRelationshipFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index,
     JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -1179,7 +1438,10 @@ PlatformResult ImportContactRelationshipFromContactsRecord(
   char* relative = nullptr;
   PlatformResult status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_relationship.name, &relative);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!relative) {
     return PlatformResult(ErrorCode::NO_ERROR);
@@ -1191,7 +1453,10 @@ PlatformResult ImportContactRelationshipFromContactsRecord(
   int type = 0;
   status = ContactUtil::GetIntFromRecord(child_record,
                                          _contacts_relationship.type, &type);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // TODO Move out.insert outside of switch statement.
   switch (type) {
@@ -1281,7 +1546,10 @@ PlatformResult ImportContactRelationshipFromContactsRecord(
   char* label = nullptr;
   status = ContactUtil::GetStrFromRecord(child_record,
                                          _contacts_relationship.label, &label);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair(std::string("label"),
@@ -1292,6 +1560,8 @@ PlatformResult ImportContactRelationshipFromContactsRecord(
 
 PlatformResult ExportContactRelationshipToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -1304,14 +1574,20 @@ PlatformResult ExportContactRelationshipToContactsRecord(
   err = contacts_record_create(_contacts_relationship._uri, &child_record);
   PlatformResult status =
       ContactUtil::ErrorChecker(err, "Fail to create child_record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&child_record, ContactsDeleter);
 
   status = ContactUtil::SetStrInRecord(
       child_record, _contacts_relationship.name,
       FromJson<JsonString>(in, "relativeName").c_str());
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   const JsonString& type = FromJson<JsonString>(in, "type");
   int type_to_set;
@@ -1351,20 +1627,29 @@ PlatformResult ExportContactRelationshipToContactsRecord(
 
   status = ContactUtil::SetIntInRecord(
       child_record, _contacts_relationship.type, type_to_set);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!IsNull(in, "label")) {
     status =
         ContactUtil::SetStrInRecord(child_record, _contacts_relationship.label,
                                     FromJson<JsonString>(in, "label").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   err = contacts_record_add_child_record(
       contacts_record, _contacts_contact.relationship, child_record);
   status = ContactUtil::ErrorChecker(
       err, "Fail to set number value to child_record");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   record.release();
 
@@ -1374,6 +1659,8 @@ PlatformResult ExportContactRelationshipToContactsRecord(
 PlatformResult ImportContactInstantMessengerFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index,
     JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -1394,7 +1681,10 @@ PlatformResult ImportContactInstantMessengerFromContactsRecord(
   char* im_address = nullptr;
   PlatformResult status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_messenger.im_id, &im_address);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!im_address) {
     LoggerW("Skipping message with index %i. missing im address", index);
@@ -1406,7 +1696,10 @@ PlatformResult ImportContactInstantMessengerFromContactsRecord(
   int type = 0;
   status = ContactUtil::GetIntFromRecord(child_record, _contacts_messenger.type,
                                          &type);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // TODO Move out.insert outside of switch statement.
   switch (type) {
@@ -1464,7 +1757,10 @@ PlatformResult ImportContactInstantMessengerFromContactsRecord(
   char* label = nullptr;
   status = ContactUtil::GetStrFromRecord(child_record,
                                          _contacts_messenger.label, &label);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("label", label ? JsonValue{label} : JsonValue{}));
 
@@ -1473,6 +1769,8 @@ PlatformResult ImportContactInstantMessengerFromContactsRecord(
 
 PlatformResult ExportContactInstantMessengerToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -1485,14 +1783,20 @@ PlatformResult ExportContactInstantMessengerToContactsRecord(
   err = contacts_record_create(_contacts_messenger._uri, &child_record);
   PlatformResult status =
       ContactUtil::ErrorChecker(err, "Fail to create child_record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&child_record, ContactsDeleter);
 
   status = ContactUtil::SetStrInRecord(
       child_record, _contacts_messenger.im_id,
       FromJson<JsonString>(in, "imAddress").c_str());
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   int type_to_set = 0;
   const JsonString& type = FromJson<JsonString>(in, "type");
@@ -1524,20 +1828,29 @@ PlatformResult ExportContactInstantMessengerToContactsRecord(
 
   status = ContactUtil::SetIntInRecord(child_record, _contacts_messenger.type,
                                        type_to_set);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!IsNull(in, "label")) {
     status =
         ContactUtil::SetStrInRecord(child_record, _contacts_messenger.label,
                                     FromJson<JsonString>(in, "label").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   err = contacts_record_add_child_record(
       contacts_record, _contacts_contact.messenger, child_record);
   status = ContactUtil::ErrorChecker(
       err, "Fail to set number value to child_record");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   record.release();
 
@@ -1547,6 +1860,8 @@ PlatformResult ExportContactInstantMessengerToContactsRecord(
 PlatformResult ImportContactAddressFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index,
     JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -1566,54 +1881,81 @@ PlatformResult ImportContactAddressFromContactsRecord(
   char* value = nullptr;
   PlatformResult status = ContactUtil::GetStrFromRecord(
       child_record, _contacts_address.country, &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("country", value ? JsonValue{value} : JsonValue{}));
   status = ContactUtil::GetStrFromRecord(child_record, _contacts_address.region,
                                          &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("region", value ? JsonValue{value} : JsonValue{}));
   status = ContactUtil::GetStrFromRecord(child_record,
                                          _contacts_address.locality, &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("city", value ? JsonValue{value} : JsonValue{}));
   status = ContactUtil::GetStrFromRecord(child_record, _contacts_address.street,
                                          &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("streetAddress", value ? JsonValue{value} : JsonValue{}));
   status = ContactUtil::GetStrFromRecord(child_record,
                                          _contacts_address.extended, &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("additionalInformation",
                             value ? JsonValue{value} : JsonValue{}));
   status = ContactUtil::GetStrFromRecord(child_record,
                                          _contacts_address.postal_code, &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("postalCode", value ? JsonValue{value} : JsonValue{}));
   status = ContactUtil::GetStrFromRecord(child_record, _contacts_address.label,
                                          &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("label", value ? JsonValue{value} : JsonValue{}));
 
   bool bool_value = false;
   status = ContactUtil::GetBoolFromRecord(
       child_record, _contacts_address.is_default, &bool_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("isDefault", JsonValue{bool_value}));
 
   int int_value = 0;
   status = ContactUtil::GetIntFromRecord(child_record, _contacts_address.type,
                                          &int_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   JsonArray types;
   if (int_value & CONTACTS_ADDRESS_TYPE_HOME) {
@@ -1639,6 +1981,8 @@ PlatformResult ImportContactAddressFromContactsRecord(
 
 PlatformResult ExportContactAddressToContactsRecord(
     contacts_record_h contacts_record, const JsonObject& in) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -1651,7 +1995,10 @@ PlatformResult ExportContactAddressToContactsRecord(
   err = contacts_record_create(_contacts_address._uri, &address_record);
   PlatformResult status = ContactUtil::ErrorChecker(
       err, "Failed to create address record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&address_record, ContactsDeleter);
 
@@ -1659,49 +2006,73 @@ PlatformResult ExportContactAddressToContactsRecord(
     status = ContactUtil::SetStrInRecord(
         address_record, _contacts_address.country,
         FromJson<JsonString>(in, "country").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "region")) {
     status =
         ContactUtil::SetStrInRecord(address_record, _contacts_address.region,
                                     FromJson<JsonString>(in, "region").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "city")) {
     status =
         ContactUtil::SetStrInRecord(address_record, _contacts_address.locality,
                                     FromJson<JsonString>(in, "city").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "streetAddress")) {
     status = ContactUtil::SetStrInRecord(
         address_record, _contacts_address.street,
         FromJson<JsonString>(in, "streetAddress").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "additionalInformation")) {
     status = ContactUtil::SetStrInRecord(
         address_record, _contacts_address.extended,
         FromJson<JsonString>(in, "additionalInformation").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "postalCode")) {
     status = ContactUtil::SetStrInRecord(
         address_record, _contacts_address.postal_code,
         FromJson<JsonString>(in, "postalCode").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(in, "label")) {
     status =
         ContactUtil::SetStrInRecord(address_record, _contacts_address.label,
                                     FromJson<JsonString>(in, "label").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   status =
       ContactUtil::SetBoolInRecord(address_record, _contacts_address.is_default,
                                    FromJson<bool>(in, "isDefault"));
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   int type_to_set = 0;
   const JsonArray& types = FromJson<JsonArray>(in, "types");
@@ -1720,13 +2091,19 @@ PlatformResult ExportContactAddressToContactsRecord(
 
   status = ContactUtil::SetIntInRecord(address_record, _contacts_address.type,
                                        type_to_set);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   err = contacts_record_add_child_record(
       contacts_record, _contacts_contact.address, address_record);
   status =
       ContactUtil::ErrorChecker(err, "Fail to save address record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Do not delete record, it is passed to the platform
   record.release();
@@ -1736,6 +2113,8 @@ PlatformResult ExportContactAddressToContactsRecord(
 
 PlatformResult ImportContactNotesFromContactsRecord(
     contacts_record_h contacts_record, unsigned int index, JsonValue* val) {
+
+  LoggerD("Enter");
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
@@ -1754,7 +2133,10 @@ PlatformResult ImportContactNotesFromContactsRecord(
   char* note = nullptr;
   PlatformResult status =
       ContactUtil::GetStrFromRecord(notes_record, _contacts_note.note, &note);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (note) {
     *val = JsonValue{note};
@@ -1765,6 +2147,8 @@ PlatformResult ImportContactNotesFromContactsRecord(
 
 PlatformResult ExportNotesToContactsRecord(contacts_record_h contacts_record,
                                            const std::string& value) {
+
+  LoggerD("Enter");
   contacts_record_h notes_record = nullptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
@@ -1777,19 +2161,28 @@ PlatformResult ExportNotesToContactsRecord(contacts_record_h contacts_record,
   err = contacts_record_create(_contacts_note._uri, &notes_record);
   PlatformResult status =
       ContactUtil::ErrorChecker(err, "Fail to create note record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   ContactsRecordHPtr record(&notes_record, ContactsDeleter);
 
   status = ContactUtil::SetStrInRecord(notes_record, _contacts_note.note,
                                        value.c_str());
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   err = contacts_record_add_child_record(contacts_record,
                                          _contacts_contact.note, notes_record);
   status =
       ContactUtil::ErrorChecker(err, "Fail to save note record in database");
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   // Do not delete record, it is passed to the platform
   record.release();
@@ -1799,42 +2192,59 @@ PlatformResult ExportNotesToContactsRecord(contacts_record_h contacts_record,
 
 PlatformResult ImportContactFromContactsRecord(
     contacts_record_h contacts_record, JsonObject* out_ptr) {
+
+  LoggerD("Enter");
   JsonObject& out = *out_ptr;
   // contacts_record is protected by unique_ptr and its ownership is not passed
   // here
   if (!contacts_record) {
-    LoggerW("Contacts record is null");
+    LoggerE("Contacts record is null");
     return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
   }
 
   int id = 0;
   PlatformResult status =
       ContactUtil::GetIntFromRecord(contacts_record, _contacts_contact.id, &id);
-  if (status.IsError()) return status;
-
+  if (status.IsError())
+  {
+    LoggerE("Fail: GetIntFromRecord");
+    return status;
+  }
   out.insert(std::make_pair("id", JsonValue{std::to_string(id)}));
   status = ContactUtil::GetIntFromRecord(
       contacts_record, _contacts_contact.address_book_id, &id);
-  if (status.IsError()) return status;
-
+  if (status.IsError())
+  {
+    LoggerE("Fail: GetIntFromRecord");
+    return status;
+  }
   out.insert(std::make_pair("addressBookId", JsonValue{std::to_string(id)}));
   status = ContactUtil::GetIntFromRecord(contacts_record,
                                          _contacts_contact.person_id, &id);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("personId", JsonValue{std::to_string(id)}));
 
   bool is_favorite = false;
   status = ContactUtil::GetBoolFromRecord(
       contacts_record, _contacts_contact.is_favorite, &is_favorite);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("isFavorite", JsonValue{is_favorite}));
 
   int last_update = 0;
   status = ContactUtil::GetIntFromRecord(
       contacts_record, _contacts_contact.changed_time, &last_update);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("lastUpdated",
                             JsonValue{static_cast<double>(last_update)}));
@@ -1844,7 +2254,10 @@ PlatformResult ImportContactFromContactsRecord(
   bool is_contact_name;
   status = ImportContactNameFromContactsRecord(contacts_record, &name,
                                                &is_contact_name);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (is_contact_name) {
     out.insert(std::make_pair(std::string("name"), picojson::value(name)));
@@ -1883,7 +2296,10 @@ PlatformResult ImportContactFromContactsRecord(
     int child_rec_count;
     status = ContactUtil::GetNumberOfChildRecord(
         contacts_record, data.property_id, &child_rec_count);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     for (unsigned int i = 0; i < child_rec_count; ++i) {
       JsonValue val{JsonObject{}};
@@ -1900,7 +2316,10 @@ PlatformResult ImportContactFromContactsRecord(
   int child_rec_count;
   status = ContactUtil::GetNumberOfChildRecord(
       contacts_record, _contacts_contact.event, &child_rec_count);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   bool is_contact_anniv;
   for (unsigned int i = 0; i < child_rec_count; ++i) {
@@ -1908,7 +2327,10 @@ PlatformResult ImportContactFromContactsRecord(
 
     PlatformResult status = ImportContactAnniversariesFromContactsRecord(
         contacts_record, i, &anniversary.get<JsonObject>(), &is_contact_anniv);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     if (is_contact_anniv) {
       anniversaries.push_back(anniversary);
@@ -1924,13 +2346,19 @@ PlatformResult ImportContactFromContactsRecord(
 
   status = ContactUtil::GetNumberOfChildRecord(
       contacts_record, _contacts_contact.note, &child_rec_count);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   for (unsigned int i = 0; i < child_rec_count; ++i) {
     JsonValue val{JsonObject{}};
 
     status = ImportContactNotesFromContactsRecord(contacts_record, i, &val);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     notes.push_back(val);
   }
@@ -1941,19 +2369,28 @@ PlatformResult ImportContactFromContactsRecord(
     char* value = nullptr;
     status = ContactUtil::GetStrFromRecord(
         contacts_record, _contacts_contact.image_thumbnail_path, &value);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     std::make_pair("photoURI", value ? JsonValue{value} : JsonValue{});
 
     status = ContactUtil::GetStrFromRecord(
         contacts_record, _contacts_contact.ringtone_path, &value);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     std::make_pair("ringtoneURI", value ? JsonValue{value} : JsonValue{});
     value = nullptr;
     status = ContactUtil::GetStrFromRecord(
         contacts_record, _contacts_contact.message_alert, &value);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     out.insert(std::make_pair(
         "messageAlertURI",
@@ -1961,7 +2398,10 @@ PlatformResult ImportContactFromContactsRecord(
     value = nullptr;
     status = ContactUtil::GetStrFromRecord(contacts_record,
                                            _contacts_contact.vibration, &value);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     out.insert(std::make_pair(
         "vibrationURI",
@@ -1984,7 +2424,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
   if (!IsNull(in, "name")) {
     PlatformResult status = ExportContactNameToContactsRecord(
         contacts_record, FromJson<JsonObject>(in, "name"));
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   typedef PlatformResult (*ExportFunc)(contacts_record_h, const JsonObject&);
@@ -2014,7 +2457,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
   for (auto& data : exports) {
     PlatformResult status =
         ContactUtil::ClearAllContactRecord(contacts_record, data.property_id);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     const JsonArray& elements = FromJson<JsonArray>(in, data.name);
     for (auto& element : elements) {
@@ -2026,7 +2472,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
     //### m_notes: ###
     PlatformResult status = ContactUtil::ClearAllContactRecord(
         contacts_record, _contacts_contact.note);
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     const JsonArray& elements = FromJson<JsonArray>(in, "notes");
     for (auto& element : elements) {
@@ -2044,13 +2493,19 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
     int err = contacts_record_create(_contacts_image._uri, &child_record);
     PlatformResult status = ContactUtil::ErrorChecker(
         err, "Fail to create image uri record in database.");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     ContactsRecordHPtr record(&child_record, ContactsDeleter);
     err = contacts_record_add_child_record(
         contacts_record, _contacts_contact.image, child_record);
     status = ContactUtil::ErrorChecker(err, "Fail to add child to image uri.");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
 
     // Do not delete record, it is passed to the platform
     record.release();
@@ -2063,7 +2518,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
       err = contacts_record_create(_contacts_image._uri, &child_record);
       PlatformResult status = ContactUtil::ErrorChecker(
           err, "Fail to create image uri record in database.");
-      if (status.IsError()) return status;
+      if (status.IsError()) {
+        LoggerE("Error: %s", status.message().c_str());
+        return status;
+      }
 
       is_first = true;
     }
@@ -2079,7 +2537,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
           ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "photoURI"));
       PlatformResult status = ContactUtil::SetStrInRecord(
           child_record, _contacts_image.path, real_path.c_str());
-      if (status.IsError()) return status;
+      if (status.IsError()) {
+        LoggerE("Error: %s", status.message().c_str());
+        return status;
+      }
     }
 
     if (is_first) {
@@ -2087,7 +2548,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
           contacts_record, _contacts_contact.image, child_record);
       PlatformResult status =
           ContactUtil::ErrorChecker(err, "Fail to add child to image uri.");
-      if (status.IsError()) return status;
+      if (status.IsError()) {
+        LoggerE("Error: %s", status.message().c_str());
+        return status;
+      }
     }
     // Do not delete record, it is passed to the platform
     record.release();
@@ -2100,7 +2564,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
         ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "ringtoneURI"));
     PlatformResult status = ContactUtil::SetStrInRecord(
         contacts_record, _contacts_contact.ringtone_path, real_path.c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   // Contact.messageAlertURI
   if (!IsNull(in, "messageAlertURI")) {
@@ -2108,7 +2575,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
         FromJson<JsonString>(in, "messageAlertURI"));
     PlatformResult status = ContactUtil::SetStrInRecord(
         contacts_record, _contacts_contact.message_alert, real_path.c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   // Contact.vibrationURI
@@ -2117,7 +2587,10 @@ PlatformResult ExportContactToContactsRecord(contacts_record_h contacts_record,
         ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "vibrationURI"));
     PlatformResult status = ContactUtil::SetStrInRecord(
         contacts_record, _contacts_contact.vibration, real_path.c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   return PlatformResult(ErrorCode::NO_ERROR);
@@ -2137,14 +2610,20 @@ PlatformResult ImportContactGroupFromContactsRecord(
   int int_val = 0;
   PlatformResult status = ContactUtil::GetIntFromRecord(
       contacts_record, _contacts_group.id, &int_val);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("id", JsonValue{std::to_string(int_val)}));
 
   // addressBookId
   status = ContactUtil::GetIntFromRecord(
       contacts_record, _contacts_group.address_book_id, &int_val);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("addressBookId", JsonValue{std::to_string(int_val)}));
@@ -2153,7 +2632,10 @@ PlatformResult ImportContactGroupFromContactsRecord(
   char* value = nullptr;
   status = ContactUtil::GetStrFromRecord(contacts_record, _contacts_group.name,
                                          &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("name", value ? JsonValue{value} : JsonValue{}));
 
@@ -2161,7 +2643,10 @@ PlatformResult ImportContactGroupFromContactsRecord(
   value = nullptr;
   status = ContactUtil::GetStrFromRecord(contacts_record,
                                          _contacts_group.image_path, &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("photoURI", value ? JsonValue{value} : JsonValue{}));
@@ -2170,7 +2655,10 @@ PlatformResult ImportContactGroupFromContactsRecord(
   value = nullptr;
   status = ContactUtil::GetStrFromRecord(contacts_record,
                                          _contacts_group.ringtone_path, &value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("ringtoneURI", value ? JsonValue{value} : JsonValue{}));
@@ -2179,7 +2667,10 @@ PlatformResult ImportContactGroupFromContactsRecord(
   bool bool_value = false;
   status = ContactUtil::GetBoolFromRecord(
       contacts_record, _contacts_group.is_read_only, &bool_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("readOnly", JsonValue{bool_value}));
 
@@ -2192,7 +2683,10 @@ PlatformResult ExportContactGroupToContactsRecord(
   PlatformResult status =
       ContactUtil::SetStrInRecord(contacts_record, _contacts_group.name,
                                   FromJson<JsonString>(in, "name").c_str());
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   std::string real_path;
   // photoURI
@@ -2200,7 +2694,10 @@ PlatformResult ExportContactGroupToContactsRecord(
     real_path = ConvertUriToPath(FromJson<JsonString>(in, "photoURI"));
     PlatformResult status = ContactUtil::SetStrInRecord(
         contacts_record, _contacts_group.image_path, real_path.c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   // ringtoneURI
   if (!IsNull(in, "ringtoneURI")) {
@@ -2209,7 +2706,10 @@ PlatformResult ExportContactGroupToContactsRecord(
     // NOTE in the original code real path was not read
     PlatformResult status = ContactUtil::SetStrInRecord(
         contacts_record, _contacts_group.ringtone_path, real_path.c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   return PlatformResult(ErrorCode::NO_ERROR);
@@ -2233,7 +2733,10 @@ PlatformResult ImportPersonFromContactsRecord(contacts_record_h record,
   // id
   PlatformResult status =
       ContactUtil::GetIntFromRecord(record, _contacts_person.id, &int_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(
       std::make_pair("id", JsonValue(std::to_string(int_value))));
@@ -2242,7 +2745,10 @@ PlatformResult ImportPersonFromContactsRecord(contacts_record_h record,
   // displayName
   status = ContactUtil::GetStrFromRecord(record, _contacts_person.display_name,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(std::make_pair(
       "displayName", char_value ? JsonValue(char_value) : JsonValue{}));
@@ -2250,7 +2756,10 @@ PlatformResult ImportPersonFromContactsRecord(contacts_record_h record,
   // contactCount
   status = ContactUtil::GetIntFromRecord(record, _contacts_person.link_count,
                                          &int_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(std::make_pair(
       "contactCount", JsonValue(static_cast<double>(int_value))));
@@ -2259,28 +2768,40 @@ PlatformResult ImportPersonFromContactsRecord(contacts_record_h record,
   // hasPhoneNumber
   status = ContactUtil::GetBoolFromRecord(
       record, _contacts_person.has_phonenumber, &bool_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(std::make_pair("hasPhoneNumber", JsonValue(bool_value)));
 
   // hasEmail
   status = ContactUtil::GetBoolFromRecord(record, _contacts_person.has_email,
                                           &bool_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(std::make_pair("hasEmail", JsonValue(bool_value)));
 
   // isFavorite
   status = ContactUtil::GetBoolFromRecord(record, _contacts_person.is_favorite,
                                           &bool_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(std::make_pair("isFavorite", JsonValue(bool_value)));
 
   // photoURI
   status = ContactUtil::GetStrFromRecord(
       record, _contacts_person.image_thumbnail_path, &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(std::make_pair(
       "photoURI", char_value ? JsonValue(char_value) : JsonValue{}));
@@ -2288,7 +2809,10 @@ PlatformResult ImportPersonFromContactsRecord(contacts_record_h record,
   // ringtoneURI
   status = ContactUtil::GetStrFromRecord(record, _contacts_person.ringtone_path,
                                          &char_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(std::make_pair(
       "ringtoneURI", char_value ? JsonValue(char_value) : JsonValue{}));
@@ -2296,7 +2820,10 @@ PlatformResult ImportPersonFromContactsRecord(contacts_record_h record,
   // displayContactId
   status = ContactUtil::GetIntFromRecord(
       record, _contacts_person.display_contact_id, &int_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   arguments_obj.insert(
       std::make_pair("displayContactId",
@@ -2319,7 +2846,10 @@ PlatformResult ExportPersonToContactsRecord(contacts_record_h record,
 
   PlatformResult status = ContactUtil::SetBoolInRecord(
       record, _contacts_person.is_favorite, FromJson<bool>(args, "isFavorite"));
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   if (!IsNull(args, "photoURI") &&
       !FromJson<JsonString>(args, "photoURI").empty()) {
@@ -2338,17 +2868,26 @@ PlatformResult ExportPersonToContactsRecord(contacts_record_h record,
     PlatformResult status = ContactUtil::SetStrInRecord(
         record, _contacts_person.ringtone_path,
         FromJson<JsonString>(args, "ringtoneURI").c_str());
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   } else {
     PlatformResult status =
         ContactUtil::SetStrInRecord(record, _contacts_person.ringtone_path, "");
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
   if (!IsNull(args, "displayContactId")) {
     PlatformResult status = ContactUtil::SetIntInRecord(
         record, _contacts_person.display_contact_id,
         common::stol(FromJson<JsonString>(args, "displayContactId")));
-    if (status.IsError()) return status;
+    if (status.IsError()) {
+      LoggerE("Error: %s", status.message().c_str());
+      return status;
+    }
   }
 
   return PlatformResult(ErrorCode::NO_ERROR);
@@ -2360,25 +2899,37 @@ PlatformResult UpdateAdditionalInformation(
   int int_value = -1;
   PlatformResult status = ContactUtil::GetIntFromRecord(
       *contacts_record_ptr, _contacts_contact.person_id, &int_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("personId", JsonValue{std::to_string(int_value)}));
   status = ContactUtil::GetIntFromRecord(
       *contacts_record_ptr, _contacts_contact.address_book_id, &int_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("addressBookId", JsonValue{std::to_string(int_value)}));
   status = ContactUtil::GetIntFromRecord(
       *contacts_record_ptr, _contacts_contact.changed_time, &int_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(
       std::make_pair("lastUpdated", JsonValue{static_cast<double>(int_value)}));
   bool bool_value = false;
   status = ContactUtil::GetBoolFromRecord(
       *contacts_record_ptr, _contacts_contact.is_favorite, &bool_value);
-  if (status.IsError()) return status;
+  if (status.IsError()) {
+    LoggerE("Error: %s", status.message().c_str());
+    return status;
+  }
 
   out.insert(std::make_pair("isFavorite", JsonValue{bool_value}));
 
index 819d9f3..1490c2c 100755 (executable)
@@ -39,6 +39,7 @@ static const PersonPropertyMap personPropertyMap = {
 };
 
 PlatformResult PersonLink(const JsonObject& args, JsonObject&) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -66,6 +67,7 @@ PlatformResult PersonLink(const JsonObject& args, JsonObject&) {
 }
 
 PlatformResult PersonUnlink(const JsonObject& args, JsonObject& out) {
+  LoggerD("Enter");
   PlatformResult status = ContactUtil::CheckDBConnection();
   if (status.IsError()) return status;
 
@@ -128,6 +130,7 @@ PlatformResult PersonUnlink(const JsonObject& args, JsonObject& out) {
 
 PlatformResult PersonPropertyFromString(const std::string& name,
                                         PersonProperty* person_prop) {
+  LoggerD("Enter");
   auto iter = personPropertyMap.find(name);
   if (iter == personPropertyMap.end()) {
     LoggerE("Invalid property name (not in map): %s", name.c_str());