Modified log messages 19/188219/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 3 Sep 2018 06:22:20 +0000 (15:22 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 3 Sep 2018 06:22:20 +0000 (15:22 +0900)
To reduce printing log messages, this patch adds and modifies
exceptions.

Change-Id: I3fd50fe8e29292894dc344e92b69ca0bc767e5f2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/widget_service.c

index bdcaa2c..46d7c35 100644 (file)
@@ -223,7 +223,6 @@ static const char *_get_db_path(uid_t uid, bool is_init)
                                TZ_SYS_DB : TZ_USER_DB, ".widget.db");
        }
 
-       _E("%s", path);
        tzplatform_reset_user();
 
        return path;
@@ -448,7 +447,8 @@ static sqlite3 *_open_db(uid_t uid)
        ret = sqlite3_open_v2(path, &db, SQLITE_OPEN_READONLY, NULL);
        if (ret != SQLITE_OK) {
                /* LCOV_EXCL_START */
-               _E("failed to open widget db: %d", ret);
+               _E("failed to open widget db. path(%s), result(%d)",
+                               path, ret);
                return NULL;
                /* LCOV_EXCL_STOP */
        }
@@ -1233,7 +1233,6 @@ static char *_get_main_app_id(const char *widget_id, uid_t uid)
                /* TODO: which error should be set? */
                if (ret == SQLITE_DONE) {
                        set_last_result(WIDGET_ERROR_NOT_EXIST);
-                       LOGW("No data for uid (%d)", uid);
                } else {
                        set_last_result(WIDGET_ERROR_FAULT);
                        _E("step error: %s", sqlite3_errmsg(db));
@@ -1295,6 +1294,11 @@ EAPI char *widget_service_get_main_app_id(const char *widget_id)
                        && !_is_global(getuid()))
                appid = _get_main_app_id(widget_id, GLOBALAPP_USER);
 
+       if (!appid) {
+               _E("Failed to get main appid. widget(%s), result(%d)",
+                               widget_id, get_last_result());
+       }
+
        return appid;
 }
 
@@ -1374,7 +1378,6 @@ static char *_get_app_id_of_setup_app(const char *widget_id, uid_t uid)
                /* TODO: which error should be set? */
                if (ret == SQLITE_DONE) {
                        set_last_result(WIDGET_ERROR_NOT_EXIST);
-                       LOGW("No data for uid (%d)", uid);
                } else {
                        set_last_result(WIDGET_ERROR_FAULT);
                        _E("step error: %s", sqlite3_errmsg(db));
@@ -1419,6 +1422,11 @@ EAPI char *widget_service_get_app_id_of_setup_app(const char *widget_id)
                        && !_is_global(getuid()))
                appid = _get_app_id_of_setup_app(widget_id, GLOBALAPP_USER);
 
+       if (!appid) {
+               _E("Failed to get setdup app. widget_id(%s), result(%d)",
+                               widget_id, get_last_result());
+       }
+
        return appid;
 }
 
@@ -1454,7 +1462,6 @@ static int _get_nodisplay(const char *widget_id, uid_t uid)
                /* TODO: which error should be set? */
                if (ret == SQLITE_DONE) {
                        set_last_result(WIDGET_ERROR_NOT_EXIST);
-                       LOGW("No data for uid (%d)", uid);
                } else {
                        set_last_result(WIDGET_ERROR_FAULT);
                        _E("step error: %s", sqlite3_errmsg(db));
@@ -1499,7 +1506,6 @@ static int _get_update_period(const char *widget_id, uid_t uid, double *period)
                sqlite3_finalize(stmt);
                sqlite3_close_v2(db);
                if (ret == SQLITE_DONE) {
-                       LOGW("No data for uid (%d)", uid);
                        return WIDGET_ERROR_NOT_EXIST;
                } else {
                        _E("step error: %s", sqlite3_errmsg(db));
@@ -1516,11 +1522,17 @@ static int _get_update_period(const char *widget_id, uid_t uid, double *period)
 
 int widget_service_get_update_period(const char *widget_id, double *period)
 {
-       int ret = _get_update_period(widget_id, getuid(), period);
+       int ret;
 
+       ret = _get_update_period(widget_id, getuid(), period);
        if (ret == WIDGET_ERROR_NOT_EXIST)
                ret = _get_update_period(widget_id, GLOBALAPP_USER, period);
 
+       if (ret != WIDGET_ERROR_NONE) {
+               _E("Failed to get update period. widget(%s), result(%d)",
+                               widget_id, ret);
+       }
+
        return ret;
 }
 
@@ -1551,6 +1563,11 @@ EAPI int widget_service_get_nodisplay(const char *widget_id)
                        && !_is_global(getuid()))
                nodisplay = _get_nodisplay(widget_id, GLOBALAPP_USER);
 
+       if (!nodisplay) {
+               _E("Failed to get nodisplay. widget(%s), result(%d)",
+                               widget_id, get_last_result());
+       }
+
        return nodisplay;
 }
 
