From a0b588b59724b2a1111b155ee31f0502a2fe5f7b 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 68c81d79..13ef0ba6 100644 --- a/src/notification/notification_instance.cc +++ b/src/notification/notification_instance.cc @@ -18,6 +18,7 @@ namespace notification { using namespace common; NotificationInstance::NotificationInstance() { + LoggerD("Enter"); using std::placeholders::_1; using std::placeholders::_2; #define REGISTER_SYNC(c, x) \ @@ -38,6 +39,7 @@ NotificationInstance::NotificationInstance() { } NotificationInstance::~NotificationInstance() { + LoggerD("Enter"); } #define CHECK_EXIST(args, name, out) \ @@ -49,98 +51,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 ffd1c3b0..c58cd1e5 100644 --- a/src/notification/notification_manager.cc +++ b/src/notification/notification_manager.cc @@ -20,26 +20,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); @@ -53,6 +59,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); @@ -72,26 +79,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; @@ -143,7 +158,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"); @@ -170,7 +185,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 49f4d51a..12e49c67 100644 --- a/src/notification/status_notification.cc +++ b/src/notification/status_notification.cc @@ -43,6 +43,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; @@ -59,6 +60,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") { @@ -66,8 +69,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 @@ -93,6 +98,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; @@ -131,6 +137,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"); @@ -157,6 +164,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) { @@ -182,6 +190,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") { @@ -199,6 +208,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 = ""; @@ -221,6 +231,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", @@ -236,6 +247,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 = ""; @@ -256,6 +268,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(), @@ -275,6 +288,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()) @@ -290,6 +304,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( @@ -328,6 +343,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) { @@ -363,6 +379,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; @@ -396,6 +413,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); @@ -433,6 +451,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; @@ -453,6 +472,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()) @@ -471,6 +491,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()) @@ -489,6 +510,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 = @@ -507,6 +529,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) { @@ -531,6 +554,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; @@ -556,6 +580,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) { @@ -571,6 +596,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) != @@ -592,6 +618,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()) @@ -618,6 +645,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; @@ -689,6 +717,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"); @@ -771,6 +800,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); }; @@ -793,6 +823,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); @@ -808,6 +839,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) { @@ -840,6 +872,7 @@ PlatformResult StatusNotification::SetProgressValue( const std::string& progress_type, double progress_value, bool is_update) { + LoggerD("Enter"); int ret; if (progress_type == kProgressTypeByte) { @@ -873,6 +906,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) != @@ -887,6 +921,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"); @@ -899,6 +934,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, @@ -914,6 +950,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); @@ -926,6 +963,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, @@ -943,6 +981,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)); @@ -1100,6 +1139,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