unify log-related code 76/33076/4 tizen_3.0_ivi accepted/tizen/common/20150113.085924 accepted/tizen/ivi/20150115.062919 submit/tizen_common/20150108.142014 submit/tizen_common/20150109.133122 submit/tizen_common/20150112.103909 submit/tizen_common/20150112.154626 submit/tizen_ivi/20150115.222222 tizen_3.0_ivi_release
authorWonguk Jeong <wonguk.jeong@samsung.com>
Mon, 5 Jan 2015 08:26:32 +0000 (17:26 +0900)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Thu, 8 Jan 2015 14:08:02 +0000 (06:08 -0800)
There is divergence of codes regarding log message.
Use unified header(package-manager-debug.h) and set tag separately.

Change-Id: I57bc25b85c1779d1e418cf4ff8b95b0644486023
Signed-off-by: Wonguk Jeong <wonguk.jeong@samsung.com>
16 files changed:
client/include/pkgmgr-debug.h
client/src/pkgmgr-internal.c
client/src/pkgmgr.c
comm/comm_client.c
comm/comm_client_gdbus.c
comm/comm_config.h
comm/comm_debug.h [new file with mode: 0644]
comm/comm_pkg_mgr_server.c
comm/comm_status_broadcast_server.c
comm/comm_status_broadcast_server_dbus.c
comm/pkgmgr_installer.c
include/package-manager-debug.h [new file with mode: 0644]
server/include/pkgmgr-server.h
server/src/pkgmgr-server.c
server/src/pm-queue.c
tool/pkg_getsize.c

index 7ec0523..8b6e758 100644 (file)
 #ifndef __PKGMGR_DEBUG_H__
 #define __PKGMGR_DEBUG_H__
 
-#include <dlog.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif /* LOG_TAG */
+#define LOG_TAG "PKGMGR"
 
-#define _LOGE(fmt, arg...) LOGE(fmt, ##arg)
-#define _LOGD(fmt, arg...) LOGD(fmt, ##arg)
+#include "package-manager-debug.h"
 
