Support logger activation/deactivation
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 12 Jan 2021 03:47:58 +0000 (12:47 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 12 Jan 2021 04:18:25 +0000 (13:18 +0900)
After this patch is applied, a default value of the logger is "false".
It means the logger will be disabled. To enable the logger, the platform
developer should set the logger to the amd.conf file.

Change-Id: I2163619ddd4e7e54ec5ae19a76231f60eb2e26fe
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
packaging/amd.conf
src/lib/amd_config.c
src/lib/amd_config.h
src/lib/amd_logger.c

index 8acc1c7bd569de1aed5d5535777b88f854f57abd..34c1858f1d3fa6948bd9365d9ce2b680cd4093d7 100644 (file)
@@ -8,3 +8,4 @@ launchpad_max_launch_failure=5
 logger_path=/run/aul/log
 booting_status_key=memory/sysman/booting_status
 booting_success_value=1
+logger=on
index f73ce4344176322d81fbf01f3554ea070d73e76d..ca6b4b7cca0bdb0dd501664939db5a2cefb086fe 100644 (file)
@@ -30,6 +30,7 @@
 #define CONFIG_FG_TIMEOUT "fg_timeout"
 #define CONFIG_LAUNCHPAD_MAX_LAUNCH_FAILURE "launchpad_max_launch_failure"
 #define CONFIG_LOGGER_PATH "logger_path"
+#define CONFIG_LOGGER "logger"
 #define CONFIG_BOOTING_STATUS_KEY "booting_status_key"
 #define CONFIG_BOOTING_SUCCESS_VALUE "booting_success_value"
 
@@ -40,6 +41,7 @@ typedef struct config_s {
        unsigned int fg_timeout;
        unsigned int max_launch_failure;
        char *logger_path;
+       bool logger;
        char *booting_status_key;
        int booting_success_value;
 } config;
@@ -109,6 +111,10 @@ const char *_config_get_logger_path(void)
        return __config.logger_path;
 }
 
+bool _config_is_logger_enabled(void)
+{
+       return __config.logger;
+}
 const char *_config_get_booting_status_key(void)
 {
        return __config.booting_status_key;
@@ -201,6 +207,14 @@ static int __load_config_file(const char *path)
                _I("[__CONFIG__] Logger path: %s", __config.logger_path);
        }
 
+       str = __get_config_string(d, CONFIG_LOGGER);
+       if (str) {
+               if (!strcmp(str, "on"))
+                       __config.logger = true;
+
+               _I("[__CONFIG__] Logger: %s", __config.logger ? "on" : "off");
+       }
+
        str = __get_config_string(d, CONFIG_BOOTING_STATUS_KEY);
        if (str) {
                free(__config.booting_status_key);
@@ -231,6 +245,7 @@ int _config_init(void)
        __config.fg_timeout = 5000;
        __config.max_launch_failure = 5;
        __config.logger_path = strdup("/var/log/appfw");
+       __config.logger = false;
        __config.booting_status_key = strdup(VCONFKEY_SYSMAN_BOOTINGSTATUS);
        __config.booting_success_value = VCONFKEY_SYSMAN_BOOTING_SUCCESS;
 
index 5867147e15ceec99af6d2f6be70535ce13ee9cb4..7f1fe711b04cd7f5fedf3ffa24f84a625e3c5f3e 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __AMD_CONFIG_H__
 #define __AMD_CONFIG_H__
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -57,6 +59,8 @@ unsigned int _config_get_max_launch_failure(void);
 
 const char *_config_get_logger_path(void);
 
+bool _config_is_logger_enabled(void);
+
 const char *_config_get_booting_status_key(void);
 
 int _config_get_booting_success_value(void);
index b00c10116d4d9fa3c6b4e520bab1bbd4b18d6cda..59c3d3ba5dd4349bce70a70b66e4ad6ceb756f8a 100644 (file)
@@ -84,6 +84,9 @@ int _logger_create(const char *path, logger_h *handle)
        struct logger_s *logger;
        off_t offset;
 
+       if (!_config_is_logger_enabled())
+               return 0;
+
        if (!path || !handle) {
                _E("Invalid parameter");
                return -EINVAL;
@@ -120,6 +123,9 @@ int _logger_create(const char *path, logger_h *handle)
 
 int _logger_destroy(logger_h handle)
 {
+       if (!_config_is_logger_enabled())
+               return 0;
+
        if (!handle) {
                _E("Invalid parameter");
                return -EINVAL;
@@ -143,6 +149,9 @@ int _logger_print(logger_h handle, const char *tag, const char *format, ...)
        va_list ap;
        off_t offset;
 
+       if (!_config_is_logger_enabled())
+               return 0;
+
        if (!handle || !tag || !format) {
                _E("Invalid parameter");
                return -EINVAL;
@@ -183,6 +192,9 @@ int _logger_print(logger_h handle, const char *tag, const char *format, ...)
 
 int _logger_get_fd(logger_h handle, int *fd)
 {
+       if (!_config_is_logger_enabled())
+               return 0;
+
        if (!handle || !fd) {
                _E("Invalid parameter");
                return -EINVAL;
@@ -195,6 +207,9 @@ int _logger_get_fd(logger_h handle, int *fd)
 
 const char *_logger_get_dir_name(void)
 {
+       if (!_config_is_logger_enabled())
+               return NULL;
+
        return __dir_name;
 }
 
@@ -228,6 +243,9 @@ int _logger_init(void)
        char path[PATH_MAX];
        int ret;
 
+       if (!_config_is_logger_enabled())
+               return 0;
+
        ret = __create_directory(_config_get_logger_path());
        if (ret < 0)
                return ret;
@@ -244,5 +262,8 @@ int _logger_init(void)
 
 void _logger_fini(void)
 {
+       if (!_config_is_logger_enabled())
+               return;
+
        free(__dir_name);
 }