Fix an issue where the log option is not applied properly 24/245824/2
authorJaehyun Kim <jeik01.kim@samsung.com>
Fri, 16 Oct 2020 07:51:48 +0000 (16:51 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 16 Oct 2020 07:53:09 +0000 (16:53 +0900)
Change-Id: Ibb5305175a1987d74f0a24ba413a664940233e76
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/log.h
src/connman.h
src/log.c
src/main.c
src/service.c

index 7687ed0..9403633 100755 (executable)
 #ifndef __CONNMAN_LOG_H
 #define __CONNMAN_LOG_H
 
+#if defined TIZEN_EXT
+#include <stdbool.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -86,6 +90,14 @@ struct connman_debug_desc {
                                        __FILE__, __FUNCTION__ , ## arg); \
 } while (0)
 
+#if defined TIZEN_EXT
+#define simplified_log get_simple_log_option()
+bool get_simple_log_option(void);
+void set_simple_log_option(bool option);
+void set_dlog_logging_option(bool option);
+void set_file_logging_option(bool option);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index 82e584e..9e28ffe 100755 (executable)
@@ -1222,9 +1222,6 @@ int __connman_util_init(void);
 void __connman_util_cleanup(void);
 
 #ifdef TIZEN_EXT
-__attribute__ ((unused)) static bool dlog_logging = true;
-__attribute__ ((unused)) static bool file_logging = true;
-__attribute__ ((unused)) static bool simplified_log = true;
 __attribute__ ((unused)) static int __tizentvextension = -1;
 #define TIZEN_TV_EXT (__builtin_expect(__tizentvextension != -1, 1) ? \
        __tizentvextension : \
index 8dbbb04..7a4839b 100755 (executable)
--- a/src/log.c
+++ b/src/log.c
@@ -40,6 +40,7 @@ static const char *program_path;
 #if defined TIZEN_EXT
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <stdbool.h>
 #include <dlog.h>
 
 #undef LOG_TAG
@@ -55,6 +56,29 @@ static const char *program_path;
 #define syslog __connman_log_s
 
 static FILE *log_file = NULL;
+static bool dlog_logging = true;
+static bool file_logging = true;
+static bool simple_log = true;
+
+bool get_simple_log_option(void)
+{
+       return simple_log;
+}
+
+void set_simple_log_option(bool option)
+{
+       simple_log = option;
+}
+
+void set_dlog_logging_option(bool option)
+{
+       dlog_logging = option;
+}
+
+void set_file_logging_option(bool option)
+{
+       file_logging = option;
+}
 
 void __connman_log_open(const char *ident, int option, int facility)
 {
index 7938a06..7e63812 100755 (executable)
@@ -106,7 +106,7 @@ static struct {
        char *def_wifi_ifname;
        bool file_log;
        bool dlog_log;
-       bool simplified_log;
+       bool simple_log;
 #endif
 } connman_settings  = {
        .bg_scan = true,
@@ -139,7 +139,7 @@ static struct {
        .def_wifi_ifname = DEFAULT_WIFI_INTERFACE,
        .file_log = true,
        .dlog_log = true,
-       .simplified_log = true,
+       .simple_log = true,
 #endif
 };
 
@@ -695,7 +695,7 @@ static void check_Tizen_configuration(GKeyFile *config)
        boolean = __connman_config_get_bool(config, "General",
                        CONF_CONNMAN_SIMPLIFIED_LOG, &error);
        if (!error)
-               connman_settings.simplified_log = boolean;
+               connman_settings.simple_log = boolean;
 
        g_clear_error(&error);
 
@@ -940,10 +940,11 @@ static int config_init(const char *file)
        parse_config(config);
        if (config)
                g_key_file_free(config);
+
 #if defined TIZEN_EXT
-       dlog_logging = connman_settings.dlog_log;
-       file_logging = connman_settings.file_log;
-       simplified_log = connman_settings.simplified_log;
+       set_simple_log_option(connman_settings.simple_log);
+       set_dlog_logging_option(connman_settings.dlog_log);
+       set_file_logging_option(connman_settings.file_log);
 #endif
        return 0;
 }
@@ -1179,7 +1180,7 @@ bool connman_setting_get_bool(const char *key)
                return connman_settings.dlog_log;
 
        if (g_str_equal(key, CONF_CONNMAN_SIMPLIFIED_LOG))
-               return connman_settings.simplified_log;
+               return connman_settings.simple_log;
 #endif
 
 #if defined TIZEN_EXT
index e6cc61c..a1e745d 100755 (executable)
@@ -10021,7 +10021,7 @@ static int service_register(struct connman_service *service)
        if (ret == -ERANGE)
                service_ext_save(service);
        ret = __connman_config_provision_service(service);
-       if (ret < 0 && simplified_log)
+       if (ret < 0 && !simplified_log)
                DBG("Failed to provision service");
 #else
        if (__connman_config_provision_service(service) < 0)