-
-#define COLOR_RED              "\033[0;31m"
-#define COLOR_BLUE             "\033[0;34m"
-#define COLOR_END              "\033[0;m"
-
-#define PKGMGR_DEBUG(fmt, ...)\
-       do\
-       {\
-               LOGD("[%s(): %d]" fmt, __FUNCTION__, __LINE__,##__VA_ARGS__);\
+#define ret_if(expr) \
+       do { \
+               if (expr) { \
+                       ERR("(%s) ", #expr); \
+                       return; \
+               } \
        } while (0)
 
-#define PKGMGR_DEBUG_ERR(fmt, ...)\
-       do\
-       {\
-               LOGE(COLOR_RED"[%s(): %d]" fmt COLOR_END, __FUNCTION__, __LINE__,##__VA_ARGS__);\
-       }while (0)
-
-#define PKGMGR_BEGIN() \
-       do\
-    {\
-               LOGD(COLOR_BLUE"[%s(): %d] BEGIN >>>>"COLOR_END, __FUNCTION__ ,__LINE__);\
-    } while( 0 )
-
-#define PKGMGR_END() \
-       do\
-    {\
-               LOGD(COLOR_BLUE"[%s(): %d] END <<<<"COLOR_END, __FUNCTION__,__LINE__ );\
-    } \
-    while( 0 )
-
-#define ret_if(expr) do { \
-       if (expr) { \
-               PKGMGR_DEBUG_ERR("(%s) ", #expr); \
-               PKGMGR_END();\
-               return; \
-       } \
-} while (0)
-
-#define retm_if(expr, fmt, arg...) do { \
-        if (expr) { \
-                PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
-                PKGMGR_END();\
-                return; \
-        } \
- } while (0)
+#define retm_if(expr, fmt, arg...) \
+       do { \
+               if (expr) { \
+                       ERR("(%s) "fmt, #expr, ##arg); \
+                       return; \
+               } \
+       } while (0)
 
-#define retv_if(expr, val) do { \
+#define retv_if(expr, val) \
+       do { \
                if (expr) { \
-                       PKGMGR_DEBUG_ERR("(%s) ", #expr); \
-                       PKGMGR_END();\
+                       ERR("(%s) ", #expr); \
                        return (val); \
                } \
        } while (0)
 
-#define retvm_if(expr, val, fmt, arg...) do { \
-       if (expr) { \
-               PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
-               PKGMGR_END();\
-               return (val); \
-       } \
-} while (0)
+#define retvm_if(expr, val, fmt, arg...) \
+       do { \
+               if (expr) { \
+                       ERR("(%s) "fmt, #expr, ##arg); \
+                       return (val); \
+               } \
+       } while (0)
 
-#define trym_if(expr, fmt, arg...) do { \
-                        if (expr) { \
-                                PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
-                                goto catch; \
-                        } \
-                } while (0)
+#define trym_if(expr, fmt, arg...) \
+       do { \
+               if (expr) { \
+                       ERR("(%s) "fmt, #expr, ##arg); \
+                       goto catch; \
+               } \
+       } while (0)
 
-#define tryvm_if(expr, val, fmt, arg...) do { \
-                        if (expr) { \
-                                PKGMGR_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
-                                val; \
-                                goto catch; \
-                        } \
-                } while (0)
+#define tryvm_if(expr, val, fmt, arg...) \
+       do { \
+               if (expr) { \
+                       ERR("(%s) "fmt, #expr, ##arg); \
+                       val; \
+                       goto catch; \
+               } \
+       } while (0)
 
 #endif  /* __PKGMGR_DEBUG_H__ */
index 7fdd5f3..876720d 100644 (file)
 #include "package-manager.h"
 #include <pkgmgr-info.h>
 
-#undef LOG_TAG
-#ifndef LOG_TAG
-#define LOG_TAG "PKGMGR"
-#endif                         /* LOG_TAG */
-
 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
 
 #define IS_WHITESPACE(CHAR) \
@@ -88,7 +83,7 @@ char *_get_backend_path(const char *input_path)
                strncpy(pkg_path, input_path, PKG_STRING_LEN_MAX - 1);
        }
 
-       _LOGD("pkg_path[%s]\n", pkg_path);
+       DBG("pkg_path[%s]\n", pkg_path);
 
        fp = fopen(PKG_CONF_PATH, "r");
        if (fp == NULL) {
@@ -103,10 +98,10 @@ char *_get_backend_path(const char *input_path)
                _app_str_trim(buffer);
 
                if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
-                       _LOGD("[%s]\n", buffer);
-                       _LOGD("[%s]\n", path);
+                       DBG("[%s]\n", buffer);
+                       DBG("[%s]\n", path);
                        path = path + strlen(PKG_BACKEND);
-                       _LOGD("[%s]\n", path);
+                       DBG("[%s]\n", path);
 
                        break;
                }
@@ -134,7 +129,7 @@ char *_get_backend_path(const char *input_path)
        snprintf(installer_path, PKG_STRING_LEN_MAX - 1, 
                                        "%s%s", backend_path, type);
 
-       _LOGD("installer_path[%s]\n", installer_path);
+       DBG("installer_path[%s]\n", installer_path);
 
        if (access(installer_path, F_OK) != 0)
                return NULL;
@@ -149,7 +144,7 @@ char *_get_backend_path_with_type(const char *type)
        char installer_path[PKG_STRING_LEN_MAX] = { '\0', };
        char backend_path[PKG_STRING_LEN_MAX] = { '\0', };
 
-       _LOGD("type[%s]\n", type);
+       DBG("type[%s]\n", type);
 
        fp = fopen(PKG_CONF_PATH, "r");
        if (fp == NULL) {
@@ -164,10 +159,10 @@ char *_get_backend_path_with_type(const char *type)
                _app_str_trim(buffer);
 
                if ((path = strstr(buffer, PKG_BACKEND)) != NULL) {
-                       _LOGD("[%s]\n", buffer);
-                       _LOGD("[%s]\n", path);
+                       DBG("[%s]\n", buffer);
+                       DBG("[%s]\n", path);
                        path = path + strlen(PKG_BACKEND);
-                       _LOGD("[%s]\n", path);
+                       DBG("[%s]\n", path);
 
                        break;
                }
@@ -188,12 +183,12 @@ char *_get_backend_path_with_type(const char *type)
 
        snprintf(installer_path, PKG_STRING_LEN_MAX - 1, 
                                        "%s%s", backend_path, type);
-       _LOGD("installer_path[%s]\n", installer_path);
+       DBG("installer_path[%s]\n", installer_path);
 
        if (access(installer_path, F_OK) != 0) {
                char extlist[256] = { '\0', };
                _get_mime_extension(type, extlist, sizeof(extlist));
-               _LOGD("extlist[%s]\n", extlist);
+               DBG("extlist[%s]\n", extlist);
 
                if (strlen(extlist) == 0)
                        return NULL;
@@ -352,25 +347,25 @@ pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
        bool(*on_load) (pkg_plugin_set *plugin);
 
        if (library_path == NULL) {
-               _LOGE("pkg library path = [%s] \n", library_path);
+               ERR("pkg library path = [%s] \n", library_path);
                return NULL;
        }
 
        if ((library_handle = dlopen(library_path, RTLD_LAZY)) == NULL) {
-               _LOGE("dlopen is failed library_path[%s]\n", library_path);
+               ERR("dlopen is failed library_path[%s]\n", library_path);
                return NULL;
        }
 
        if ((on_load = dlsym(library_handle, "pkg_plugin_on_load")) == NULL || 
            dlerror() != NULL) {
-               _LOGE("can not find symbol \n");
+               ERR("can not find symbol \n");
                dlclose(library_handle);
                return NULL;
        }
 
        for (i = 0; plugin_set_list[i]; i++) {
                if (strcmp(plugin_set_list[i]->pkg_type, pkg_type) == 0) {
-                       _LOGD("already loaded [%s] is done well \n",
+                       DBG("already loaded [%s] is done well \n",
                              library_path);
                        goto END;
                }
@@ -378,7 +373,7 @@ pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
 
        plugin_set_list[i] = (pkg_plugin_set *) malloc(sizeof(pkg_plugin_set));
        if (plugin_set_list[i] == NULL) {
-               _LOGE("malloc of the plugin_set_list element is failed \n");
+               ERR("malloc of the plugin_set_list element is failed \n");
                dlclose(library_handle);
                return NULL;
        }
@@ -386,7 +381,7 @@ pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
        memset(plugin_set_list[i], 0x0, sizeof(pkg_plugin_set));
 
        if (on_load(plugin_set_list[i]) != 0) {
-               _LOGE("on_load is failed \n");
+               ERR("on_load is failed \n");
 
                dlclose(library_handle);
 
@@ -400,7 +395,7 @@ pkg_plugin_set *_pkg_plugin_load_library(const char *pkg_type,
        strncpy(plugin_set_list[i]->pkg_type, pkg_type,
                PKG_TYPE_STRING_LEN_MAX - 1);
 
-       _LOGD("load library [%s] is done well \n", library_path);
+       DBG("load library [%s] is done well \n", library_path);
 
  END:
        return plugin_set_list[i];
@@ -413,13 +408,13 @@ int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path)
        char buffer[1024] = { 0 };
 
        if (pkg_type == NULL || library_path == NULL) {
-               _LOGE("invalid argument\n");
+               ERR("invalid argument\n");
                return -1;
        }
 
        fp = fopen(PKG_CONF_PATH, "r");
        if (fp == NULL) {
-               _LOGE("no matching backendlib\n");
+               ERR("no matching backendlib\n");
                return PKGMGR_R_ERROR;
        }
 
@@ -431,10 +426,10 @@ int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path)
                _app_str_trim(buffer);
 
                if ((path = strstr(buffer, PKG_BACKENDLIB)) != NULL) {
-                       _LOGD("[%s]\n", buffer);
-                       _LOGD("[%s]\n", path);
+                       DBG("[%s]\n", buffer);
+                       DBG("[%s]\n", path);
                        path = path + strlen(PKG_BACKENDLIB);
-                       _LOGD("[%s]\n", path);
+                       DBG("[%s]\n", path);
 
                        break;
                }
@@ -446,7 +441,7 @@ int _pkg_plugin_get_library_path(const char *pkg_type, char *library_path)
                fclose(fp);
 
        if (path == NULL) {
-               _LOGE("no matching backendlib\n");
+               ERR("no matching backendlib\n");
                return PKGMGR_R_ERROR;
        }
 
@@ -462,7 +457,7 @@ pkg_plugin_set *_package_manager_load_library(const char *pkg_type)
        pkg_plugin_set *plugin_set = NULL;
 
        if (pkg_type == NULL) {
-               _LOGE("can not load library - pkg_type is null\n");
+               ERR("can not load library - pkg_type is null\n");
                return NULL;
        }
 
@@ -470,11 +465,11 @@ pkg_plugin_set *_package_manager_load_library(const char *pkg_type)
            PKGMGR_R_OK) {
                plugin_set = _pkg_plugin_load_library(pkg_type, package_path);
                if (plugin_set == NULL) {
-                       _LOGE("can not load library \n");
+                       ERR("can not load library \n");
                        return NULL;
                }
        } else {
-               _LOGE("can not find path \n");
+               ERR("can not find path \n");
                return NULL;
        }
 
index 0b93876..ea70fba 100644 (file)
 #include "comm_client.h"
 #include "comm_status_broadcast_server.h"
 
-#undef LOG_TAG
-#ifndef LOG_TAG
-#define LOG_TAG "PKGMGR"
-#endif                         /* LOG_TAG */
-
 #define PKG_TMP_PATH tzplatform_mkpath(TZ_USER_APP, "tmp")
 
 #define BINSH_NAME     "/bin/sh"
@@ -242,7 +237,7 @@ static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
 
        cb_info = (req_cb_info *) calloc(1, sizeof(req_cb_info));
        if (cb_info == NULL) {
-               _LOGD("calloc failed");
+               DBG("calloc failed");
                return;
        }
        cb_info->request_id = request_id;
@@ -271,11 +266,11 @@ static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
        tmp = pc->info.request.rhead;
 
        if (tmp == NULL) {
-               _LOGE("tmp is NULL");
+               ERR("tmp is NULL");
                return NULL;
        }
 
-       _LOGD("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
+       DBG("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
 
        while (tmp) {
                if (strncmp(tmp->req_key, req_key, strlen(tmp->req_key)) == 0)
@@ -313,7 +308,7 @@ static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
 
        cb_info = (listen_cb_info *) calloc(1, sizeof(listen_cb_info));
        if (cb_info == NULL) {
-               _LOGD("calloc failed");
+               DBG("calloc failed");
                return;
        }
        cb_info->request_id = request_id;
@@ -342,7 +337,7 @@ static void __operation_callback(void *cb_data, const char *req_id,
        pkgmgr_client_t *pc;
        req_cb_info *cb_info;
 
-       _LOGD("__operation_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
+       DBG("__operation_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
              "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
 
        pc = (pkgmgr_client_t *) cb_data;
@@ -352,19 +347,19 @@ static void __operation_callback(void *cb_data, const char *req_id,
        if (cb_info == NULL)
                return;
 
-       _LOGD("__find_op_cbinfo");
+       DBG("__find_op_cbinfo");
 
        /* call callback */
        if (cb_info->event_cb) {
                cb_info->event_cb(cb_info->request_id, pkg_type, pkgid, key,
                                  val, NULL, cb_info->data);
-               _LOGD("event_cb is called");
+               DBG("event_cb is called");
        }
 
        /*remove callback for last call 
           if (strcmp(key, "end") == 0) {
           __remove_op_cbinfo(pc, cb_info);
-          _LOGD("__remove_op_cbinfo");
+          DBG("__remove_op_cbinfo");
           }
         */
 
@@ -378,7 +373,7 @@ static void __status_callback(void *cb_data, const char *req_id,
        pkgmgr_client_t *pc;
        listen_cb_info *tmp;
 
-       _LOGD("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
+       DBG("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
              "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
 
        pc = (pkgmgr_client_t *) cb_data;
@@ -409,7 +404,7 @@ static char *__get_req_key(const char *pkg_path)
        size = strlen(pkg_path) + strlen(timestr) + 2;
        str_req_key = (char *)calloc(size, sizeof(char));
        if (str_req_key == NULL) {
-               _LOGD("calloc failed");
+               DBG("calloc failed");
                return NULL;
        }
        snprintf(str_req_key, size, "%s_%s", pkg_path, timestr);
@@ -426,14 +421,14 @@ static char *__get_type_from_path(const char *pkg_path)
 
        ret = _get_mime_from_file(pkg_path, mimetype, sizeof(mimetype));
        if (ret) {
-               _LOGE("_get_mime_from_file() failed - error code[%d]\n",
+               ERR("_get_mime_from_file() failed - error code[%d]\n",
                      ret);
                return NULL;
        }
 
        ret = _get_mime_extension(mimetype, extlist, sizeof(extlist));
        if (ret) {
-               _LOGE("_get_mime_extension() failed - error code[%d]\n",
+               ERR("_get_mime_extension() failed - error code[%d]\n",
                      ret);
                return NULL;
        }
@@ -598,11 +593,11 @@ static char *__get_caller_pkgid(uid_t uid)
        char *caller_pkgid = NULL;
 
        if (__get_appid_bypid(getpid(), caller_appid, sizeof(caller_appid), uid) < 0) {
-               _LOGE("get appid fail!!!\n");
+               ERR("get appid fail!!!\n");
                return NULL;
        }
        if (__get_pkgid_by_appid(caller_appid, &caller_pkgid) < 0){
-               _LOGE("get pkgid fail!!!\n");
+               ERR("get pkgid fail!!!\n");
                return NULL;
        }
 
@@ -717,15 +712,15 @@ static int __sync_process(char *req_key)
 
                vconf_get_int(VCONFKEY_PKGMGR_STATUS, &result);
                if (result < 0) {
-                       _LOGD("file is not generated yet.... wait\n");
+                       DBG("file is not generated yet.... wait\n");
                        usleep(10 * 1000);      /* 10ms sleep*/
                } else {
-                       _LOGD("info_file file is generated, result = %d. \n", result);
+                       DBG("info_file file is generated, result = %d. \n", result);
                        break;
                }
 
                if (check_cnt > 6000) { /* 60s time over*/
-                       _LOGD("wait time over!!\n");
+                       DBG("wait time over!!\n");
                        break;
                }
        }
@@ -863,7 +858,7 @@ static int __get_size_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -872,11 +867,11 @@ static int __get_size_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
        /* request */
        ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
        if (ret < 0)
-               _LOGE("comm_client_request failed, ret=%d\n", ret);
+               ERR("comm_client_request failed, ret=%d\n", ret);
 
        ret = __sync_process(req_key);
        if (ret < 0)
-               _LOGE("get size failed, ret=%d\n", ret);
+               ERR("get size failed, ret=%d\n", ret);
 
 catch:
        for (i = 0; i < argcnt; i++)
@@ -961,7 +956,7 @@ static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -970,12 +965,12 @@ static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, uid_t uid,
        /* 6. request */
        ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie,uid, 1);
        if (ret < 0)
-               _LOGE("comm_client_request failed, ret=%d\n", ret);
+               ERR("comm_client_request failed, ret=%d\n", ret);
 
        snprintf(info_file, PKG_STRING_LEN_MAX, "app2sd_%s", pkgid);
        ret = __sync_process(info_file);
        if (ret != 0)
-               _LOGE("move pkg failed, ret=%d\n", ret);
+               ERR("move pkg failed, ret=%d\n", ret);
 
 catch:
        for (i = 0; i < argcnt; i++)
@@ -1021,7 +1016,7 @@ static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_
                ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_CHECK_APP, pkgtype, pkgid, NULL, NULL, uid, 1);
 
        if (ret < 0)
-               _LOGE("request failed, ret=%d\n", ret);
+               ERR("request failed, ret=%d\n", ret);
 
        pid  = __sync_process(req_key);
        * (int *) data = pid;
@@ -1106,7 +1101,7 @@ API int pkgmgr_client_free(pkgmgr_client *pc)
                comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
                ret = 0;
        } else {
-               _LOGE("Invalid client type\n");
+               ERR("Invalid client type\n");
                return PKGMGR_R_EINVAL;
        }
 
@@ -1144,7 +1139,7 @@ API int pkgmgr_client_usr_install(pkgmgr_client * pc, const char *pkg_type,
 
        caller_pkgid = __get_caller_pkgid(uid);
        if (caller_pkgid == NULL)
-               _LOGE("caller dont have pkgid..\n");
+               ERR("caller dont have pkgid..\n");
 
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL");
@@ -1176,7 +1171,7 @@ API int pkgmgr_client_usr_install(pkgmgr_client * pc, const char *pkg_type,
        }
        if (installer_path == NULL) {
                free(pkgtype);
-               _LOGE("installer_path is NULL\n");
+               ERR("installer_path is NULL\n");
                return PKGMGR_R_EINVAL;
        }
 
@@ -1235,7 +1230,7 @@ API int pkgmgr_client_usr_install(pkgmgr_client * pc, const char *pkg_type,
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -1368,7 +1363,7 @@ API int pkgmgr_client_usr_reinstall(pkgmgr_client * pc, const char *pkg_type, co
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -1422,7 +1417,7 @@ API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
 
        caller_pkgid = __get_caller_pkgid(uid);
        if (caller_pkgid == NULL)
-               _LOGD("caller dont have pkgid..\n");
+               DBG("caller dont have pkgid..\n");
 
        /* Check for NULL value of pc */
        retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
@@ -1522,7 +1517,7 @@ API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -1545,7 +1540,6 @@ catch:
                free(cookie);
 
        pkgmgr_pkginfo_destroy_pkginfo(handle);
-       PKGMGR_END();\
        return ret;
 }
 
@@ -1573,7 +1567,7 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
 
        /* Check for NULL value of pc */
        if (pc == NULL) {
-               _LOGD("package manager client handle is NULL\n");
+               DBG("package manager client handle is NULL\n");
                return PKGMGR_R_EINVAL;
        }
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
@@ -1636,7 +1630,7 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
 
        args = (char *)calloc(len, sizeof(char));
        if (args == NULL) {
-               _LOGD("calloc failed");
+               DBG("calloc failed");
 
                for (i = 0; i < argcnt; i++)
                        free(argv[i]);
@@ -1651,7 +1645,7 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
        /******************* end of quote ************************/
 
        /* 6. request install */
@@ -1659,7 +1653,7 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
                                  COMM_REQ_TO_MOVER, pkgtype, pkgid,
                                  args, cookie, uid, 1);
        if (ret < 0) {
-               _LOGE("request failed, ret=%d\n", ret);
+               ERR("request failed, ret=%d\n", ret);
 
                for (i = 0; i < argcnt; i++)
                        free(argv[i]);
@@ -1800,7 +1794,7 @@ API int pkgmgr_client_move_usr_pkg(pkgmgr_client *pc, const char *pkg_type,
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -1823,7 +1817,6 @@ catch:
                free(cookie);
 
        pkgmgr_pkginfo_destroy_pkginfo(handle);
-       PKGMGR_END();\
        return ret;
 }
 
@@ -2029,7 +2022,7 @@ API int pkgmgr_client_usr_activate_appv(pkgmgr_client * pc, const char *appid, c
                strncat(argsr, args, strlen(args));
        }
 
-       _LOGD("argsr [%s]\n", argsr);
+       DBG("argsr [%s]\n", argsr);
        /******************* end of quote ************************/
 
        /* 3. request activate */
@@ -2111,7 +2104,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ
 
        /* Check for NULL value of pc */
        if (pc == NULL) {
-               _LOGD("package manager client handle is NULL\n");
+               DBG("package manager client handle is NULL\n");
                return PKGMGR_R_EINVAL;
        }
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
@@ -2168,7 +2161,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ
 
        args = (char *)calloc(len, sizeof(char));
        if (args == NULL) {
-               _LOGD("calloc failed");
+               DBG("calloc failed");
 
                for (i = 0; i < argcnt; i++)
                        free(argv[i]);
@@ -2183,7 +2176,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
        /******************* end of quote ************************/
 
        /* 6. request clear */
@@ -2191,7 +2184,7 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_typ
                                  COMM_REQ_TO_CLEARER, pkgtype, appid,
                                  args, cookie, uid, 1);
        if (ret < 0) {
-               _LOGE("request failed, ret=%d\n", ret);
+               ERR("request failed, ret=%d\n", ret);
 
                for (i = 0; i < argcnt; i++)
                        free(argv[i]);
@@ -2291,12 +2284,12 @@ API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
 {
        /* Check for NULL value of pc */
        if (pc == NULL) {
-               _LOGD("package manager client handle is NULL\n");
+               DBG("package manager client handle is NULL\n");
                return PKGMGR_R_EINVAL;
        }
        /* Check for valid arguments. NULL parameter causes DBUS to abort */
        if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
-               _LOGD("Argument supplied is NULL\n");
+               DBG("Argument supplied is NULL\n");
                return PKGMGR_R_EINVAL;
        }
        pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
@@ -2359,7 +2352,7 @@ API int pkgmgr_client_usr_request_service(pkgmgr_request_service_type service_ty
 
                ret = __csc_process(custom_info, (char *)data);
                if (ret < 0)
-                       _LOGE("__csc_process fail \n");
+                       ERR("__csc_process fail \n");
                else
                        ret = PKGMGR_R_OK;
 
@@ -2388,14 +2381,14 @@ API int pkgmgr_client_usr_request_service(pkgmgr_request_service_type service_ty
 
                ret = __check_app_process(service_type, pc, pkgid, uid, data);
                if (ret < 0)
-                       _LOGE("__check_app_process fail \n");
+                       ERR("__check_app_process fail \n");
                else
                        ret = PKGMGR_R_OK;
 
                break;
 
        default:
-               _LOGE("Wrong Request\n");
+               ERR("Wrong Request\n");
                ret = -1;
                break;
        }
@@ -2461,7 +2454,7 @@ API int pkgmgr_client_usr_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr
                strncat(args, temp, strlen(temp));
                g_free(temp);
        }
-       _LOGD("[args] %s [len] %d\n", args, len);
+       DBG("[args] %s [len] %d\n", args, len);
 
        /* get cookie from security-server */
        cookie = __get_cookie_from_security_server();
@@ -2470,7 +2463,7 @@ API int pkgmgr_client_usr_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr
        /* request */
        ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
        if (ret < 0)
-               _LOGE("comm_client_request failed, ret=%d\n", ret);
+               ERR("comm_client_request failed, ret=%d\n", ret);
 
 catch:
        for (i = 0; i < argcnt; i++)
@@ -2547,7 +2540,7 @@ API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data, uid_t uid)
 
        iter_data *udata = calloc(1, sizeof(iter_data));
        if (udata == NULL) {
-               _LOGE("calloc failed");
+               ERR("calloc failed");
                ail_filter_destroy(filter);
 
                return PKGMGR_R_ERROR;
@@ -2595,20 +2588,20 @@ API pkgmgr_info *pkgmgr_info_usr_new(const char *pkg_type, const char *pkgid, ui
 
        pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
        if (pkg_detail_info == NULL) {
-               _LOGE("*** Failed to alloc package_handler_info.\n");
+               ERR("*** Failed to alloc package_handler_info.\n");
                return NULL;
        }
 
        plugin_set = _package_manager_load_library(pkgtype);
        if (plugin_set == NULL) {
-               _LOGE("*** Failed to load library");
+               ERR("*** Failed to load library");
                free(pkg_detail_info);
                return NULL;
        }
 
        if (plugin_set->pkg_is_installed) {
                if (plugin_set->pkg_is_installed(pkgid) != 0) {
-                       _LOGE("*** Failed to call pkg_is_installed()");
+                       ERR("*** Failed to call pkg_is_installed()");
                        free(pkg_detail_info);
                        return NULL;
                }
@@ -2616,7 +2609,7 @@ API pkgmgr_info *pkgmgr_info_usr_new(const char *pkg_type, const char *pkgid, ui
                if (plugin_set->get_pkg_detail_info) {
                        if (plugin_set->get_pkg_detail_info(pkgid,
                                                            pkg_detail_info) != 0) {
-                               _LOGE("*** Failed to call get_pkg_detail_info()");
+                               ERR("*** Failed to call get_pkg_detail_info()");
                                free(pkg_detail_info);
                                return NULL;
                        }
@@ -2647,19 +2640,19 @@ API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type,
        package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
        char *pkgtype;
        if (pkg_path == NULL) {
-               _LOGE("pkg_path is NULL\n");
+               ERR("pkg_path is NULL\n");
                return NULL;
        }
 
        if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) {
-               _LOGE("length of pkg_path is too long - %d.\n",
+               ERR("length of pkg_path is too long - %d.\n",
                      strlen(pkg_path));
                return NULL;
        }
 
        pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
        if (pkg_detail_info == NULL) {
-               _LOGE("*** Failed to alloc package_handler_info.\n");
+               ERR("*** Failed to alloc package_handler_info.\n");
                return NULL;
        }
 
index 4d5f8a7..b5cce80 100644 (file)
@@ -29,6 +29,7 @@
 #include "comm_pkg_mgr_client_dbus_bindings.h"
 #include "comm_status_broadcast_client_dbus_bindings.h"
 #include "comm_status_broadcast_signal_marshaller.h"
+#include "comm_debug.h"
 #include <stdlib.h>
 #include <string.h>
 
@@ -104,23 +105,23 @@ status_signal_handler(DBusGProxy *proxy,
 {
        comm_client *cc = (comm_client *) data;
 
-       dbg("Got signal: %s/%s/%s/%s/%s", req_id, pkg_type,
+       DBG("Got signal: %s/%s/%s/%s/%s", req_id, pkg_type,
                                 pkgid, key, val);
        if (cc->signal_cb) {
                if (cc->pkgid && pkgid &&
                        0 == strncmp(cc->pkgid, pkgid,
                                     strlen(cc->pkgid))) {
-                       dbg("Run signal handler");
+                       DBG("Run signal handler");
                        cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
                                      pkgid, key, val);
                } else {
-                       dbg("pkgid is different. (My pkgid:%s)"
+                       DBG("pkgid is different. (My pkgid:%s)"
                        " Though pass signal to user callback.", cc->pkgid);
                        cc->signal_cb(cc->signal_cb_data, req_id, pkg_type,
                                      pkgid, key, val);
                }
        } else {
-               dbg("No signal handler is set. Do nothing.");
+               DBG("No signal handler is set. Do nothing.");
        }
 }
 
@@ -132,7 +133,7 @@ comm_client_request(comm_client *cc, const char *req_id, const int req_type,
        gboolean r;
        gint ret = COMM_RET_ERROR;
 
-       dbg("got request:%s/%d/%s/%s/%s/%s\n", req_id, req_type, pkg_type,
+       DBG("got request:%s/%d/%s/%s/%s/%s\n", req_id, req_type, pkg_type,
            pkgid, args, cookie);
 
        if (!pkgid)
@@ -152,16 +153,16 @@ comm_client_request(comm_client *cc, const char *req_id, const int req_type,
                }
                return ret;
        }
-       dbg("request sent");
+       DBG("request sent");
 
        if (cc->pkgid) {
-               dbg("freeing pkgid");
+               DBG("freeing pkgid");
                free(cc->pkgid);
-               dbg("freed pkgid");
+               DBG("freed pkgid");
        }
        cc->pkgid = strdup(pkgid);
 
-       dbg("ret:%d", ret);
+       DBG("ret:%d", ret);
 
        return ret;
 }
@@ -171,7 +172,7 @@ comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
 {
        /* set callback */
        if (!cc->signal_proxy) {
-               dbg("signal_proxy is NULL. Try to create a proxy for signal.");
+               DBG("signal_proxy is NULL. Try to create a proxy for signal.");
                cc->signal_proxy = dbus_g_proxy_new_for_name(cc->conn,
                                     COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX,
                                     COMM_STATUS_BROADCAST_DBUS_PATH,
@@ -188,7 +189,7 @@ comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
        cc->signal_cb = cb;
        cc->signal_cb_data = cb_data;
 
-       dbg("Register signal-type marshaller.");
+       DBG("Register signal-type marshaller.");
        dbus_g_object_register_marshaller(
        g_cclosure_user_marshal_VOID__STRING_STRING_STRING_STRING_STRING,
                /* marshaller */
@@ -196,7 +197,7 @@ comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
        G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
        G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);  /* termination flag */
 
-       dbg("Add signal to proxy.");
+       DBG("Add signal to proxy.");
        dbus_g_proxy_add_signal(cc->signal_proxy,
                                COMM_STATUS_BROADCAST_SIGNAL_STATUS,
                                G_TYPE_STRING,
@@ -204,7 +205,7 @@ comm_client_set_status_callback(comm_client *cc, status_cb cb, void *cb_data)
                                G_TYPE_STRING,
                                G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
 
-       dbg("Connect signal to proxy.");
+       DBG("Connect signal to proxy.");
 
        dbus_g_proxy_connect_signal(cc->signal_proxy,
                                    COMM_STATUS_BROADCAST_SIGNAL_STATUS,
index de3944b..3633950 100755 (executable)
@@ -34,6 +34,7 @@
 #include "comm_config.h"
 #include "comm_client.h"
 #include "comm_pkg_mgr_client_gdbus_generated.h"
+#include "comm_debug.h"
 
 /*******************
  * ADT description
@@ -139,7 +140,7 @@ void _on_signal_handle_filter(GDBusConnection *conn,
                strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE) &&
                strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE) &&
                strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE)) {
-               dbg("Interface name did not match. Drop the message");
+               DBG("Interface name did not match. Drop the message");
                return;
        }
        if (signal_name && strcmp(signal_name, COMM_STATUS_BROADCAST_SIGNAL_STATUS) &&
@@ -148,7 +149,7 @@ void _on_signal_handle_filter(GDBusConnection *conn,
                strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UPGRADE) &&
                strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_MOVE) &&
                strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS)) {
-               dbg("Signal name did not match. Drop the message");
+               DBG("Signal name did not match. Drop the message");
                return;
        }
        /* Values to be received by signal */
@@ -175,9 +176,9 @@ void _on_signal_handle_filter(GDBusConnection *conn,
        if (sig_cb_data && sig_cb_data->cb) {
                sig_cb_data->cb(sig_cb_data->cb_data, req_id,
                                pkg_type, pkgid, key, val);
-               dbg("callback function is end");
+               DBG("callback function is end");
        }
-       dbg("Handled signal. Exit function");
+       DBG("Handled signal. Exit function");
        return;
 }
 
index 6fa50a9..50ef0df 100644 (file)
  *
  */
 
-
-
-
-
 #ifndef __COMM_CONFIG_H__
 #define __COMM_CONFIG_H__
 
 #define API __attribute__ ((visibility("default")))
 #endif
 
-/* Debug message macro */
-#define USE_DLOG 1             /* Use dlog! */
-
-#ifndef NDEBUG
-#ifdef USE_DLOG
-#undef LOG_TAG
-#ifndef LOG_TAG
-#define LOG_TAG "PKGMGR"
-#endif                         /* LOG_TAG */
-#include <dlog.h>
-
-#define dbg(fmt, arg...) LOGD(fmt, ##arg)
-#define ERR(fmt, arg...) LOGE(fmt, ##arg)
-
-#else
-#include <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
-#define dbg(fmtstr, args...) \
-       do {
-               fprintf(stdout, "[%d:comm]%s:%d:%s(): " \
-               fmtstr "\n", getpid(),\
-               basename(__FILE__), __LINE__, __func__, ##args);\
-       } while (0)
-
-#define ERR(fmtstr, args...) \
-       do {
-               fprintf(stderr, "[%d:comm]%s:%d:%s(): " \
-               fmtstr "\n", getpid(),\
-               basename(__FILE__), __LINE__, __func__, ##args);\
-       } while (0)
-#endif                         /* USE_DLOG */
-#else
-#define dbg(fmtstr, args...)
-#endif
-
 /* from comm_pkg_mgr.xml
  */
 #define COMM_PKG_MGR_DBUS_SERVICE "org.tizen.slp.pkgmgr"
diff --git a/comm/comm_debug.h b/comm/comm_debug.h
new file mode 100644 (file)
index 0000000..f669daf
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * 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 __COMM_DEBUG_H__
+#define __COMM_DEBUG_H__
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif /* LOG_TAG */
+#define LOG_TAG "PKGMGR"
+
+#include "package-manager-debug.h"
+
+#endif /* __COMM_DEBUG_H__ */
index 61dbd08..8359f4b 100644 (file)
@@ -31,6 +31,7 @@
 #include <unistd.h>
 
 #include "comm_pkg_mgr_server.h"
+#include "comm_debug.h"
 
 /* object class def: do nothing on this */
 struct PkgMgrObjectClass {
@@ -85,7 +86,7 @@ static void pkg_mgr_object_init(PkgMgrObject *obj);
 static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass);
 static void pkg_mgr_object_init(PkgMgrObject *obj)
 {
-       dbg("called");
+       DBG("called");
        g_assert(NULL != obj);
 
        GError *err = NULL;
@@ -93,7 +94,7 @@ static void pkg_mgr_object_init(PkgMgrObject *obj)
        /* Establish dbus session  */
        obj->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
        if (NULL == obj->bus) {
-               dbg("Failed to open connection to dbus: %s", err->message);
+               DBG("Failed to open connection to dbus: %s", err->message);
                return;
        }
 
@@ -103,7 +104,7 @@ static void pkg_mgr_object_init(PkgMgrObject *obj)
                                          DBUS_SERVICE_DBUS,
                                          DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
        if (NULL == proxy) {
-               dbg("Failed to get a proxy");
+               DBG("Failed to get a proxy");
                return;
        }
        /* Register service name
@@ -122,28 +123,28 @@ static void pkg_mgr_object_init(PkgMgrObject *obj)
                g_printerr("dbus RequestName RPC failed %s %d", err->message, TRUE);
                return;
        }
-       dbg("RequestName returns: %d", result);
+       DBG("RequestName returns: %d", result);
 
        dbus_g_connection_register_g_object(obj->bus,
                                            COMM_PKG_MGR_DBUS_PATH,
                                            G_OBJECT(obj));
-       dbg("Ready to serve requests");
+       DBG("Ready to serve requests");
 
        g_object_unref(proxy);
 
-       dbg("done");
+       DBG("done");
 }
 
 static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass)
 {
-       dbg("called");
+       DBG("called");
 
        g_assert(NULL != klass);
 
        dbus_g_object_type_install_info(PKG_MGR_TYPE_OBJECT,
                                        &dbus_glib_pkgmgr_object_info);
 
-       dbg("done");
+       DBG("done");
 }
 
 static void pkg_mgr_object_finalize(GObject *self)
@@ -167,7 +168,7 @@ pkgmgr_request(PkgMgrObject *obj,
               const gchar *args,
               const gchar *cookie, uid_t uid, gint *ret, GError *err)
 {
-       dbg("Called");
+       DBG("Called");
        *ret = COMM_RET_OK;     /* TODO: fix this! */
 
        /* TODO: Add business logic 
@@ -175,12 +176,12 @@ pkgmgr_request(PkgMgrObject *obj,
         * */
 
        if (obj->req_cb) {
-               dbg("Call request callback(obj, %lu, %s, %d, %s, %s, %s, *ret)",
+               DBG("Call request callback(obj, %lu, %s, %d, %s, %s, %s, *ret)",
                    uid, req_id, req_type, pkg_type, pkgid, args);
                obj->req_cb(obj->req_cb_data, uid, req_id, req_type, pkg_type,
                            pkgid, args, cookie, ret);
        } else {
-               dbg("Attempt to call request callback,"
+               DBG("Attempt to call request callback,"
                " but request callback is not set. Do nothing.\n"
                "Use pkg_mgr_set_request_callback()"
                " to register your callback.");
index 22aa7d2..7e1acab 100644 (file)
@@ -30,6 +30,7 @@
 #include <dbus/dbus.h>
 
 #include "comm_status_broadcast_server.h"
+#include "comm_debug.h"
 
 /***************************
  * dbus-glib API for server
@@ -89,7 +90,7 @@ static void __status_broadcast_object_finalize(GObject *self);
 static void
 __status_broadcast_object_class_init(StatusBroadcastObjectClass *klass)
 {
-       dbg("called");
+       DBG("called");
 
        g_assert(NULL != klass);
 
@@ -108,12 +109,12 @@ __status_broadcast_object_class_init(StatusBroadcastObjectClass *klass)
        dbus_g_object_type_install_info(STATUS_BROADCAST_TYPE_OBJECT,
                                &dbus_glib_status_broadcast_object_info);
 
-       dbg("done");
+       DBG("done");
 }
 
 static void __status_broadcast_object_init(StatusBroadcastObject *obj)
 {
-       dbg("called");
+       DBG("called");
        g_assert(NULL != obj);
 
        GError *err = NULL;
@@ -121,7 +122,7 @@ static void __status_broadcast_object_init(StatusBroadcastObject *obj)
        /* Establish dbus session  */
        obj->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
        if (NULL == obj->bus) {
-               dbg("Failed to open connection to dbus: %s", err->message);
+               DBG("Failed to open connection to dbus: %s", err->message);
                return;
        }
 
@@ -131,7 +132,7 @@ static void __status_broadcast_object_init(StatusBroadcastObject *obj)
                                          DBUS_SERVICE_DBUS,
                                          DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
        if (NULL == proxy) {
-               dbg("Failed to get a proxy");
+               DBG("Failed to get a proxy");
                return;
        }
        /* Register service name
@@ -151,16 +152,16 @@ static void __status_broadcast_object_init(StatusBroadcastObject *obj)
                g_printerr("dbus RequestName RPC failed", err->message, TRUE);
                return;
        }
-       dbg("RequestName returns: %d", result);
+       DBG("RequestName returns: %d", result);
 
        dbus_g_connection_register_g_object(obj->bus,
                                            COMM_STATUS_BROADCAST_DBUS_PATH,
                                            G_OBJECT(obj));
-       dbg("Ready to serve requests");
+       DBG("Ready to serve requests");
 
        g_object_unref(proxy);
 
-       dbg("done");
+       DBG("done");
 }
 
 static void __status_broadcast_object_finalize(GObject *self)
@@ -183,7 +184,7 @@ status_broadcast_emit_status(StatusBroadcastObject *obj,
        StatusBroadcastObjectClass *klass;
        klass = STATUS_BROADCAST_OBJECT_GET_CLASS(obj);
 
-       dbg("Send signal: %s/%s/%s", pkg, key, val);
+       DBG("Send signal: %s/%s/%s", pkg, key, val);
        g_signal_emit(obj, klass->signal, 0, pkg, key, val);
 
 }
index 17a4c6b..408f674 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "comm_config.h"
 #include "comm_status_broadcast_server.h"
+#include "comm_debug.h"
 #include <dbus/dbus.h>
 
 /********************************************
@@ -180,18 +181,18 @@ API DBusConnection *comm_status_broadcast_server_connect(int status_type)
 
        conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
        if (dbus_error_is_set(&err)) {
-               dbg("Connection error: %s", err.message);
+               DBG("Connection error: %s", err.message);
                dbus_error_free(&err);
        }
        dbus_error_free(&err);
        if (NULL == conn) {
-               dbg("conn is NULL");
+               DBG("conn is NULL");
                return NULL;
        }
 
        dbus_bus_request_name(conn, __get_prifix(status_type), DBUS_NAME_FLAG_ALLOW_REPLACEMENT, &err);
        if (dbus_error_is_set(&err)) {
-               dbg("Failed to request name: %s", err.message);
+               DBG("Failed to request name: %s", err.message);
                dbus_error_free(&err);
                return NULL;
        }
@@ -220,13 +221,13 @@ comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *c
        int i;
 
        if (conn == NULL) {
-               dbg("dbus conn is NULL");
+               DBG("dbus conn is NULL");
                return;
        }
 
        msg = dbus_message_new_signal(__get_path(comm_status_type), __get_interface(comm_status_type), __get_name(comm_status_type));
        if (NULL == msg) {
-               dbg("msg NULL");
+               DBG("msg NULL");
                return;
        }
 
@@ -235,13 +236,13 @@ comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *c
        for (i = 0; i < 5; i++) {
                if (!dbus_message_iter_append_basic
                    (&args, DBUS_TYPE_STRING, &(values[i]))) {
-                       dbg("dbus_message_iter_append_basic failed:"
+                       DBG("dbus_message_iter_append_basic failed:"
                        " Out of memory");
                        return;
                }
        }
        if (!dbus_connection_send(conn, msg, &serial)) {
-               dbg("dbus_connection_send failed: Out of memory");
+               DBG("dbus_connection_send failed: Out of memory");
                return;
        }
        dbus_connection_flush(conn);
index 20217d3..4e0f9f9 100644 (file)
 #include "comm_config.h"
 #include "comm_socket.h"
 #include "comm_status_broadcast_server.h"
+#include "comm_debug.h"
 #include "error_report.h"
 
 #include <db-util.h>
 #include <pkgmgr-info.h>
 
-
 #undef LOG_TAG
 #ifndef LOG_TAG
 #define LOG_TAG "PKGMGR_INSTALLER"
-#endif                         /* LOG_TAG */
+#endif /* LOG_TAG */
 
 #define MAX_STRLEN 1024
 #define MAX_QUERY_LEN  4096
diff --git a/include/package-manager-debug.h b/include/package-manager-debug.h
new file mode 100644 (file)
index 0000000..b61b00d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * slp-pkgmgr
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+  * Contact: junsuk. oh <junsuk77.oh@samsung.com>
+ *
+ * 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 __PKG_MANAGER_DEBUG_H__
+#define __PKG_MANAGER_DEBUG_H__
+
+#include <dlog.h>
+
+#ifndef ERR
+#define ERR(fmt, args...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef DBG
+#define DBG(fmt, args...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef INFO
+#define INFO(fmt, args...) LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#endif  /* __PKG_MANAGER_DEBUG_H__ */
index dae1f27..234ae80 100644 (file)
  *
  */
 
-
-
-
-
 #ifndef _PKGMGR_SERVER_H_
 #define _PKGMGR_SERVER_H_
 
-#define CONF_FILE      "/etc/package-manager/server/.config"
-#define DESKTOP_FILE_DIRS      "/usr/share/install-info/desktop.conf"
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif /* LOG_TAG */
+#define LOG_TAG "PKGMGR_SERVER"
+#include "package-manager-debug.h"
+
+#define CONF_FILE "/etc/package-manager/server/.config"
+#define DESKTOP_FILE_DIRS "/usr/share/install-info/desktop.conf"
 
-#define PKG_BACKEND    "backend:"
-#define PKG_CONF_PATH  "/etc/package-manager/pkg_path.conf"
+#define PKG_BACKEND "backend:"
+#define PKG_CONF_PATH "/etc/package-manager/pkg_path.conf"
 
-#define MAX_REQ_ID_LEN         256
-#define MAX_PKG_TYPE_LEN       128
-#define MAX_PKG_NAME_LEN       256
-#define MAX_PKG_ARGS_LEN       4096
-#define MAX_COOKIE_LEN         32
-#define DESKTOP_FILE_DIRS_NUM          1024
+#define MAX_REQ_ID_LEN 256
+#define MAX_PKG_TYPE_LEN 128
+#define MAX_PKG_NAME_LEN 256
+#define MAX_PKG_ARGS_LEN 4096
+#define MAX_COOKIE_LEN  32
+#define DESKTOP_FILE_DIRS_NUM 1024
 
 typedef struct {
        char req_id[MAX_REQ_ID_LEN];
@@ -55,7 +57,7 @@ typedef struct backend_info_t {
        char pkgtype[MAX_PKG_TYPE_LEN];
        char pkgid[MAX_PKG_NAME_LEN];
        char args[MAX_PKG_ARGS_LEN];
-}backend_info;
+} backend_info;
 
 struct pm_inotify_paths_t {
        int wd;
@@ -68,4 +70,4 @@ void _pm_desktop_file_monitor_init();
 void _pm_desktop_file_monitor_fini();
 int _pm_desktop_file_dir_search(pm_inotify_paths *paths, int number);
 
-#endif                         /*  _PKGMGR_SERVER_H_ */
+#endif/*  _PKGMGR_SERVER_H_ */
index ec28a7d..8e2d50d 100644 (file)
 #include "pm-queue.h"
 #include "comm_config.h"
 
-/* debug output */
-#if defined(NDEBUG)
-#define DBG(fmt, args...)
-#define __SET_DBG_OUTPUT(fp)
-#elif defined(PRINT)
-#include <stdio.h>
-FILE *___log = NULL;
-#define DBG(fmt, args...) \
-       {if (!___log) ___log = stderr; \
-        fprintf(___log, "[DBG:PMS]%s:%d:%s(): " fmt "\n",\
-        basename(__FILE__), __LINE__, __func__, ##args); fflush(___log); }
-#define __SET_DBG_OUTPUT(fp) \
-       (___log = fp)
-#else
-#include <dlog.h>
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_SERVER"
-
-#define DBGE(fmt, arg...) LOGE(fmt,##arg)
-#define DBG(fmt, arg...) LOGD(fmt,##arg)
-#endif
-
-#if !defined(PACKAGE)
-#define PACKAGE "package-manager"
-#endif
-
-#if !defined(LOCALEDIR)
-#define LOCALEDIR "/usr/share/locale"
-#endif
-
 #define PACKAGE_RECOVERY_DIR tzplatform_mkpath(TZ_SYS_RW_PACKAGES, ".recovery/pkgmgr")
-
-#define DESKTOP_W   720.0
-
 #define NO_MATCHING_FILE 11
 
 static int backend_flag = 0;   /* 0 means that backend process is not running */
@@ -535,27 +502,27 @@ static char *__get_exe_path(const char *pkgid)
 
        ret = ail_package_get_appinfo(pkgid, &handle);
        if (ret != AIL_ERROR_OK) {
-               DBGE("ail_package_get_appinfo() failed");
+               ERR("ail_package_get_appinfo() failed");
                return NULL;
        }
 
        ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_EXE_PATH, &str);
        if (ret != AIL_ERROR_OK) {
-               DBGE("ail_appinfo_get_str() failed");
+               ERR("ail_appinfo_get_str() failed");
                ail_package_destroy_appinfo(handle);
                return NULL;
        }
 
        exe_path = strdup(str);
        if (exe_path == NULL) {
-               DBGE("strdup() failed");
+               ERR("strdup() failed");
                ail_package_destroy_appinfo(handle);
                return NULL;
        }
 
        ret = ail_package_destroy_appinfo(handle);
        if (ret != AIL_ERROR_OK) {
-               DBGE("ail_package_destroy_appinfo() failed");
+               ERR("ail_package_destroy_appinfo() failed");
                free(exe_path);
                return NULL;
        }
@@ -1623,7 +1590,7 @@ pop:
                                                DBG("activated label %s", label);
                                                break;
                                        default: /* '?' */
-                                               DBGE("Incorrect argument %s\n", item->args);
+                                               ERR("Incorrect argument %s\n", item->args);
                                                exit(1);
                                        }
                                }
@@ -1661,14 +1628,14 @@ pop:
                                        exit(1);
                                }
                        } else { /* in case of package */
-                               DBGE("(De)activate PKG[pkgid=%s, val=%d]", item->pkgid, val);
+                               ERR("(De)activate PKG[pkgid=%s, val=%d]", item->pkgid, val);
                                char *manifest = NULL;
                                manifest = pkgmgr_parser_get_manifest_file(item->pkgid);
                                if (manifest == NULL) {
-                                       DBGE("Failed to fetch package manifest file\n");
+                                       ERR("Failed to fetch package manifest file\n");
                                        exit(1);
                                }
-                               DBGE("manifest : %s\n", manifest);
+                               ERR("manifest : %s\n", manifest);
 
                                if (val) {
                                        pkgmgrinfo_pkginfo_h handle;
@@ -1676,12 +1643,12 @@ pop:
                                        if (ret < 0) {
                                                ret = pkgmgr_parser_parse_usr_manifest_for_installation(manifest,item->uid, NULL);
                                                if (ret < 0) {
-                                                       DBGE("insert in db failed\n");
+                                                       ERR("insert in db failed\n");
                                                }
 
                                                ret = ail_usr_desktop_add(item->pkgid, item->uid);
                                                if (ret != AIL_ERROR_OK) {
-                                                       DBGE("fail to ail_desktop_add");
+                                                       ERR("fail to ail_desktop_add");
                                                }
                                        } else {
                                                pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
@@ -1706,7 +1673,7 @@ pop:
                                        ret = pkgmgr_parser_parse_usr_manifest_for_uninstallation(manifest, item->uid, NULL);
 
                                if (ret < 0) {
-                                       DBGE("insert in db failed\n");
+                                       ERR("insert in db failed\n");
                                        exit(1);
                                }
                        }
index 3880fd5..901999a 100644 (file)
  *
  */
 
-
-
-
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -248,14 +244,14 @@ int _pm_queue_init()
 
 #ifdef DEBUG_INFO
        /*Debug info*/
-       printf("Queue Info Map\n");
-       printf("Number of Backends is %d\n", num_of_backends);
-       printf("Number of Entries is %d\n", entries);
-       printf("Backend\tType\tSlot\tHead\n");
+       DBG("Queue Info Map");
+       DBG("Number of Backends is %d", num_of_backends);
+       DBG("Number of Entries is %d", entries);
+       DBG("Backend\tType\tSlot\tHead");
        ptr = start;
        for(n = 0; n < entries; n++)
        {
-               printf("%s\t%s\t%d\t%p\n", ptr->backend, ptr->pkgtype, ptr->queue_slot, ptr->head);
+               DBG("%s\t%s\t%d\t%p", ptr->backend, ptr->pkgtype, ptr->queue_slot, ptr->head);
                ptr++;
        }
 #endif
@@ -278,8 +274,8 @@ int _pm_queue_push(pm_dbus_msg *item)
        tmp = cur;
 
        data = _add_node();
-       if (!data) {            /* fail to allocate mem */
-               fprintf(stderr, "Fail to allocate memory\n");
+       if (!data) { /* fail to allocate mem */
+               ERR("Fail to allocate memory\n");
                pthread_mutex_unlock(&pm_mutex);
                return -1;
        }
@@ -320,7 +316,7 @@ pm_dbus_msg *_pm_queue_pop(int position)
 
        ret = (pm_dbus_msg *) malloc(sizeof(pm_dbus_msg));
        if (!ret) {
-               fprintf(stderr, "Mem alloc error\n");
+               ERR("Mem alloc error");
                return NULL;
        }
        memset(ret, 0x00, sizeof(pm_dbus_msg));
@@ -400,8 +396,8 @@ void _pm_queue_final()
 
        c = 0;
        while(c < num_of_backends) {
-               if (!head[c]) {         /* in case of head is NULL */
-                       fprintf(stderr, "queue is NULL\n");
+               if (!head[c]) { /* in case of head is NULL */
+                       ERR("queue is NULL");
                        c = c + 1;
                        continue;
                }
@@ -439,15 +435,15 @@ pm_queue_data *_add_node()
        pm_queue_data *newnode = NULL;
 
        newnode = (pm_queue_data *) malloc(sizeof(pm_queue_data));
-       if (!newnode) {         /* if NULL */
-               fprintf(stderr, "Mem alloc error\n");
+       if (!newnode) { /* if NULL */
+               ERR("Mem alloc error");
                return NULL;
        }
        memset(newnode, 0x00, sizeof(pm_queue_data));
 
        newnode->msg = (pm_dbus_msg *) malloc(sizeof(pm_dbus_msg));
        if (!newnode->msg) {
-               fprintf(stderr, "Mem alloc error\n");
+               ERR("Mem alloc error");
                free(newnode);
                return NULL;
        }
@@ -483,7 +479,7 @@ void _save_queue_status(pm_dbus_msg *item, char *status)
 
        fp_status = fopen(STATUS_FILE, "w");    /* overwrite always */
        if (!fp_status) {
-               fprintf(stderr, "Can't open status file:%s\n", STATUS_FILE);
+               ERR("Can't open status file:%s", STATUS_FILE);
                return;
        }
 
index 75c31f4..7d9be41 100644 (file)
 #include "package-manager.h"
 #include "pkgmgr_installer.h"
 
-#undef LOG_TAG
-#ifndef LOG_TAG
-#define LOG_TAG "PKGMGR"
-#endif                         /* LOG_TAG */
 
 #define MAX_PKG_BUF_LEN        1024
 #define BLOCK_SIZE      4096 /*in bytes*/
@@ -64,7 +60,7 @@ long long __get_dir_size(int dfd)
 
     dir = fdopendir(dfd);
     if (dir == NULL) {
-       _LOGE("Couldn't open the directory\n");
+       ERR("Couldn't open the directory\n");
        close(dfd);
         return 0;
     }
@@ -102,7 +98,7 @@ long long __get_pkg_size(char *path)
        int dfd;
        struct stat f_stat;
        if (path == NULL){
-               _LOGE("path is NULL");
+               ERR("path is NULL");
                return -1;
        }
 
@@ -110,7 +106,7 @@ long long __get_pkg_size(char *path)
                if (!S_ISLNK(f_stat.st_mode)) {
                        dir = opendir(path);
                        if (dir == NULL) {
-                               _LOGE("Couldn't open the directory %s \n", path);
+                               ERR("Couldn't open the directory %s \n", path);
                                return -1;
                        }
                        dfd = dirfd(dir);
@@ -120,13 +116,13 @@ long long __get_pkg_size(char *path)
                                 size = size + f_stat.st_blocks * 512;
                        }
                        else {
-                               _LOGE("Couldn't open the directory\n");
+                               ERR("Couldn't open the directory\n");
                                return -1;
                        }
                }
        }
        else {
-               _LOGE("Couldn't lstat the directory %s %d \n", path, errno);
+               ERR("Couldn't lstat the directory %s %d \n", path, errno);
                return -1;
        }
 
@@ -244,7 +240,7 @@ static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *user_data)
 
        * (int *) user_data += size;
 
-       _LOGD("pkg=[%s], size=[%d]\n", pkgid, size);
+       DBG("pkg=[%s], size=[%d]\n", pkgid, size);
 
        return 0;
 }
@@ -269,13 +265,13 @@ int main(int argc, char *argv[])
                ret = pkgmgrinfo_pkginfo_get_list(__pkg_list_cb, &size);
        }
        if (ret < 0)
-               _LOGD("_pkg_getsize fail \n");
+               DBG("_pkg_getsize fail \n");
        else
-               _LOGD("_pkg_getsize success \n");
+               DBG("_pkg_getsize success \n");
 
        pi = pkgmgr_installer_new();
        if (!pi) {
-               _LOGD("Failure in creating the pkgmgr_installer object");
+               DBG("Failure in creating the pkgmgr_installer object");
        } else {
                pkgmgr_installer_receive_request(pi, argc, argv);
                snprintf(buf, MAX_PKG_BUF_LEN - 1, "%d", size);