From 2f7789558c98d8b79b41d62ac97f5bd6de557dc9 Mon Sep 17 00:00:00 2001 From: wang_zhiqiang Date: Tue, 26 Mar 2019 10:35:18 +0800 Subject: [PATCH] Change log macro to AFB_XXX 1. using binder log macro instead of HMI_LOG. 2. unify log using level as below: AFB_ERROR: fatal error or serious error may occur. AFB_WARNING: input parameter error or not serious error. AFB_NOTICE: alert sth. AFB_INFO: print input argument or sth else. AFB_DEBUG: prompt for calling location. 3. delete hmi-debug.h. Change-Id: I203864ced39c418d2f792faa50ab2c009deb9d02 Signed-off-by: wang_zhiqiang --- src/hmi-debug.h | 77 ------------------------------------------------ src/homescreen.cpp | 41 +++++++++++++------------- src/hs-appinfo.cpp | 48 +++++++++++++++--------------- src/hs-client.cpp | 68 +++++++++++++++++++++--------------------- src/hs-clientmanager.cpp | 17 ++++++----- src/hs-proxy.cpp | 7 ++--- 6 files changed, 90 insertions(+), 168 deletions(-) delete mode 100644 src/hmi-debug.h diff --git a/src/hmi-debug.h b/src/hmi-debug.h deleted file mode 100644 index 3c71ff5..0000000 --- a/src/hmi-debug.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017 TOYOTA MOTOR CORPORATION - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __HMI_DEBUG_H__ -#define __HMI_DEBUG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include - -enum LOG_LEVEL{ - LOG_LEVEL_NONE = 0, - LOG_LEVEL_ERROR, - LOG_LEVEL_WARNING, - LOG_LEVEL_NOTICE, - LOG_LEVEL_INFO, - LOG_LEVEL_DEBUG, - LOG_LEVEL_MAX = LOG_LEVEL_DEBUG -}; - -#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) - -#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__) -#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) -#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) -#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) -#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) - -static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}; - -static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...) -{ - const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG")); - if(log_level < level) - { - return; - } - - char *message; - struct timespec tp; - unsigned int time; - - clock_gettime(CLOCK_REALTIME, &tp); - time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); - - va_list args; - va_start(args, log); - if (log == NULL || vasprintf(&message, log, args) < 0) - message = NULL; - fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message); - va_end(args); - free(message); -} - -#ifdef __cplusplus -} -#endif -#endif //__HMI_DEBUG_H__ \ No newline at end of file diff --git a/src/homescreen.cpp b/src/homescreen.cpp index 10cc9bc..892fcba 100644 --- a/src/homescreen.cpp +++ b/src/homescreen.cpp @@ -20,7 +20,6 @@ #include #include #include "hs-helper.h" -#include "hmi-debug.h" #include "hs-clientmanager.h" #include "hs-appinfo.h" @@ -54,13 +53,13 @@ struct hs_instance { int hs_instance::init(afb_api_t api) { if(client_manager == nullptr) { - HMI_ERROR("homescreen-service","FATAL ERROR: client_manager is nullptr."); + AFB_ERROR("FATAL ERROR: client_manager is nullptr."); return -1; } client_manager->init(); if(app_info == nullptr) { - HMI_ERROR("homescreen-service","FATAL ERROR: app_info is nullptr."); + AFB_ERROR("FATAL ERROR: app_info is nullptr."); return -1; } app_info->init(api); @@ -78,7 +77,7 @@ static void pingSample(afb_req_t request) { static int pingcount = 0; afb_req_success_f(request, json_object_new_int(pingcount), "Ping count = %d", pingcount); - HMI_NOTICE("homescreen-service","Verbosity macro at level notice invoked at ping invocation count = %d", pingcount); + AFB_DEBUG("Verbosity macro at level notice invoked at ping invocation count = %d", pingcount); pingcount++; } @@ -96,11 +95,11 @@ static void pingSample(afb_req_t request) */ static void tap_shortcut (afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = 0; const char* value = afb_req_value(request, _application_id); if (value) { - HMI_NOTICE("homescreen-service","request appid = %s.", value); + AFB_INFO("request appid = %s.", value); ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, value); if(ret == AFB_REQ_NOT_STARTED_APPLICATION) { std::string id = g_hs_instance->app_info->getAppProperty(value, _keyId); @@ -137,7 +136,7 @@ static void tap_shortcut (afb_req_t request) */ static void on_screen_message (afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__); if (ret) { afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__); @@ -163,7 +162,7 @@ static void on_screen_message (afb_req_t request) */ static void on_screen_reply (afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__); if (ret) { afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__); @@ -188,7 +187,7 @@ static void on_screen_reply (afb_req_t request) */ static void subscribe(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = 0; std::string req_appid = std::move(get_application_id(request)); if(!req_appid.empty()) { @@ -221,7 +220,7 @@ static void subscribe(afb_req_t request) */ static void unsubscribe(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = 0; std::string req_appid = std::move(get_application_id(request)); if(!req_appid.empty()) { @@ -254,7 +253,7 @@ static void unsubscribe(afb_req_t request) */ static void showWindow(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = 0; const char* value = afb_req_value(request, _application_id); if (value) { @@ -293,7 +292,7 @@ static void showWindow(afb_req_t request) */ static void hideWindow(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = 0; const char* value = afb_req_value(request, _application_id); if (value) { @@ -326,7 +325,7 @@ static void hideWindow(afb_req_t request) */ static void replyShowWindow(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = 0; const char* value = afb_req_value(request, _application_id); if (value) { @@ -361,7 +360,7 @@ static void replyShowWindow(afb_req_t request) */ static void showNotification(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, "homescreen"); if (ret) { afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__); @@ -388,7 +387,7 @@ static void showNotification(afb_req_t request) */ static void showInformation(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); int ret = g_hs_instance->client_manager->handleRequest(request, __FUNCTION__, "homescreen"); if (ret) { afb_req_fail_f(request, "failed", "called %s, Unknown parameter", __FUNCTION__); @@ -413,7 +412,7 @@ static void showInformation(afb_req_t request) */ static void getRunnables(afb_req_t request) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); struct json_object* j_runnable = json_object_new_array(); g_hs_instance->app_info->getRunnables(&j_runnable); @@ -456,7 +455,7 @@ static const afb_verb_t verbs[]= { */ static int preinit(afb_api_t api) { - HMI_NOTICE("homescreen-service","binding preinit (was register)"); + AFB_DEBUG("binding preinit (was register)"); return 0; } @@ -472,10 +471,10 @@ static int preinit(afb_api_t api) */ static int init(afb_api_t api) { - HMI_NOTICE("homescreen-service","binding init"); + AFB_DEBUG("binding init"); if(g_hs_instance != nullptr) { - HMI_WARNING("homescreen-service", "g_hs_instance isn't null."); + AFB_WARNING( "g_hs_instance isn't null."); delete g_hs_instance->client_manager; delete g_hs_instance->app_info; delete g_hs_instance; @@ -483,7 +482,7 @@ static int init(afb_api_t api) } g_hs_instance = new hs_instance(); if(g_hs_instance == nullptr) { - HMI_ERROR("homescreen-service", "Fatal Error: new g_hs_instance failed."); + AFB_ERROR( "Fatal Error: new g_hs_instance failed."); return -1; } @@ -504,7 +503,7 @@ static int init(afb_api_t api) */ static void onevent(afb_api_t api, const char *event, struct json_object *object) { - HMI_NOTICE("homescreen-service","on_event %s", event); + AFB_DEBUG("on_event %s", event); g_hs_instance->app_info->onEvent(api, event, object); } diff --git a/src/hs-appinfo.cpp b/src/hs-appinfo.cpp index e1c1990..1d1d48c 100644 --- a/src/hs-appinfo.cpp +++ b/src/hs-appinfo.cpp @@ -15,8 +15,8 @@ */ #include +#include #include "hs-appinfo.h" -#include "hmi-debug.h" #include "hs-clientmanager.h" #define RETRY_CNT 10 @@ -47,7 +47,7 @@ std::string AppDetail::getProperty(std::string key) const struct json_object *j_obj; struct json_object *j_detail = json_tokener_parse(this->detail.c_str()); if(json_object_object_get_ex(j_detail, key.c_str(), &j_obj) == 0) { - HMI_ERROR("homescreen-service","can't find key=%s.", key.c_str()); + AFB_WARNING("can't find key=%s.", key.c_str()); return std::string(); } return std::string(json_object_get_string(j_obj)); @@ -102,7 +102,7 @@ int HS_AppInfo::init(afb_api_t api) { afmmain = new HS_AfmMainProxy(); if(afmmain == nullptr) { - HMI_ERROR("homescreen-service","Fatal Error:new HS_AfmMainProxy failed"); + AFB_ERROR("Fatal Error:new HS_AfmMainProxy failed"); return -1; } @@ -117,11 +117,11 @@ int HS_AppInfo::init(afb_api_t api) ++retry; if(retry == RETRY_CNT) { - HMI_ERROR("homescreen-service","get runnables list failed"); + AFB_ERROR("get runnables list failed"); json_object_put(j_runnable); return -1; } - HMI_NOTICE("homescreen-service","retry to get runnables list %d", retry); + AFB_DEBUG("retry to get runnables list %d", retry); usleep(100000); // 100ms } while(1); @@ -144,7 +144,7 @@ void HS_AppInfo::onEvent(afb_api_t api, const char *event, struct json_object *o { auto ip = concerned_event_list.find(std::string(event)); if(ip != concerned_event_list.end()) { - HMI_NOTICE("homescreen-service","[%s] event received.", event); + AFB_INFO("[%s] event received.", event); (this->*(ip->second))(api, object); } } @@ -161,7 +161,7 @@ void HS_AppInfo::onEvent(afb_api_t api, const char *event, struct json_object *o */ void HS_AppInfo::createAppDetailList(struct json_object *object) { - HMI_NOTICE("homescreen-service","applist:%s", json_object_to_json_string(object)); + AFB_DEBUG("applist:%s", json_object_to_json_string(object)); if(json_object_get_type(object) == json_type_array) { int array_len = json_object_array_length(object); @@ -171,7 +171,7 @@ void HS_AppInfo::createAppDetailList(struct json_object *object) } } else { - HMI_ERROR("homescreen-service","Apps information input error."); + AFB_ERROR("Apps information input error."); } } @@ -187,23 +187,23 @@ void HS_AppInfo::createAppDetailList(struct json_object *object) */ void HS_AppInfo::updateAppDetailList(afb_api_t api, struct json_object *object) { - HMI_NOTICE("homescreen-service","update:%s", json_object_to_json_string(object)); + AFB_DEBUG("update:%s", json_object_to_json_string(object)); if(json_object_get_type(object) != json_type_object) { - HMI_ERROR("homescreen-service","input detail object error."); + AFB_ERROR("input detail object error."); return; } struct json_object *obj_oper, *obj_data; if(json_object_object_get_ex(object, _keyOperation, &obj_oper) == 0 || json_object_object_get_ex(object, _keyData, &obj_data) == 0) { - HMI_ERROR("homescreen-service","can't find key=%s, %s.", _keyOperation, _keyData); + AFB_ERROR("can't find key=%s, %s.", _keyOperation, _keyData); return; } std::string id = json_object_get_string(obj_data); std::string appid = id2appid(id); if(isPeripheryApp(appid.c_str())) { - HMI_NOTICE("homescreen-service", "install/uninstall application is periphery."); + AFB_INFO( "install/uninstall application is periphery."); return; } @@ -214,7 +214,7 @@ void HS_AppInfo::updateAppDetailList(afb_api_t api, struct json_object *object) if(!ret) { struct json_object *j_found = retrieveRunnables(j_runnable, id); if(j_found == nullptr) { - HMI_NOTICE("homescreen-service", "installed application isn't runnables."); + AFB_INFO( "installed application isn't runnables."); json_object_put(j_runnable); return; } @@ -222,21 +222,21 @@ void HS_AppInfo::updateAppDetailList(afb_api_t api, struct json_object *object) pushAppListChangedEvent(_keyInstall, j_found); } else { - HMI_ERROR("homescreen-service","get runnalbes failed."); + AFB_ERROR("get runnalbes failed."); } json_object_put(j_runnable); } else if(oper == _keyUninstall) { std::string appid_checked = checkAppId(appid); if(appid_checked.empty()) { - HMI_NOTICE("homescreen-service","uninstalled application isn't in runnables list, appid=%s.", appid.c_str()); + AFB_INFO("uninstalled application isn't in runnables list, appid=%s.", appid.c_str()); return; } pushAppListChangedEvent(_keyUninstall, obj_data); removeAppDetail(appid); } else { - HMI_ERROR("homescreen-service","operation error."); + AFB_ERROR("operation error."); } } @@ -256,7 +256,7 @@ std::string HS_AppInfo::parseAppDetail(struct json_object *object, AppDetail &in struct json_object *name, *id; if(json_object_object_get_ex(object, _keyName, &name) == 0 || json_object_object_get_ex(object, _keyId, &id) == 0) { - HMI_ERROR("homescreen-service","can't find key=%s, %s.", _keyName, _keyId); + AFB_ERROR("can't find key=%s, %s.", _keyName, _keyId); return std::string(); } std::string appid = id2appid(json_object_get_string(id)); @@ -285,7 +285,7 @@ void HS_AppInfo::addAppDetail(struct json_object *object) AppDetail info; std::string appid = parseAppDetail(object, info); if(appid.empty()) { - HMI_ERROR("homescreen-service","application id error"); + AFB_ERROR("application id error"); return; } @@ -315,7 +315,7 @@ void HS_AppInfo::removeAppDetail(std::string appid) app_detail_list.erase(it); } else { - HMI_WARNING("homescreen-service","erase application(%s) wasn't in applist.", appid.c_str()); + AFB_WARNING("erase application(%s) wasn't in applist.", appid.c_str()); } } @@ -332,7 +332,7 @@ void HS_AppInfo::removeAppDetail(std::string appid) */ void HS_AppInfo::pushAppListChangedEvent(const char *oper, struct json_object *object) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); struct json_object *push_obj = json_object_new_object(); json_object_object_add(push_obj, _keyOperation, json_object_new_string(oper)); json_object_object_add(push_obj, _keyData, object); @@ -360,7 +360,7 @@ struct json_object* HS_AppInfo::retrieveRunnables(struct json_object *obj_runnab struct json_object *obj = json_object_array_get_idx(obj_runnables, i); struct json_object *j_id; if(json_object_object_get_ex(obj, _keyId, &j_id) == 0) { - HMI_WARNING("homescreen-service","can't find id."); + AFB_WARNING("can't find id."); continue; } if(id == json_object_get_string(j_id)) { @@ -370,7 +370,7 @@ struct json_object* HS_AppInfo::retrieveRunnables(struct json_object *obj_runnab } } else { - HMI_ERROR("homescreen-service","Apps information input error."); + AFB_ERROR("Apps information input error."); } return j_found; } @@ -393,7 +393,7 @@ std::string HS_AppInfo::id2appid(const std::string &id) const appid = id.substr(0,pos); } else { - HMI_ERROR("homescreen-service","input id error."); + AFB_WARNING("input id error."); } return appid; } @@ -411,7 +411,7 @@ std::string HS_AppInfo::id2appid(const std::string &id) const void HS_AppInfo::getRunnables(struct json_object **object) { if(json_object_get_type(*object) != json_type_array) { - HMI_ERROR("homescreen-service","json type error."); + AFB_ERROR("json type error."); return; } diff --git a/src/hs-client.cpp b/src/hs-client.cpp index c927442..d6e771c 100644 --- a/src/hs-client.cpp +++ b/src/hs-client.cpp @@ -14,9 +14,9 @@ * limitations under the License. */ +#include #include "hs-client.h" #include "hs-helper.h" -#include "hmi-debug.h" static const char _event[] = "event"; static const char _type[] = "type"; @@ -54,7 +54,7 @@ const std::unordered_map HS_Client::func_l */ HS_Client::HS_Client(afb_req_t request, std::string id) : my_id(id) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); my_event = afb_api_make_event(request->api, id.c_str()); } @@ -70,7 +70,7 @@ HS_Client::HS_Client(afb_req_t request, std::string id) : my_id(id) */ HS_Client::~HS_Client() { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); afb_event_unref(my_event); } @@ -87,7 +87,7 @@ HS_Client::~HS_Client() */ int HS_Client::tap_shortcut(afb_req_t request) { - HMI_NOTICE("homescreen-service","request appid = %s.", my_id.c_str()); + AFB_INFO("request appid = %s.", my_id.c_str()); struct json_object* push_obj = json_object_new_object(); hs_add_object_to_json_object_str( push_obj, 4, _application_id, my_id.c_str(), _type, __FUNCTION__); @@ -111,14 +111,14 @@ int HS_Client::on_screen_message(afb_req_t request) int ret = 0; const char* value = afb_req_value(request, _display_message); if (value) { - HMI_NOTICE("homescreen-service","push %s event message [%s].", __FUNCTION__, value); + AFB_INFO("push %s event message [%s].", __FUNCTION__, value); struct json_object* push_obj = json_object_new_object(); hs_add_object_to_json_object_str( push_obj, 4, _display_message, value, _type, __FUNCTION__); afb_event_push(my_event, push_obj); } else { - HMI_NOTICE("homescreen-service","Please input display_message"); + AFB_WARNING("Please input display_message"); ret = AFB_EVENT_BAD_REQUEST; } return ret; @@ -140,14 +140,14 @@ int HS_Client::on_screen_reply(afb_req_t request) int ret = 0; const char* value = afb_req_value(request, _reply_message); if (value) { - HMI_NOTICE("homescreen-service","push %s event message [%s].", __FUNCTION__, value); + AFB_INFO("push %s event message [%s].", __FUNCTION__, value); struct json_object* push_obj = json_object_new_object(); hs_add_object_to_json_object_str( push_obj, 4, _reply_message, value, _type, __FUNCTION__); afb_event_push(my_event, push_obj); } else { - HMI_NOTICE("homescreen-service","Please input reply_message"); + AFB_WARNING("Please input reply_message"); ret = AFB_EVENT_BAD_REQUEST; } return ret; @@ -166,13 +166,13 @@ int HS_Client::on_screen_reply(afb_req_t request) */ int HS_Client::subscribe(afb_req_t request) { - HMI_NOTICE("homescreen-service"," called."); + AFB_DEBUG(" called."); int ret = 0; const char *value = afb_req_value(request, _event); if(value) { - HMI_NOTICE("homescreen-service","subscribe event %s", value); + AFB_INFO("subscribe event %s", value); if(!isSupportEvent(value)) { - HMI_NOTICE("homescreen-service","subscibe event isn't existing."); + AFB_WARNING("subscibe event isn't existing."); ret = AFB_EVENT_BAD_REQUEST; } else { @@ -186,7 +186,7 @@ int HS_Client::subscribe(afb_req_t request) } } else { - HMI_NOTICE("homescreen-service","Please input event name"); + AFB_WARNING("Please input event name"); ret = AFB_EVENT_BAD_REQUEST; } return ret; @@ -205,18 +205,18 @@ int HS_Client::subscribe(afb_req_t request) */ int HS_Client::unsubscribe(afb_req_t request) { - HMI_NOTICE("homescreen-service"," called."); + AFB_DEBUG(" called."); int ret = 0; const char *value = afb_req_value(request, _event); if(value) { - HMI_NOTICE("homescreen-service","unsubscribe %s event", value); + AFB_INFO("unsubscribe %s event", value); event_list.erase(std::string(value)); if(event_list.empty()) { ret = afb_req_unsubscribe(request, my_event); } } else { - HMI_NOTICE("homescreen-service","Please input event name"); + AFB_WARNING("Please input event name"); ret = AFB_EVENT_BAD_REQUEST; } return ret; @@ -235,7 +235,7 @@ int HS_Client::unsubscribe(afb_req_t request) */ int HS_Client::showWindow(afb_req_t request) { - HMI_NOTICE("homescreen-service","%s application_id = %s.", __FUNCTION__, my_id.c_str()); + AFB_INFO("%s application_id = %s.", __FUNCTION__, my_id.c_str()); int ret = 0; struct json_object* push_obj = json_object_new_object(); hs_add_object_to_json_object_str( push_obj, 4, _application_id, my_id.c_str(), _type, __FUNCTION__); @@ -243,7 +243,7 @@ int HS_Client::showWindow(afb_req_t request) if(param) { std::string req_appid = std::move(get_application_id(request)); if(req_appid.empty()) { - HMI_NOTICE("homescreen-service","can't get application identifier"); + AFB_WARNING("can't get application identifier"); return AFB_REQ_GETAPPLICATIONID_ERROR; } @@ -253,7 +253,7 @@ int HS_Client::showWindow(afb_req_t request) afb_event_push(my_event, push_obj); } else { - HMI_ERROR("homescreen-service","please input correct parameter."); + AFB_WARNING("please input correct parameter."); ret = AFB_EVENT_BAD_REQUEST; } return ret; @@ -272,10 +272,10 @@ int HS_Client::showWindow(afb_req_t request) */ int HS_Client::hideWindow(afb_req_t request) { - HMI_NOTICE("homescreen-service"," called."); + AFB_DEBUG(" called."); std::string req_appid = std::move(get_application_id(request)); if(req_appid.empty()) { - HMI_NOTICE("homescreen-service","can't get application identifier"); + AFB_WARNING("can't get application identifier"); return AFB_REQ_GETAPPLICATIONID_ERROR; } @@ -302,7 +302,7 @@ int HS_Client::hideWindow(afb_req_t request) */ int HS_Client::replyShowWindow(afb_req_t request) { - HMI_NOTICE("homescreen-service","%s application_id = %s.", __FUNCTION__, my_id.c_str()); + AFB_INFO("%s application_id = %s.", __FUNCTION__, my_id.c_str()); int ret = 0; struct json_object* push_obj = json_object_new_object(); hs_add_object_to_json_object_str( push_obj, 4, _application_id, my_id.c_str(), _type, __FUNCTION__); @@ -312,7 +312,7 @@ int HS_Client::replyShowWindow(afb_req_t request) afb_event_push(my_event, push_obj); } else { - HMI_ERROR("homescreen-service","please input correct parameter."); + AFB_WARNING("please input correct parameter."); ret = AFB_EVENT_BAD_REQUEST; } return ret; @@ -331,14 +331,14 @@ int HS_Client::replyShowWindow(afb_req_t request) */ int HS_Client::showNotification(afb_req_t request) { - HMI_NOTICE("homescreen-service"," called."); + AFB_DEBUG(" called."); int ret = 0; const char *value = afb_req_value(request, _text); if(value) { - HMI_NOTICE("homescreen-service","text is %s", value); + AFB_INFO("text is %s", value); std::string appid =std::move(get_application_id(request)); if(appid.empty()) { - HMI_NOTICE("homescreen-service","can't get application identifier"); + AFB_WARNING("can't get application identifier"); return AFB_REQ_GETAPPLICATIONID_ERROR; } @@ -354,12 +354,12 @@ int HS_Client::showNotification(afb_req_t request) afb_event_push(my_event, push_obj); } else { - HMI_NOTICE("homescreen-service","please input icon."); + AFB_WARNING("please input icon."); ret = AFB_REQ_SHOWNOTIFICATION_ERROR; } } else { - HMI_NOTICE("homescreen-service","please input text."); + AFB_WARNING("please input text."); ret = AFB_REQ_SHOWNOTIFICATION_ERROR; } @@ -379,14 +379,14 @@ int HS_Client::showNotification(afb_req_t request) */ int HS_Client::showInformation(afb_req_t request) { - HMI_NOTICE("homescreen-service"," called."); + AFB_DEBUG(" called."); int ret = 0; const char *value = afb_req_value(request, _info); if(value) { - HMI_NOTICE("homescreen-service","info is %s", value); + AFB_INFO("info is %s", value); std::string appid = std::move(get_application_id(request)); if(appid.empty()) { - HMI_NOTICE("homescreen-service","can't get application identifier"); + AFB_WARNING("can't get application identifier"); return AFB_REQ_GETAPPLICATIONID_ERROR; } @@ -398,7 +398,7 @@ int HS_Client::showInformation(afb_req_t request) afb_event_push(my_event, push_obj); } else { - HMI_NOTICE("homescreen-service","please input information."); + AFB_WARNING("please input information."); ret = AFB_REQ_SHOWINFORMATION_ERROR; } @@ -459,14 +459,14 @@ bool HS_Client::isSupportEvent(const char* event) */ int HS_Client::handleRequest(afb_req_t request, const char *verb) { - HMI_NOTICE("homescreen-service","called."); + AFB_DEBUG("called."); if((strcasecmp(verb, "subscribe") && strcasecmp(verb, "unsubscribe")) && !checkEvent(verb)) return 0; int ret = AFB_EVENT_BAD_REQUEST; auto ip = func_list.find(std::string(verb)); if(ip != func_list.end() && ip->second != nullptr) { - HMI_NOTICE("homescreen-service","[%s]verb found", verb); + AFB_INFO("[%s]verb found", verb); ret = (this->*(ip->second))(request); } return ret; @@ -489,7 +489,7 @@ int HS_Client::pushEvent(const char *event, struct json_object *param) if(!checkEvent(event)) return 0; - HMI_NOTICE("homescreen-service","called, event=%s.",event); + AFB_INFO("called, event=%s.",event); struct json_object* push_obj = json_object_new_object(); hs_add_object_to_json_object_str( push_obj, 4, _application_id, my_id.c_str(), _type, event); if(param != nullptr) diff --git a/src/hs-clientmanager.cpp b/src/hs-clientmanager.cpp index 8735c2e..1f8bc81 100644 --- a/src/hs-clientmanager.cpp +++ b/src/hs-clientmanager.cpp @@ -13,9 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include #include #include "hs-clientmanager.h" -#include "hmi-debug.h" static const char _homescreen[] = "homescreen"; @@ -70,7 +71,7 @@ HS_ClientManager* HS_ClientManager::instance(void) */ int HS_ClientManager::init(void) { - HMI_NOTICE("homescreen-service","called."); + AFB_NOTICE("called."); } /** @@ -88,7 +89,7 @@ HS_ClientCtxt* HS_ClientManager::createClientCtxt(afb_req_t req, std::string app HS_ClientCtxt *ctxt = (HS_ClientCtxt *)afb_req_context_get(req); if (!ctxt) { - HMI_NOTICE("homescreen-service", "create new session for %s", appid.c_str()); + AFB_INFO( "create new session for %s", appid.c_str()); HS_ClientCtxt *ctxt = new HS_ClientCtxt(appid.c_str()); afb_req_session_set_LOA(req, 1); afb_req_context_set(req, ctxt, cbRemoveClientCtxt); @@ -142,11 +143,11 @@ void HS_ClientManager::removeClientCtxt(void *data) HS_ClientCtxt *ctxt = (HS_ClientCtxt *)data; if(ctxt == nullptr) { - HMI_ERROR("homescreen-service", "data is nullptr"); + AFB_WARNING( "data is nullptr"); return; } - HMI_NOTICE("homescreen-service", "remove app %s", ctxt->id.c_str()); + AFB_INFO( "remove app %s", ctxt->id.c_str()); std::lock_guard lock(this->mtx); removeClient(ctxt->id); delete appid2ctxt[ctxt->id]; @@ -168,7 +169,7 @@ void HS_ClientManager::removeClientCtxt(void *data) */ int HS_ClientManager::handleRequest(afb_req_t request, const char *verb, const char *appid) { - HMI_NOTICE("homescreen-service","verb=[%s],appid=[%s].", verb, appid); + AFB_INFO("verb=[%s],appid=[%s].", verb, appid); int ret = 0; std::lock_guard lock(this->mtx); if(appid == nullptr) { @@ -188,7 +189,7 @@ int HS_ClientManager::handleRequest(afb_req_t request, const char *verb, const c ret = client->handleRequest(request, "subscribe"); } else { - HMI_NOTICE("homescreen-service","not exist session"); + AFB_NOTICE("not exist session"); ret = AFB_REQ_NOT_STARTED_APPLICATION; } } @@ -212,7 +213,7 @@ int HS_ClientManager::handleRequest(afb_req_t request, const char *verb, const c int HS_ClientManager::pushEvent(const char *event, struct json_object *param, std::string appid) { if(event == nullptr) { - HMI_ERROR("homescreen-service","event name is null."); + AFB_WARNING("event name is null."); return -1; } diff --git a/src/hs-proxy.cpp b/src/hs-proxy.cpp index 0f5e78c..f0ee5f0 100644 --- a/src/hs-proxy.cpp +++ b/src/hs-proxy.cpp @@ -15,7 +15,6 @@ */ #include "hs-proxy.h" -#include "hmi-debug.h" const char _afm_main[] = "afm-main"; @@ -36,7 +35,7 @@ const char _afm_main[] = "afm-main"; */ static void api_callback(void *closure, struct json_object *object, const char *error, const char *info, afb_api_t api) { - HMI_DEBUG("homescreen-service","asynchronous call, error=%s, info=%s, object=%s.", error, info, json_object_get_string(object)); + AFB_INFO("asynchronous call, error=%s, info=%s, object=%s.", error, info, json_object_get_string(object)); } /** @@ -54,7 +53,7 @@ static void api_callback(void *closure, struct json_object *object, const char * */ static void api_call(afb_api_t api, const char *service, const char *verb, struct json_object *args) { - HMI_DEBUG("homescreen-service","service=%s verb=%s, args=%s.", service, verb, json_object_get_string(args)); + AFB_INFO("service=%s verb=%s, args=%s.", service, verb, json_object_get_string(args)); afb_api_call(api, service, verb, args, api_callback, nullptr); } @@ -77,7 +76,7 @@ static int api_call_sync(afb_api_t api, const char *service, const char *verb, s { char *error = nullptr, *info = nullptr; int ret = afb_api_call_sync(api, service, verb, args, object, &error, &info); - HMI_DEBUG("homescreen-service","synchronous call, error=%s, info=%s.", error, info); + AFB_INFO("synchronous call, error=%s, info=%s.", error, info); return ret; } -- 2.16.6