Set STC_DEBUG_LOG flag 85/151485/1 accepted/tizen/unified/20170927.063134 submit/tizen/20170922.065607 submit/tizen/20170926.021226
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 21 Sep 2017 05:15:51 +0000 (14:15 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Thu, 21 Sep 2017 05:15:53 +0000 (14:15 +0900)
Change-Id: Ic4cfd5f7eb3fa1014db9486479d567e092486e1c
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
include/stc-manager.h
packaging/stc-manager.spec
src/helper/helper-cgroup.c
src/helper/helper-nfacct-rule.c
src/monitor/stc-monitor.c

index 990db68..37e5d97 100755 (executable)
@@ -31,6 +31,8 @@
 #define STC_TOTAL_IPV4 "TOTAL_IPV4"
 #define STC_TOTAL_IPV6 "TOTAL_IPV6"
 
+#define STC_DEBUG_LOG 0
+
 typedef enum {
        STC_CANCEL = 0,    /**< cancel */
        STC_CONTINUE = 1,  /**< continue */
index 4a256b3..d0e6065 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.34
+Version:    0.0.35
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index aa01d16..c636bc2 100755 (executable)
@@ -116,7 +116,9 @@ int cgroup_write_node_uint32(const char *cgroup_name,
 {
        char buf[MAX_PATH_LENGTH];
        snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
+#if STC_DEBUG_LOG
        STC_LOGD("cgroup_buf %s, value %d\n", buf, value);
+#endif
        return fwrite_uint(buf, value);
 }
 
@@ -125,7 +127,9 @@ int cgroup_write_node_str(const char *cgroup_name,
 {
        char buf[MAX_PATH_LENGTH];
        snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
+#if STC_DEBUG_LOG
        STC_LOGD("cgroup_buf %s, string %s\n", buf, string);
+#endif
        return fwrite_str(buf, string);
 }
 
@@ -136,7 +140,9 @@ int cgroup_read_node_uint32(const char *cgroup_name,
        int ret;
        snprintf(buf, sizeof(buf), "%s/%s", cgroup_name, file_name);
        ret = fread_uint(buf, value);
+#if STC_DEBUG_LOG
        STC_LOGD("cgroup_buf %s, value %d\n", buf, *value);
+#endif
        return ret;
 }
 
index a2a598f..a8474a1 100755 (executable)
@@ -156,7 +156,9 @@ stc_error_e nfacct_send_del(nfacct_rule_s *counter)
 {
        struct genl req;
 
+#if STC_DEBUG_LOG
        STC_LOGD("send remove request for %s", counter->name);
+#endif
 
        prepare_netlink_msg(&req, NFNL_MSG_ACCT_DEL, NLM_F_ACK);
        add_string_attr(&req, counter->name, NFACCT_NAME);
@@ -432,7 +434,9 @@ static bool is_rule_present(const char *cmd_buf)
                strncpy(exec_buf + (cmd_pos - cmd_buf), IPTABLES_CHECK,
                        sizeof(IPTABLES_CHECK) - 1);
 
+#if STC_DEBUG_LOG
                STC_LOGD("check rule %s", exec_buf);
+#endif
 
                args = g_strsplit_set(exec_buf, " ", -1);
 
@@ -468,8 +472,9 @@ stc_error_e exec_iptables_cmd(const char *cmd_buf, pid_t *cmd_pid)
                int ret;
                char *save_ptr = NULL;
 
-               STC_LOGD("executing iptables cmd %s in forked process",
-                        cmd_buf);
+#if STC_DEBUG_LOG
+               STC_LOGD("executing iptables cmd %s in forked process", cmd_buf);
+#endif
 
                if (is_rule_present(cmd_buf)) {
                        STC_LOGD("Rule %s already present", cmd_buf);
@@ -518,8 +523,9 @@ stc_error_e exec_ip6tables_cmd(const char *cmd_buf, pid_t *cmd_pid)
                int ret;
                char *save_ptr = NULL;
 
-               STC_LOGD("executing ip6tables cmd %s in forked process",
-                        cmd_buf);
+#if STC_DEBUG_LOG
+               STC_LOGD("executing ip6tables cmd %s in forked process", cmd_buf);
+#endif
 
                if (is_rule_present(cmd_buf)) {
                        STC_LOGD("Rule %s already present", cmd_buf);
index fc7b7bb..0e34821 100755 (executable)
@@ -292,6 +292,7 @@ static void __processes_tree_printall(GTree *processes)
        g_tree_foreach(processes, __processes_tree_foreach_print, NULL);
 }
 
+#if STC_DEBUG_LOG
 static gboolean __apps_tree_foreach_print(gpointer key, gpointer value,
                                          gpointer data)
 {
@@ -308,6 +309,7 @@ static gboolean __apps_tree_foreach_print(gpointer key, gpointer value,
        __processes_tree_printall(app_value->processes);
        return FALSE;
 }
+#endif
 
 #if 0
 static void __apps_tree_printall(void)
@@ -323,7 +325,9 @@ static gboolean __apps_tree_foreach_remove_pid(gpointer key, gpointer value,
        stc_app_value_s *app_value = (stc_app_value_s *)value;
 
        if (!g_tree_remove(app_value->processes, context->proc_key)) {
+#if STC_DEBUG_LOG
                STC_LOGD("key not found");
+#endif
                return FALSE;
        }
 
@@ -964,14 +968,18 @@ static void __app_counter_update(stc_app_key_s *app_key,
                app_value->counter.in_bytes = context->bytes;
                g_system->apps_tree_updated = TRUE;
 
+#if STC_DEBUG_LOG
                __apps_tree_foreach_print(app_key, app_value, NULL);
+#endif
                break;
        case NFACCT_COUNTER_OUT:
                app_value->data_usage.out_bytes += context->bytes;
                app_value->counter.out_bytes = context->bytes;
                g_system->apps_tree_updated = TRUE;
 
+#if STC_DEBUG_LOG
                __apps_tree_foreach_print(app_key, app_value, NULL);
+#endif
                break;
        default:
                STC_LOGE("unknown iotype");