Remove critical log feature 17/168217/2
authorSeungha Son <seungha.son@samsung.com>
Thu, 25 Jan 2018 05:25:24 +0000 (14:25 +0900)
committerSeungha Son <seungha.son@samsung.com>
Thu, 25 Jan 2018 06:23:24 +0000 (15:23 +0900)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I21a0ad7eee468c8950da66e34203b9ead152555a

CMakeLists.txt
include/critical_log.h [deleted file]
include/util.h [deleted file]
src/critical_log.c [deleted file]
src/main.c
src/pkgmgr.c
src/util.c [deleted file]

index 814a1c2..561fe97 100644 (file)
@@ -56,13 +56,11 @@ ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET")
 
 SET(BUILD_SOURCE
        src/main.c
-       src/util.c
        src/pkgmgr.c
        src/shortcut_service.c
        src/badge_service.c
        src/notification_service.c
        src/service_common.c
-       src/critical_log.c
 )
 
 STRING(REPLACE "-L-l" "-l" pkg_fixed_LDFLAGS ${pkg_LDFLAGS})
diff --git a/include/critical_log.h b/include/critical_log.h
deleted file mode 100755 (executable)
index 2742f10..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016  Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-extern int critical_log(const char *func, int line, const char *fmt, ...);
-extern int critical_log_init(const char *tag);
-extern void critical_log_fini(void);
-
-#define CRITICAL_LOG(args...) critical_log(__func__, __LINE__, args)
-
-/* End of a file */
diff --git a/include/util.h b/include/util.h
deleted file mode 100755 (executable)
index a4f1de8..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2016  Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-extern double util_timestamp(void);
-extern void util_setup_log_disk(void);
-extern const char *util_basename(const char *name);
-
-#define SCHEMA_FILE    "file://"
-#define SCHEMA_PIXMAP  "pixmap://"
-#define SCHEMA_SHM     "shm://"
-
-#define CRITICAL_SECTION_BEGIN(handle) \
-do { \
-       int ret; \
-       ret = pthread_mutex_lock(handle); \
-       if (ret != 0) \
-               ERR("pthread_mutex_lock: %d", ret); \
-} while (0)
-
-#define CRITICAL_SECTION_END(handle) \
-do { \
-       int ret; \
-       ret = pthread_mutex_unlock(handle); \
-       if (ret != 0) \
-               ERR("pthread_mutex_unlock: %d", ret); \
-} while (0)
-
-#define CANCEL_SECTION_BEGIN() do { \
-       int ret; \
-       ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); \
-       if (ret != 0) \
-               ERR("Unable to set cancelate state: %d", ret); \
-} while (0)
-
-#define CANCEL_SECTION_END() do { \
-       int ret; \
-       ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); \
-       if (ret != 0) \
-               ERR("Unable to set cancelate state: %d", ret); \
-} while (0)
-
-#define CLOSE_PIPE(p)  do { \
-       int status; \
-       status = close(p[PIPE_READ]); \
-       if (status < 0) \
-               ERR("close: %d", errno); \
-       status = close(p[PIPE_WRITE]); \
-       if (status < 0) \
-               ERR("close: %d", errno); \
-} while (0)
-
-#define PIPE_READ 0
-#define PIPE_WRITE 1
-#define PIPE_MAX 2
-
-/* End of a file */
diff --git a/src/critical_log.c b/src/critical_log.c
deleted file mode 100755 (executable)
index dd61930..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2016  Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <string.h>
-#include <libgen.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include <dlog.h>
-#include <Eina.h>
-
-#include "conf.h"
-#include "debug.h"
-#include "util.h"
-#include "service_common.h"
-#include "critical_log.h"
-
-static struct {
-       FILE *fp;
-       int file_id;
-       int nr_of_lines;
-       char *filename;
-       pthread_mutex_t cri_lock;
-} s_info = {
-       .fp = NULL,
-       .file_id = 0,
-       .nr_of_lines = 0,
-       .filename = NULL,
-       .cri_lock = PTHREAD_MUTEX_INITIALIZER,
-};
-
-static inline void rotate_log(void)
-{
-       char *filename;
-       int namelen;
-
-       if (s_info.nr_of_lines < CONF_MAX_LOG_LINE)
-               return;
-
-       s_info.file_id = (s_info.file_id + 1) % CONF_MAX_LOG_FILE;
-
-       namelen = strlen(s_info.filename) + strlen(CONF_LOG_PATH) + 30;
-       filename = malloc(namelen);
-       if (filename) {
-               snprintf(filename, namelen, "%s/%d_%s.%d", CONF_LOG_PATH, s_info.file_id, s_info.filename, getpid());
-               if (s_info.fp) {
-                       if (fclose(s_info.fp) != 0)
-                               ERR("fclose [%d]", errno);
-               }
-
-               if (access(filename, F_OK) == 0)
-                       unlink(filename);
-
-               s_info.fp = fopen(filename, "w+x");
-               if (!s_info.fp)
-                       ERR("Failed to open a file [%s][%d]", filename, errno);
-
-               free(filename);
-       }
-
-       s_info.nr_of_lines = 0;
-}
-
-HAPI int critical_log(const char *func, int line, const char *fmt, ...)
-{
-       va_list ap;
-       int ret;
-
-       if (!s_info.fp)
-               return SERVICE_COMMON_ERROR_IO_ERROR;
-
-       CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
-
-       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);
-       va_end(ap);
-
-       fflush(s_info.fp);
-
-       s_info.nr_of_lines++;
-       rotate_log();
-
-       CRITICAL_SECTION_END(&s_info.cri_lock);
-       return ret;
-}
-
-HAPI int critical_log_init(const char *name)
-{
-       int namelen;
-       int ret = SERVICE_COMMON_ERROR_NONE;
-       char *filename;
-
-       if (s_info.fp)
-               return SERVICE_COMMON_ERROR_NONE;
-
-       s_info.filename = strdup(name);
-       if (!s_info.filename) {
-               ERR("Failed to create a log file");
-               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
-       }
-
-       namelen = strlen(name) + strlen(CONF_LOG_PATH) + 30;
-
-       filename = malloc(namelen);
-       if (!filename) {
-               ERR("Failed to create a log file");
-               ret = SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
-               goto out;
-       }
-
-       snprintf(filename, namelen, "%s/%d_%s.%d", CONF_LOG_PATH, s_info.file_id, name, getpid());
-
-       if (access(filename, F_OK) == 0)
-               unlink(filename);
-
-       s_info.fp = fopen(filename, "w+x");
-       if (!s_info.fp) {
-               ERR("fopen [%s][%d]", filename, errno);
-               ret = SERVICE_COMMON_ERROR_IO_ERROR;
-       }
-
-out:
-       if (s_info.filename) {
-               free(s_info.filename);
-               s_info.filename = NULL;
-       }
-
-       if (filename)
-               free(filename);
-
-       return ret;
-}
-
-HAPI void critical_log_fini(void)
-{
-       if (s_info.filename) {
-               free(s_info.filename);
-               s_info.filename = NULL;
-       }
-
-       if (s_info.fp) {
-               if (fclose(s_info.fp) != 0)
-                       ERR("fclose [%d]", errno);
-               s_info.fp = NULL;
-       }
-}
-
-/* End of a file */
index 715b25d..c9a8747 100755 (executable)
@@ -33,8 +33,6 @@
 #include <locale.h>
 
 #include "debug.h"
