From d409b52950e03c4a61f4bb185eeca2b5ab1019c7 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 27 May 2015 14:52:03 +0200 Subject: [PATCH] [Notification] Added logs in methods onEntered and onReturn Change-Id: I5e2f120dc0c16fb40241df5814c93679a7243474 Signed-off-by: Piotr Kosko --- src/notification/notification_instance.cc | 60 +++++++++++++++++------ src/notification/notification_manager.cc | 25 ++++++++-- src/notification/status_notification.cc | 42 +++++++++++++++- 3 files changed, 105 insertions(+), 22 deletions(-) diff --git a/src/notification/notification_instance.cc b/src/notification/notification_instance.cc index 12aef9be..5c571ba2 100644 --- a/src/notification/notification_instance.cc +++ b/src/notification/notification_instance.cc @@ -30,6 +30,7 @@ namespace notification { using namespace common; NotificationInstance::NotificationInstance() { + LoggerD("Enter"); using std::placeholders::_1; using std::placeholders::_2; #define REGISTER_SYNC(c, x) \ @@ -50,6 +51,7 @@ NotificationInstance::NotificationInstance() { } NotificationInstance::~NotificationInstance() { + LoggerD("Enter"); } #define CHECK_EXIST(args, name, out) \ @@ -61,98 +63,124 @@ NotificationInstance::~NotificationInstance() { void NotificationInstance::NotificationManagerPost(const picojson::value& args, picojson::object& out) { + LoggerD("Enter"); picojson::value val{picojson::object{}}; PlatformResult status = manager_->Post(args.get(), val.get()); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(val, out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } void NotificationInstance::NotificationManagerUpdate( const picojson::value& args, picojson::object& out) { + LoggerD("Enter"); PlatformResult status = manager_->Update(args.get()); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } void NotificationInstance::NotificationManagerRemove( const picojson::value& args, picojson::object& out) { + LoggerD("Enter"); PlatformResult status = manager_->Remove(args.get()); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } void NotificationInstance::NotificationManagerRemoveAll( const picojson::value& args, picojson::object& out) { + LoggerD("Enter"); PlatformResult status = manager_->RemoveAll(); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } void NotificationInstance::NotificationManagerGet(const picojson::value& args, picojson::object& out) { + LoggerD("Enter"); picojson::value val{picojson::object{}}; PlatformResult status = manager_->Get(args.get(), val.get()); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(val, out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } void NotificationInstance::NotificationManagerGetAll( const picojson::value& args, picojson::object& out) { + LoggerD("Enter"); picojson::value val{picojson::array{}}; PlatformResult status = manager_->GetAll(val.get()); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(val, out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } void NotificationInstance::NotificationManagerPlayLEDCustomEffect( const picojson::value& args, picojson::object& out) { + LoggerD("Enter"); + PlatformResult status = manager_->PlayLEDCustomEffect(args.get()); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } void NotificationInstance::NotificationManagerStopLEDCustomEffect( const picojson::value& /*args*/, picojson::object& out) { + LoggerD("Enter"); + PlatformResult status = manager_->StopLEDCustomEffect(); - if (status.IsSuccess()) + if (status.IsSuccess()) { ReportSuccess(out); - else + } else { + LoggerE("Failed"); ReportError(status, &out); + } } #undef CHECK_EXIST diff --git a/src/notification/notification_manager.cc b/src/notification/notification_manager.cc index 8712a4de..ca6f4cd9 100644 --- a/src/notification/notification_manager.cc +++ b/src/notification/notification_manager.cc @@ -32,26 +32,32 @@ namespace notification { using namespace common; NotificationManager::NotificationManager() { + LoggerD("Enter"); } NotificationManager::~NotificationManager() { + LoggerD("Enter"); } NotificationManager* NotificationManager::GetInstance() { + LoggerD("Enter"); static NotificationManager instance; return &instance; } PlatformResult NotificationManager::Post(const picojson::object& args, picojson::object& out) { + LoggerD("Enter"); return StatusNotification::FromJson(args, false, &out); } PlatformResult NotificationManager::Update(const picojson::object& args) { + LoggerD("Enter"); return StatusNotification::FromJson(args, true, NULL); } PlatformResult NotificationManager::Remove(const picojson::object& args) { + LoggerD("Enter"); int id = std::stoi(FromJson(args, "id")); int ret = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NONE, id); @@ -65,6 +71,7 @@ PlatformResult NotificationManager::Remove(const picojson::object& args) { } PlatformResult NotificationManager::RemoveAll() { + LoggerD("Enter"); int ret = notification_delete_all(NOTIFICATION_TYPE_NOTI); if (ret != NOTIFICATION_ERROR_NONE) { LoggerE("Notification remove all failed: %d", ret); @@ -84,26 +91,34 @@ PlatformResult NotificationManager::RemoveAll() { PlatformResult NotificationManager::Get(const picojson::object& args, picojson::object& out) { + LoggerD("Enter"); int id = std::stoi(FromJson(args, "id")); notification_h noti_handle; PlatformResult status = StatusNotification::GetNotiHandle(id, ¬i_handle); if (status.IsError()) + { + LoggerE("Failed: GetNotiHandle"); return status; - + } app_control_h app_control; status = StatusNotification::GetAppControl(noti_handle, &app_control); if (status.IsError()) + { + LoggerE("Failed: GetAppControl"); return status; - + } status = StatusNotification::ToJson(id, noti_handle, app_control, &out); if (status.IsError()) + { + LoggerE("Failed: ToJson"); return status; - + } return PlatformResult(ErrorCode::NO_ERROR); } PlatformResult NotificationManager::GetAll(picojson::array& out) { + LoggerD("Enter"); notification_h noti = nullptr; notification_list_h noti_list = nullptr; notification_list_h noti_list_iter = nullptr; @@ -155,7 +170,7 @@ PlatformResult NotificationManager::GetAll(picojson::array& out) { PlatformResult NotificationManager::PlayLEDCustomEffect( const picojson::object& args) { - LOGGER(DEBUG) << "entered"; + LoggerD("Enter"); int timeOn = FromJson(args, "timeOn"); int timeOff = FromJson(args, "timeOff"); @@ -182,7 +197,7 @@ PlatformResult NotificationManager::PlayLEDCustomEffect( } PlatformResult NotificationManager::StopLEDCustomEffect() { - LOGGER(DEBUG) << "entered"; + LoggerD("Enter"); int ret = DEVICE_ERROR_NONE; ret = device_led_stop_custom(); diff --git a/src/notification/status_notification.cc b/src/notification/status_notification.cc index 13461cff..eaaaedcc 100644 --- a/src/notification/status_notification.cc +++ b/src/notification/status_notification.cc @@ -55,6 +55,7 @@ StatusNotification::~StatusNotification() { } bool StatusNotification::IsColorFormatNumberic(const std::string& color) { + LoggerD("Enter"); std::string hexCode = "0123456789abcdef"; if (color.length() != 7 || !color.compare(0, 1, "#")) { return false; @@ -71,6 +72,8 @@ bool StatusNotification::IsColorFormatNumberic(const std::string& color) { PlatformResult StatusNotification::SetLayout(notification_h noti_handle, const std::string& noti_type) { + + LoggerD("Enter"); notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE; if (noti_type == "SIMPLE") { @@ -78,8 +81,10 @@ PlatformResult StatusNotification::SetLayout(notification_h noti_handle, PlatformResult status = GetNumber(noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &number); if (status.IsError()) + { + LoggerE("Failed: GetNumber"); return status; - + } if (number > 0) noti_layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; else @@ -105,6 +110,7 @@ PlatformResult StatusNotification::SetLayout(notification_h noti_handle, static bool ServiceExtraDataCb(app_control_h service, const char* key, void* user_data) { + LoggerD("Enter"); if (user_data != NULL && key != NULL) { LoggerE("User data or key not exist"); return true; @@ -143,6 +149,7 @@ static bool ServiceExtraDataCb(app_control_h service, PlatformResult StatusNotification::Create(notification_type_e noti_type, notification_h* noti_handle) { + LoggerD("Enter"); *noti_handle = notification_create(noti_type); if (!noti_handle) { LoggerE("Cannot make new notification object"); @@ -169,6 +176,7 @@ PlatformResult StatusNotification::StatusTypeFromPlatform( notification_type_e noti_type, notification_ly_type_e noti_layout, std::string* type) { + LoggerD("Enter"); if (noti_type == NOTIFICATION_TYPE_NOTI) { if (noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE || noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE) { @@ -194,6 +202,7 @@ PlatformResult StatusNotification::StatusTypeFromPlatform( PlatformResult StatusNotification::StatusTypeToPlatform( const std::string& type, notification_type_e* noti_type) { + LoggerD("Enter"); if (type == "SIMPLE" || type == "THUMBNAIL") { *noti_type = NOTIFICATION_TYPE_NOTI; } else if (type == "ONGOING" || type == "PROGRESS") { @@ -211,6 +220,7 @@ PlatformResult StatusNotification::GetImage( notification_h noti_handle, notification_image_type_e image_type, std::string* image_path) { + LoggerD("Enter"); char* path = NULL; *image_path = ""; @@ -233,6 +243,7 @@ PlatformResult StatusNotification::SetImage( notification_h noti_handle, notification_image_type_e image_type, const std::string& image_path) { + LoggerD("Enter"); int ret = notification_set_image(noti_handle, image_type, image_path.c_str()); if (ret != NOTIFICATION_ERROR_NONE) { LoggerE("Set notification image error, image_type: %d, error: %d", @@ -248,6 +259,7 @@ PlatformResult StatusNotification::SetImage( PlatformResult StatusNotification::GetText(notification_h noti_handle, notification_text_type_e text_type, std::string* noti_text) { + LoggerD("Enter"); char* text = NULL; *noti_text = ""; @@ -268,6 +280,7 @@ PlatformResult StatusNotification::GetText(notification_h noti_handle, PlatformResult StatusNotification::SetText(notification_h noti_handle, notification_text_type_e text_type, const std::string& noti_text) { + LoggerD("Enter"); int ret = notification_set_text(noti_handle, text_type, noti_text.c_str(), @@ -287,6 +300,7 @@ PlatformResult StatusNotification::SetText(notification_h noti_handle, PlatformResult StatusNotification::GetNumber(notification_h noti_handle, notification_text_type_e text_type, long* number) { + LoggerD("Enter"); std::string text; PlatformResult status = GetText(noti_handle, text_type, &text); if (status.IsError()) @@ -302,6 +316,7 @@ PlatformResult StatusNotification::GetNumber(notification_h noti_handle, PlatformResult StatusNotification::GetDetailInfos(notification_h noti_handle, picojson::array* out) { + LoggerD("Enter"); if (info_map_.size() != info_sub_map_.size()) { LoggerE("Different notification information types element size"); return PlatformResult( @@ -340,6 +355,7 @@ PlatformResult StatusNotification::GetDetailInfos(notification_h noti_handle, PlatformResult StatusNotification::SetDetailInfos( notification_h noti_handle, const picojson::array& value) { + LoggerD("Enter"); int idx = 0; for (auto& item : value) { @@ -375,6 +391,7 @@ PlatformResult StatusNotification::SetDetailInfos( PlatformResult StatusNotification::GetLedColor(notification_h noti_handle, std::string* led_color) { + LoggerD("Enter"); unsigned int color = 0; notification_led_op_e type = NOTIFICATION_LED_OP_ON; @@ -408,6 +425,7 @@ PlatformResult StatusNotification::GetLedColor(notification_h noti_handle, PlatformResult StatusNotification::SetLedColor(notification_h noti_handle, const std::string& led_color) { + LoggerD("Enter"); std::string color_str = led_color; std::transform( color_str.begin(), color_str.end(), color_str.begin(), ::tolower); @@ -445,6 +463,7 @@ PlatformResult StatusNotification::SetLedColor(notification_h noti_handle, PlatformResult StatusNotification::GetLedPeriod(notification_h noti_handle, unsigned long* on_period, unsigned long* off_period) { + LoggerD("Enter"); int on_time = 0; int off_time = 0; @@ -465,6 +484,7 @@ PlatformResult StatusNotification::GetLedPeriod(notification_h noti_handle, PlatformResult StatusNotification::SetLedOnPeriod(notification_h noti_handle, unsigned long on_period) { + LoggerD("Enter"); unsigned long off_period = 0; PlatformResult status = GetLedPeriod(noti_handle, nullptr, &off_period); if (status.IsError()) @@ -483,6 +503,7 @@ PlatformResult StatusNotification::SetLedOnPeriod(notification_h noti_handle, PlatformResult StatusNotification::SetLedOffPeriod(notification_h noti_handle, unsigned long off_period) { + LoggerD("Enter"); unsigned long on_period = 0; PlatformResult status = GetLedPeriod(noti_handle, &on_period, nullptr); if (status.IsError()) @@ -501,6 +522,7 @@ PlatformResult StatusNotification::SetLedOffPeriod(notification_h noti_handle, PlatformResult StatusNotification::GetThumbnails(notification_h noti_handle, picojson::array* out) { + LoggerD("Enter"); std::string text; for (int idx = 0; idx < thumbnails_map_.size(); ++idx) { PlatformResult status = @@ -519,6 +541,7 @@ PlatformResult StatusNotification::GetThumbnails(notification_h noti_handle, PlatformResult StatusNotification::SetThumbnails(notification_h noti_handle, const picojson::array& value) { + LoggerD("Enter"); int idx = 0; for (auto& item : value) { @@ -543,6 +566,7 @@ PlatformResult StatusNotification::SetThumbnails(notification_h noti_handle, PlatformResult StatusNotification::GetSoundPath(notification_h noti_handle, std::string* sound_path) { + LoggerD("Enter"); *sound_path = ""; const char* path = NULL; @@ -568,6 +592,7 @@ PlatformResult StatusNotification::GetSoundPath(notification_h noti_handle, PlatformResult StatusNotification::SetSoundPath(notification_h noti_handle, const std::string& sound_path) { + LoggerD("Enter"); int ret = notification_set_sound( noti_handle, NOTIFICATION_SOUND_TYPE_USER_DATA, sound_path.c_str()); if (ret != NOTIFICATION_ERROR_NONE) { @@ -583,6 +608,7 @@ PlatformResult StatusNotification::SetSoundPath(notification_h noti_handle, PlatformResult StatusNotification::GetVibration(notification_h noti_handle, bool* vibration) { + LoggerD("Enter"); notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE; if (notification_get_vibration(noti_handle, &vib_type, NULL) != @@ -604,6 +630,7 @@ PlatformResult StatusNotification::GetVibration(notification_h noti_handle, PlatformResult StatusNotification::SetVibration(notification_h noti_handle, bool vibration) { + LoggerD("Enter"); bool platform_vibration; PlatformResult status = GetVibration(noti_handle, &platform_vibration); if (status.IsError()) @@ -630,6 +657,7 @@ PlatformResult StatusNotification::SetVibration(notification_h noti_handle, PlatformResult StatusNotification::GetApplicationControl( app_control_h app_handle, picojson::object* out_ptr) { + LoggerD("Enter"); picojson::object& out = *out_ptr; char* operation = NULL; @@ -701,6 +729,7 @@ PlatformResult StatusNotification::GetApplicationControl( PlatformResult StatusNotification::SetApplicationControl( app_control_h app_handle, const picojson::object& app_ctrl) { + LoggerD("Enter"); picojson::value val(app_ctrl); const std::string& operation = common::FromJson(app_ctrl, "operation"); @@ -783,6 +812,7 @@ PlatformResult StatusNotification::SetApplicationControl( PlatformResult StatusNotification::GetApplicationId(app_control_h app_handle, std::string* app_id) { + LoggerD("Enter"); char* app_id_str = NULL; SCOPE_EXIT { free(app_id_str); }; @@ -805,6 +835,7 @@ PlatformResult StatusNotification::GetApplicationId(app_control_h app_handle, PlatformResult StatusNotification::SetApplicationId(app_control_h app_handle, const std::string& app_id) { + LoggerD("Enter"); int ret = app_control_set_app_id(app_handle, app_id.c_str()); if (ret != APP_CONTROL_ERROR_NONE) { LoggerE("Set applicaiton ID error: %d", ret); @@ -820,6 +851,7 @@ PlatformResult StatusNotification::GetProgressValue( notification_h noti_handle, const std::string& progess_type, double* progress_value) { + LoggerD("Enter"); *progress_value = 0.0; if (progess_type == kProgressTypeByte) { @@ -852,6 +884,7 @@ PlatformResult StatusNotification::SetProgressValue( const std::string& progress_type, double progress_value, bool is_update) { + LoggerD("Enter"); int ret; if (progress_type == kProgressTypeByte) { @@ -885,6 +918,7 @@ PlatformResult StatusNotification::SetProgressValue( PlatformResult StatusNotification::GetPostedTime(notification_h noti_handle, time_t* posted_time) { + LoggerD("Enter"); *posted_time = 0; if (notification_get_insert_time(noti_handle, posted_time) != @@ -899,6 +933,7 @@ PlatformResult StatusNotification::GetPostedTime(notification_h noti_handle, PlatformResult StatusNotification::GetNotiHandle(int id, notification_h* noti_handle) { + LoggerD("Enter"); *noti_handle = notification_load(NULL, id); if (NULL == *noti_handle) { LoggerE("Not found or removed notification id"); @@ -911,6 +946,7 @@ PlatformResult StatusNotification::GetNotiHandle(int id, PlatformResult StatusNotification::GetAppControl(notification_h noti_handle, app_control_h* app_control) { + LoggerD("Enter"); int ret = notification_get_launch_option(noti_handle, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, @@ -926,6 +962,7 @@ PlatformResult StatusNotification::GetAppControl(notification_h noti_handle, PlatformResult StatusNotification::CreateAppControl( app_control_h* app_control) { + LoggerD("Enter"); int ret = app_control_create(app_control); if (ret != APP_CONTROL_ERROR_NONE) { LoggerE("Application create error: %d", ret); @@ -938,6 +975,7 @@ PlatformResult StatusNotification::CreateAppControl( PlatformResult StatusNotification::SetAppControl(notification_h noti_handle, app_control_h app_control) { + LoggerD("Enter"); int ret = notification_set_launch_option(noti_handle, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, @@ -955,6 +993,7 @@ PlatformResult StatusNotification::ToJson(int id, notification_h noti_handle, app_control_h app_handle, picojson::object* out_ptr) { + LoggerD("Enter"); picojson::object& out = *out_ptr; out["id"] = picojson::value(std::to_string(id)); @@ -1112,6 +1151,7 @@ PlatformResult StatusNotification::ToJson(int id, PlatformResult StatusNotification::FromJson(const picojson::object& args, bool is_update, picojson::object* out_ptr) { + LoggerD("Enter"); picojson::object noti_obj = common::FromJson(args, "notification"); -- 2.34.1