Logging system & notification service updated.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 28 May 2013 00:40:41 +0000 (09:40 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 28 May 2013 00:40:41 +0000 (09:40 +0900)
[model] Tizen
[binary_type] AP
[customer] Tizen Developers
[issue#] N/A
[problem] N/A
[cause] N/A
[solution] Update logging system & notification service routine
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: Ief2ed01ba038f3e28868064dd3544094a47fc231

src/critical_log.c
src/notification_service.c

index 3b6059c..7469013 100644 (file)
@@ -57,10 +57,10 @@ static inline void rotate_log(void)
 
        s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE;
 
-       namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 20;
+       namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 30;
        filename = malloc(namelen);
        if (filename) {
-               snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, s_info.filename);
+               snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, s_info.filename, getpid());
 
                if (s_info.fp)
                        fclose(s_info.fp);
@@ -81,18 +81,11 @@ HAPI int critical_log(const char *func, int line, const char *fmt, ...)
 {
        va_list ap;
        int ret;
-       struct timeval tv;
 
        if (!s_info.fp)
                return LB_STATUS_ERROR_IO;
 
-       if (gettimeofday(&tv, NULL) < 0) {
-               ErrPrint("gettimeofday: %s\n", strerror(errno));
-               tv.tv_sec = 0;
-               tv.tv_usec = 0;
-       }
-
-       fprintf(s_info.fp, "%d %lu.%lu [%s:%d] ", getpid(), tv.tv_sec, tv.tv_usec, util_basename((char *)func), line);
+       fprintf(s_info.fp, "%lf [%s:%d] ", util_timestamp(), util_basename((char *)func), line);
 
        va_start(ap, fmt);
        ret = vfprintf(s_info.fp, fmt, ap);
@@ -121,7 +114,7 @@ HAPI int critical_log_init(const char *name)
                return LB_STATUS_ERROR_MEMORY;
        }
 
-       namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 20;
+       namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 30;
 
        filename = malloc(namelen);
        if (!filename) {
@@ -131,7 +124,7 @@ HAPI int critical_log_init(const char *name)
                return LB_STATUS_ERROR_MEMORY;
        }
 
-       snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, name);
+       snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, name, getpid());
 
        s_info.fp = fopen(filename, "w+");
        if (!s_info.fp) {
index 11fd207..06bf92e 100644 (file)
@@ -213,6 +213,7 @@ static void _handler_refresh(struct tcb *tcb, struct packet *packet, void *data)
 
 static void _handler_delete_single(struct tcb *tcb, struct packet *packet, void *data)
 {
+       int num_changes = 0;
        int ret = 0, ret_p = 0;
        int priv_id = 0;
        struct packet *packet_reply = NULL;
@@ -222,9 +223,9 @@ static void _handler_delete_single(struct tcb *tcb, struct packet *packet, void
        if (packet_get(packet, "si", &pkgname, &priv_id) == 2) {
                pkgname = get_string(pkgname);
 
-               ret = notification_noti_delete_by_priv_id(pkgname, priv_id);
+               ret = notification_noti_delete_by_priv_id_get_changes(pkgname, priv_id, &num_changes);
 
-               DbgPrint("priv_id: [%d]\n", priv_id);
+               DbgPrint("priv_id: [%d] num_delete:%d\n", priv_id, num_changes);
                packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
                if (packet_reply) {
                        if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
@@ -235,8 +236,8 @@ static void _handler_delete_single(struct tcb *tcb, struct packet *packet, void
                        ErrPrint("failed to create a reply packet\n");
                }
 
-               if (ret != NOTIFICATION_ERROR_NONE) {
-                       ErrPrint("failed to delete a notification:%d\n", ret);
+               if (ret != NOTIFICATION_ERROR_NONE && num_changes <= 0) {
+                       ErrPrint("failed to delete a notification:%d %d\n", ret, num_changes);
                        return ;
                }