Support logger activation/deactivation
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 12 Jan 2021 06:05:23 +0000 (15:05 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 12 Jan 2021 23:32:32 +0000 (08:32 +0900)
After this patch is applied, a default value of the logger is "false".
To enable the logger, the platform developer should set "Enable=1" to
the launchpad.conf file.

Change-Id: I9308964b912f79fa2261f4ac0d83de122e78cd6b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launchpad-process-pool/conf/launchpad.conf.in
src/launchpad-process-pool/inc/launchpad_config.h
src/launchpad-process-pool/src/launchpad_config.c
src/launchpad-process-pool/src/launchpad_logger.c

index 44acf40b398ba1ab25208aa73d76abfe0a69e75b..0812a6488f24cbd537d7e59446004ee9407cbe0c 100644 (file)
@@ -13,3 +13,4 @@ MaxCount=10
 
 [Logger]
 Path=/run/aul/log
+Enable=1
index d38cae31a6aa740baf58bc2b91bfc3b77d69ae96..0f769dbaea83ce992941346d8eb5dbdb5e0dc201 100644 (file)
@@ -26,6 +26,7 @@ typedef enum {
        CONFIG_TYPE_MEMORY_MONITOR_INTERVAL,
        CONFIG_TYPE_CPU_CHECKER_MAX_COUNT,
        CONFIG_TYPE_LOGGER_PATH,
+       CONFIG_TYPE_LOGGER_ENABLE,
 } config_type_e;
 
 const char *_config_get_string_value(config_type_e type);
index f43bc1a0e94e1913cb8c62ea7470538693116f2e..90e42563f0255308fc24866ea875950a83f0ad2f 100644 (file)
@@ -45,6 +45,7 @@
 
 #define TAG_LOGGER                      "Logger"
 #define KEY_LOGGER_PATH                 "Path"
+#define KEY_LOGGER_ENABLE               "Enable"
 
 struct memory_status_s {
        char *low_key;
@@ -64,6 +65,7 @@ struct cpu_checker_s {
 
 struct logger_s {
        char *path;
+       int enable;
 };
 
 static struct memory_status_s __memory_status;
@@ -114,6 +116,9 @@ int _config_get_int_value(config_type_e type)
        case CONFIG_TYPE_CPU_CHECKER_MAX_COUNT:
                value = __cpu_checker.max_count;
                break;
+       case CONFIG_TYPE_LOGGER_ENABLE:
+               value = __logger.enable;
+               break;
        default:
                _E("Unknown type");
                value = INT_MIN;
@@ -255,6 +260,7 @@ static void __cpu_checker_set(dictionary *d)
 static void __logger_init(void)
 {
        __logger.path = strdup("/var/log/appfw");
+       __logger.enable = false;
 }
 
 static void __logger_fini(void)
@@ -265,6 +271,7 @@ static void __logger_fini(void)
 static void __logger_set(dictionary *d)
 {
        const char *str;
+       int val;
 
        str = __get_string_value(d, TAG_LOGGER,
                        KEY_LOGGER_PATH);
@@ -273,6 +280,12 @@ static void __logger_set(dictionary *d)
                __logger.path = strdup(str);
        }
        _W("Logger path(%s)", __logger.path);
+
+       val = __get_int_value(d, TAG_LOGGER,
+                       KEY_LOGGER_ENABLE);
+       if (val >= 0)
+               __logger.enable = val;
+       _W("Logger enable(%d)", __logger.enable);
 }
 
 int _config_init(void)
index 3dd37a4edd23524f7fcb358830ba0205693d43ac..d6b99d84d590ba5bab216baf14c11de0e6239254 100644 (file)
@@ -111,6 +111,9 @@ int _logger_create(const char *path, logger_h *handle)
        off_t offset;
        int ret;
 
+       if (!_config_get_int_value(CONFIG_TYPE_LOGGER_ENABLE))
+               return 0;
+
        if (!path || !handle) {
                _E("Invalid parameter");
                return -EINVAL;
@@ -156,6 +159,9 @@ int _logger_create(const char *path, logger_h *handle)
 
 int _logger_destroy(logger_h handle)
 {
+       if (!_config_get_int_value(CONFIG_TYPE_LOGGER_ENABLE))
+               return 0;
+
        if (!handle) {
                _E("Invalid parameter");
                return -EINVAL;
@@ -180,6 +186,9 @@ int _logger_print(logger_h handle, const char *tag, const char *format, ...)
        off_t offset;
        int bytes;
 
+       if (!_config_get_int_value(CONFIG_TYPE_LOGGER_ENABLE))
+               return 0;
+
        if (!handle || !tag || !format) {
                _E("Invalid parameter");
                return -EINVAL;
@@ -225,6 +234,9 @@ int _logger_print(logger_h handle, const char *tag, const char *format, ...)
 
 int _logger_get_fd(logger_h handle, int *fd)
 {
+       if (!_config_get_int_value(CONFIG_TYPE_LOGGER_ENABLE))
+               return 0;
+
        if (!handle || !fd) {
                _E("Invalid parameter");
                return -EINVAL;