-#include "util.h"
-#include "critical_log.h"
 #include "service_common.h"
 #include "shortcut_service.h"
 #include "notification_service.h"
@@ -117,7 +115,6 @@ static gboolean __signal_handler(GIOChannel *channel,
        struct signalfd_siginfo fdsi;
        ssize_t size;
        int sfd;
-       int cfd;
 
        sfd = g_io_channel_unix_get_fd(channel);
 
@@ -128,13 +125,10 @@ static gboolean __signal_handler(GIOChannel *channel,
        }
 
        if (fdsi.ssi_signo == SIGTERM) {
-               CRITICAL_LOG("Terminated(SIGTERM)");
-               cfd = creat("/tmp/.stop.provider", 0644);
-               if (cfd < 0 || close(cfd) < 0)
-                       ERR("stop.provider [%d]", errno);
+               ERR("Terminated(SIGTERM)");
                g_main_loop_quit(main_loop);
        } else {
-               CRITICAL_LOG("Unknown SIG[%d] received", fdsi.ssi_signo);
+               ERR("Unknown SIG[%d] received", fdsi.ssi_signo);
        }
 
        return TRUE;
@@ -148,25 +142,25 @@ static int __init_signal_handler(void)
 
        ret = sigemptyset(&mask);
        if (ret < 0) {
-               CRITICAL_LOG("sigemptyset : %d", errno);
+               ERR("sigemptyset : %d", errno);
                return -1;
        }
 
        ret = sigaddset(&mask, SIGTERM);
        if (ret < 0) {
-               CRITICAL_LOG("sigaddset: %d", errno);
+               ERR("sigaddset: %d", errno);
                return -1;
        }
 
        ret = sigprocmask(SIG_BLOCK, &mask, NULL);
        if (ret < 0) {
-               CRITICAL_LOG("sigprocmask: %d", errno);
+               ERR("sigprocmask: %d", errno);
                return -1;
        }
 
        sfd = signalfd(-1, &mask, SFD_NONBLOCK);
        if (sfd < 0) {
-               CRITICAL_LOG("signalfd: %d", errno);
+               ERR("signalfd: %d", errno);
                return -1;
        }
 
@@ -190,12 +184,10 @@ void __finish(void)
                g_io_channel_unref(channel);
 
        app_terminate();
-       critical_log_fini();
 }
 
 int main(int argc, char *argv[])
 {
-       int ret;
        int restart_count = 0;
 
        main_loop = g_main_loop_new(NULL, FALSE);
@@ -207,15 +199,6 @@ int main(int argc, char *argv[])
 #endif
 
        vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
-       util_setup_log_disk();
-
-       /*!
-        * How could we care this return values?
-        * Is there any way to print something on the screen?
-        */
-       ret = critical_log_init(util_basename(argv[0]));
-       if (ret < 0)
-               ERR("Failed to init the critical log");
 
        app_create();
        sd_notify(0, "READY=1");
index 4f875ff..09f4495 100755 (executable)
@@ -23,7 +23,6 @@
 
 #include <Ecore.h>
 #include "service_common.h"
-#include "util.h"
 #include "debug.h"
 #include "pkgmgr.h"
 #include "conf.h"
diff --git a/src/util.c b/src/util.c
deleted file mode 100755 (executable)
index 6699523..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2016  Samsung Electronics Co., Ltd
- *
- * 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.
- */
-
-#include <stdio.h>
-#include <sys/time.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/vfs.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <sys/statvfs.h>
-#include <sys/mount.h>
-#include <strings.h>
-
-#include <sys/smack.h>
-#include <dlog.h>
-#include <Eina.h>
-#include <Ecore.h>
-
-#include "util.h"
-#include "debug.h"
-#include "conf.h"
-
-#define DELIM ';'
-
-int errno;
-
-HAPI double util_timestamp(void)
-{
-#if defined(_USE_ECORE_TIME_GET)
-       return ecore_time_get();
-#else
-       struct timeval tv;
-       if (gettimeofday(&tv, NULL) < 0) {
-               static unsigned long internal_count = 0;
-               ERR("gettimeofday [%d]", errno);
-               tv.tv_sec = internal_count++;
-               tv.tv_usec = 0;
-       }
-
-       return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
-#endif
-}
-
-HAPI void util_setup_log_disk(void)
-{
-       if (access(CONF_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
-               DBG("[%s] is already accessible", CONF_LOG_PATH);
-               return;
-       }
-
-       DBG("Initiate the critical log folder [%s]", CONF_LOG_PATH);
-       if (mkdir(CONF_LOG_PATH, 0755) < 0)
-               ERR("mkdir: %d", errno);
-}
-
-HAPI const char *util_basename(const char *name)
-{
-       int length;
-       length = name ? strlen(name) : 0;
-       if (!length)
-               return ".";
-
-       while (--length > 0 && name[length] != '/')
-               ;
-
-       return length <= 0 ? name : (name + length + (name[length] == '/'));
-}
-
-/* End of a file */