@@ -1654,7 +1671,6 @@ static char *_get_preview_image_path(const char *widget_id, int width,
                /* TODO: which error should be set? */
                if (ret == SQLITE_DONE) {
                        set_last_result(WIDGET_ERROR_NOT_EXIST);
-                       LOGW("No data for uid (%d)", uid);
                } else {
                        set_last_result(WIDGET_ERROR_FAULT);
                        _E("step error: %s", sqlite3_errmsg(db));
@@ -1829,10 +1845,7 @@ static char *_get_main_widget_id(const char *pkg_id, uid_t uid)
 
        ret = sqlite3_step(stmt);
        if (ret != SQLITE_ROW) {
-               if (ret == SQLITE_DONE)
-                       LOGW("cannot find widget_id for pkg_id %s, uid(%d)"
-                                       , pkg_id, uid);
-               else
+               if (ret != SQLITE_DONE)
                        _E("step error: %s", sqlite3_errmsg(db));
                sqlite3_finalize(stmt);
                sqlite3_close_v2(db);
@@ -1887,10 +1900,7 @@ static char *_get_icon(const char *widget_id, const char *lang, uid_t uid)
 
        ret = sqlite3_step(stmt);
        if (ret != SQLITE_ROW) {
-               if (ret == SQLITE_DONE)
-                       LOGW("cannot find icon for widget_id %s, uid(%d)"
-                                       , widget_id, uid);
-               else
+               if (ret != SQLITE_DONE)
                        _E("step error: %s", sqlite3_errmsg(db));
                sqlite3_finalize(stmt);
                sqlite3_close_v2(db);
@@ -1942,6 +1952,11 @@ EAPI char *widget_service_get_icon(const char *pkgid, const char *lang)
                        && !_is_global(getuid()))
                icon = _get_icon(widget_id, lang, GLOBALAPP_USER);
 
+       if (!icon) {
+               _E("Failed to get icon. pkgid(%s), lang(%s), result(%d)",
+                               pkgid, lang, get_last_result());
+       }
+
        return icon;
 }
 
@@ -1980,12 +1995,8 @@ static char *_get_name(const char *widget_id, const char *lang, uid_t uid)
 
        ret = sqlite3_step(stmt);
        if (ret != SQLITE_ROW) {
-               if (ret == SQLITE_DONE)
-                       LOGW("cannot find label for widget_id %s, uid(%d)"
-                                       , widget_id, uid);
-               else
+               if (ret != SQLITE_DONE)
                        _E("step error: %s", sqlite3_errmsg(db));
-               _E("step error: %s", sqlite3_errmsg(db));
                sqlite3_finalize(stmt);
                sqlite3_close_v2(db);
                /* TODO: which error should be set? */
@@ -2071,6 +2082,11 @@ EAPI char *widget_service_get_name(const char *widget_id, const char *lang)
                        && !_is_global(getuid()))
                name = _get_name(widget_id, language, GLOBALAPP_USER);
 
+       if (!name) {
+               _E("Failed to get name. widget(%s), lang(%s), result(%d)",
+                               widget_id, lang, get_last_result());
+       }
+
        free(language);
 
        return name;
@@ -2100,8 +2116,15 @@ EAPI int widget_service_get_supported_sizes(const char *widget_id, int *cnt,
                ret = _get_widget_supported_sizes(widget_id, GLOBALAPP_USER,
                                cnt, w, h);
 
-       if (ret == WIDGET_ERROR_NOT_EXIST)
-               _E("cannot find supported sizes for widget %s", widget_id);
+       if (ret != WIDGET_ERROR_NONE) {
+               if (ret == WIDGET_ERROR_NOT_EXIST) {
+                       _E("cannot find supported sizes for widget %s",
+                                       widget_id);
+               } else {
+                       _E("Failed to get widget(%s) supported size",
+                                       widget_id);
+               }
+       }
 
        return ret;
 }
@@ -2277,6 +2300,11 @@ EAPI char *widget_service_get_widget_id(const char *appid)
                        && !_is_global(getuid()))
                classid = _get_widget_id(widget_id, GLOBALAPP_USER);
 
+       if (!classid) {
+               _E("Failed to get widget id. appid(%s), result(%d)",
+                               appid, get_last_result());
+       }
+
        free(widget_id);
 
        return classid;
@@ -2316,7 +2344,6 @@ static char *_get_package_id(const char *widget_id, uid_t uid)
                /* TODO: which error should be set? */
                if (ret == SQLITE_DONE) {
                        set_last_result(WIDGET_ERROR_NOT_EXIST);
-                       LOGW("No data for uid (%d)", uid);
                } else {
                        set_last_result(WIDGET_ERROR_FAULT);
                        _E("step error: %s", sqlite3_errmsg(db));
@@ -2360,6 +2387,11 @@ EAPI char *widget_service_get_package_id(const char *widget_id)
                        && !_is_global(getuid()))
                pkgid = _get_package_id(widget_id, GLOBALAPP_USER);
 
+       if (!pkgid) {
+               _E("Failed to get package id. widget(%s), result(%d)",
+                               widget_id, get_last_result());
+       }
+
        return pkgid;
 }
 
@@ -2634,7 +2666,6 @@ static int __get_max_instance(const char *widget_id, uid_t uid)
                sqlite3_finalize(stmt);
                sqlite3_close_v2(db);
                if (ret == SQLITE_DONE) {
-                       LOGW("No data for uid (%d)", uid);
                        return WIDGET_ERROR_NOT_EXIST;
                } else {
                        _E("step error: %s", sqlite3_errmsg(db));
@@ -2672,6 +2703,11 @@ EAPI int widget_service_get_widget_max_count(const char *widget_id)
        if (ret == WIDGET_ERROR_NOT_EXIST && !_is_global(getuid()))
                ret = __get_max_instance(widget_id, GLOBALAPP_USER);
 
+       if (ret != WIDGET_ERROR_NONE) {
+               _E("Failed to get widget(%s) max count. result(%d)",
+                               widget_id, ret);
+       }
+
        return ret;
 }