From cab8bbff4b7610ecbe70a90a980ebe1579e08c21 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Thu, 31 May 2018 16:06:51 +0900 Subject: [PATCH] Organize log for print tree Change-Id: Ie27476ac28f8939df71dd0739adbcfccad427fb1 Signed-off-by: hyunuktak --- plugin/procfs/stc-plugin-procfs.c | 12 +++++--- src/database/tables/table-statistics.c | 3 +- src/monitor/stc-monitor.c | 52 ++++++++++++++++++++-------------- 3 files changed, 40 insertions(+), 27 deletions(-) mode change 100644 => 100755 src/database/tables/table-statistics.c mode change 100644 => 100755 src/monitor/stc-monitor.c diff --git a/plugin/procfs/stc-plugin-procfs.c b/plugin/procfs/stc-plugin-procfs.c index 80cf9b1..e889b7d 100755 --- a/plugin/procfs/stc-plugin-procfs.c +++ b/plugin/procfs/stc-plugin-procfs.c @@ -102,6 +102,7 @@ static proc_value_s * __proc_tree_lookup(const proc_key_s *key) return lookup; } +/* static gboolean __proc_tree_foreach_print(gpointer key, gpointer value, gpointer data) { @@ -119,6 +120,7 @@ static void __proc_tree_printall(void) { g_tree_foreach(proc_tree, __proc_tree_foreach_print, NULL); } +*/ static proc_value_s * __proc_tree_find_parent(proc_value_s *value) { @@ -193,8 +195,9 @@ static void __proc_tree_add(proc_key_s *key, proc_value_s *value) g_tree_insert(proc_tree, proc_key, proc_value); - if (STC_DEBUG_LOG) - __proc_tree_printall(); + /* + __proc_tree_printall(); + */ parent = __proc_tree_find_parent(proc_value); if (parent != NULL) @@ -217,8 +220,9 @@ static void __proc_tree_remove(const proc_key_s *key) g_tree_remove(proc_tree, key); - if (STC_DEBUG_LOG) - __proc_tree_printall(); + /* + __proc_tree_printall(); + */ } static gboolean __check_excn(char *cmdline) diff --git a/src/database/tables/table-statistics.c b/src/database/tables/table-statistics.c old mode 100644 new mode 100755 index 6f2fe03..436c55d --- a/src/database/tables/table-statistics.c +++ b/src/database/tables/table-statistics.c @@ -628,7 +628,8 @@ stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key, goto handle_error; //LCOV_EXCL_LINE } - STC_LOGD("App stat recorded [%s]", stat->app_id); + if (STC_DEBUG_LOG) + STC_LOGD("App stat recorded [%s]", stat->app_id); handle_error: sqlite3_reset(stmt); diff --git a/src/monitor/stc-monitor.c b/src/monitor/stc-monitor.c old mode 100644 new mode 100755 index adb79a2..cbd6f11 --- a/src/monitor/stc-monitor.c +++ b/src/monitor/stc-monitor.c @@ -283,6 +283,7 @@ static void __rstns_tree_key_free(gpointer data) FREE(key); } +/* //LCOV_EXCL_START static gboolean __processes_tree_foreach_print(gpointer key, gpointer value, gpointer data) @@ -322,6 +323,7 @@ static void __apps_tree_printall(void) g_tree_foreach(g_system->apps, __apps_tree_foreach_print, NULL); } //LCOV_EXCL_STOP +*/ static gboolean __apps_tree_foreach_remove_pid(gpointer key, gpointer value, gpointer data) @@ -329,11 +331,8 @@ static gboolean __apps_tree_foreach_remove_pid(gpointer key, gpointer value, remove_pid_context_s *context = (remove_pid_context_s *)data; 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"); //LCOV_EXCL_LINE + if (!g_tree_remove(app_value->processes, context->proc_key)) return FALSE; - } context->entry_removed = TRUE; context->app_key = (stc_app_key_s *)key; @@ -1074,16 +1073,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); //LCOV_EXCL_LINE + /* + __apps_tree_foreach_print(app_key, app_value, NULL); //LCOV_EXCL_LINE + */ 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); //LCOV_EXCL_LINE + /* + __apps_tree_foreach_print(app_key, app_value, NULL); //LCOV_EXCL_LINE + */ break; default: STC_LOGE("unknown iotype"); //LCOV_EXCL_LINE @@ -1158,10 +1159,11 @@ static void __fill_nfacct_result(char *cnt_name, int64_t bytes, return; //LCOV_EXCL_LINE } - STC_LOGI("classid %u, iftype %u, iotype %d, intend %d, ifname %s, bytes %lld", - context.counter->classid, context.counter->iftype, - context.counter->iotype, context.counter->intend, - context.counter->ifname, context.bytes); + if (STC_DEBUG_LOG) + STC_LOGI("classid %u, iftype %u, iotype %d, intend %d, ifname %s, bytes %lld", + context.counter->classid, context.counter->iftype, + context.counter->iotype, context.counter->intend, + context.counter->ifname, context.bytes); if (g_system->rstns) g_tree_foreach(g_system->rstns, @@ -1307,6 +1309,7 @@ static gboolean __update_contr_cb(void *user_data) return TRUE; } +/* //LCOV_EXCL_START static gboolean __rstn_tree_foreach_print(gpointer key, gpointer value, gpointer data) @@ -1322,7 +1325,8 @@ static void __rstn_tree_printall(void) { g_tree_foreach(g_system->rstns, __rstn_tree_foreach_print, NULL); } -//LCOV_EXCL_END +//LCOV_EXCL_STOP +*/ static stc_rstn_value_s * __rstn_lookup(GTree *rstns_tree, const stc_rstn_key_s *key) @@ -1505,8 +1509,7 @@ static void __fill_restritions_list(void) { table_restrictions_foreach(__insert_restriction_cb, NULL); - if (STC_DEBUG_LOG) - __rstn_tree_printall(); + /* __rstn_tree_printall(); */ } static gboolean __add_rstn_foreach_application(gpointer key, @@ -1758,7 +1761,8 @@ API stc_error_e stc_monitor_application_add(const stc_app_key_s app_key, lookup = __application_lookup(g_system->apps, &app_key); if (lookup) { - STC_LOGD("app_key already present"); //LCOV_EXCL_LINE + if (STC_DEBUG_LOG) + STC_LOGD("app_key already present"); //LCOV_EXCL_LINE return STC_ERROR_NONE; //LCOV_EXCL_LINE } @@ -1812,13 +1816,15 @@ API stc_error_e stc_monitor_process_add(const stc_app_key_s app_key, app_lookup = __application_lookup(g_system->apps, &app_key); if (!app_lookup) { - STC_LOGD("app_key not found"); //LCOV_EXCL_LINE + if (STC_DEBUG_LOG) + STC_LOGD("app_key not found"); //LCOV_EXCL_LINE return STC_ERROR_FAIL; //LCOV_EXCL_LINE } proc_lookup = __process_lookup(app_lookup->processes, &proc_key); if (proc_lookup) { - STC_LOGD("proc_key already present"); //LCOV_EXCL_LINE + if (STC_DEBUG_LOG) + STC_LOGD("proc_key already present"); //LCOV_EXCL_LINE return STC_ERROR_NONE; //LCOV_EXCL_LINE } @@ -1844,8 +1850,9 @@ API stc_error_e stc_monitor_process_add(const stc_app_key_s app_key, /* add pid to application cgroup */ place_pids_to_net_cgroup(proc_key.pid, app_key.app_id); - if (STC_DEBUG_LOG) - __apps_tree_printall(); //LCOV_EXCL_LINE + /* + __apps_tree_printall(); //LCOV_EXCL_LINE + */ return ret; } @@ -1871,8 +1878,9 @@ API stc_error_e stc_monitor_process_remove(pid_t pid) if (context.entry_removed) __application_remove_if_empty(context.app_key); - if (STC_DEBUG_LOG) - __apps_tree_printall(); //LCOV_EXCL_LINE + /* + __apps_tree_printall(); //LCOV_EXCL_LINE + */ return ret; } -- 2.7.4