[IMPROVE] add sys_stat debug
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Tue, 26 Nov 2013 09:52:48 +0000 (13:52 +0400)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Tue, 26 Nov 2013 10:13:51 +0000 (14:13 +0400)
Change-Id: I2b5cd4b7fc75f9ff678a9bed941a5c8b92bbd67d
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
daemon/Makefile
daemon/debug.h
daemon/sys_stat.c

index 737badb665ca47a2143a635b8aa1c70db8b01667..f615e397df9efe9c10e6b410cca4b9c9c7025164 100644 (file)
@@ -1,10 +1,11 @@
 CC :=gcc
-DEBUG_CPPFLAGS =                       \
-               -DDEBUG                 \
-#              -DDEB_PRINTBUF          \#
-#              -DPARSE_DEBUG_ON        \#
+DEBUG_CPPFLAGS =                               \
+               -DDEBUG                                 \
+               -DUSE_LOG_ONCE                  \
+#              -DDEB_PRINTBUF                  \#
+#              -DPARSE_DEBUG_ON                \#
 #              -DTHREAD_SAMPLING_DEBUG \#
-#              -THREAD_REPLAY_DEBUG     #
+#              -DTHREAD_REPLAY_DEBUG   #
 
 CPPFLAGS :=    -I/usr/include          \
                -I/usr/include/system   \
index ee827c85baf2aaea741ae8f89ac36c329cd63fb1..4931f11368e04b9e42972a1cc5607c5a09d12b09 100644 (file)
@@ -65,6 +65,25 @@ void print_buf(char *buf, int len, const char *info);
 #define LOGE(...) do_log("ERR", __func__, __VA_ARGS__)
 #define LOGW(...) do_log("WRN", __func__, __VA_ARGS__)
 
+#ifdef USE_LOG_ONCE
+       #define TOKENPASTE(x, y) x ## y
+       #define TOKENPASTE2(x, y) TOKENPASTE(x, y)
+       #define LOG_ONCE_VAR TOKENPASTE2(log_once_var_, __LINE__)
+       #define INIT_LOG_ONCE static char LOG_ONCE_VAR = 0
+
+       #define LOG_ONCE(W_E,...)                               \
+               INIT_LOG_ONCE;                                  \
+               if (LOG_ONCE_VAR == 0) {                        \
+                       TOKENPASTE2(LOG, W_E)(__VA_ARGS__);     \
+                       LOG_ONCE_VAR = 1;                       \
+               }
+       #define LOG_ONCE_E(...) LOG_ONCE(E, __VA_ARGS__)
+       #define LOG_ONCE_W(...) LOG_ONCE(W, __VA_ARGS__)
+#else
+       #define LOG_ONCE_W(...)
+       #define LOG_ONCE_E(...)
+#endif
+
 static inline void do_log(const char *prefix, const char *funcname, ...)
 {
        va_list ap;
@@ -93,6 +112,9 @@ static inline void do_log(const char *prefix, const char *funcname, ...)
        #define LOGI_(...)
        #define LOGE(...)
        #define LOGW(...)
+       #define LOG_ONCE_W(...)
+       #define LOG_ONCE_E(...)
+
 #endif
 
 
index ace04d3fcb19c705abfe4c78c4c1339b3eaef8b1..ef04cb773a9205ef67361728974f610704246a13 100644 (file)
@@ -156,18 +156,27 @@ int get_file_status(int *pfd, const char *filename)
 static int get_wifi_status()
 {
        int wifi_status = 0;
+       int res = 0;
+
+       res = vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_status);
+       if (unlikely(res < 0)) {
+               LOG_ONCE_W("get error #%d\n", res);
+               wifi_status = VCONFKEY_WIFI_OFF;
+       }
 
-       if (unlikely(vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_status) < 0))
-                       wifi_status = VCONFKEY_WIFI_OFF;
        return wifi_status;
 }
 
 static int get_bt_status()
 {
        int bt_status = false;
+       int res = 0;
 
-       if (unlikely(vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0))
+       res = vconf_get_int(VCONFKEY_BT_STATUS, &bt_status);
+       if (unlikely(res < 0)) {
+               LOG_ONCE_W("get error #%d\n", res);
                bt_status = VCONFKEY_BT_STATUS_OFF;
+       }
 
        return bt_status;
 }
@@ -175,13 +184,16 @@ static int get_bt_status()
 static int get_gps_status()
 {
        int gps_status = 0;
+       int res = 0;
 
-       if (unlikely(vconf_get_bool(VCONFKEY_LOCATION_ENABLED,
-                                   &gps_status) < 0)) {
+       res = vconf_get_int(VCONFKEY_LOCATION_ENABLED, &gps_status);
+       if(unlikely(res < 0)) {
+               LOG_ONCE_W("get error #%d\n", res);
                gps_status = VCONFKEY_LOCATION_GPS_OFF;
-       } else if (gps_status != 0) {
-               if (unlikely(vconf_get_int(VCONFKEY_LOCATION_GPS_STATE,
-                                          &gps_status) < 0)) {
+       } else if(gps_status != 0) {
+               res = vconf_get_int(VCONFKEY_LOCATION_GPS_STATE, &gps_status);
+               if (unlikely(res < 0)) {
+                       LOG_ONCE_W("get error #%d\n", res);
                        gps_status = VCONFKEY_LOCATION_GPS_OFF;
                }
        }
@@ -295,16 +307,21 @@ static int get_rssi_status()
 {
 
        int flightmode_status;
-       int rssi_status;
+       int res = 0;
 
-       if (unlikely(vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL,
-                                   &flightmode_status) < 0)) {
+       int rssi_status;
+       res = vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL,
+                                       &flightmode_status);
+       if(unlikely(res < 0)) {
+               LOG_ONCE_W("get err #%d <%s>\n", res,
+                        VCONFKEY_TELEPHONY_FLIGHT_MODE);
                flightmode_status = 0;
        }
 
-       if (!flightmode_status) {
-               if (unlikely(vconf_get_int(VCONFKEY_TELEPHONY_RSSI,
-                                          &rssi_status) < 0)) {
+       if(!flightmode_status) {
+               res = vconf_get_int(VCONFKEY_TELEPHONY_RSSI, &rssi_status);
+               if(unlikely(res < 0)) {
+                       LOG_ONCE_W("rssi get err #%d\n", res);
                        rssi_status = VCONFKEY_TELEPHONY_RSSI_0;
                }
        } else {
@@ -313,16 +330,19 @@ static int get_rssi_status()
 
        return rssi_status;
 
-
        return 0;
 }
 
 static int get_call_status()
 {
        int call_status = 0;
+       int res = 0;
 
-       if (unlikely(vconf_get_int(VCONFKEY_CALL_STATE, &call_status) < 0))
+       res = vconf_get_int(VCONFKEY_CALL_STATE, &call_status);
+       if(unlikely(res < 0)) {
+               LOG_ONCE_W("get err #%d\n", res);
                call_status = VCONFKEY_CALL_OFF;
+       }
 
        return call_status;
 }
@@ -331,11 +351,13 @@ static int get_call_status()
 static int get_dnet_status()
 {
        int dnet_status = false;
+       int res = 0;
 
-               if (unlikely(vconf_get_int(VCONFKEY_DNET_STATE,
-                                          &dnet_status) < 0)) {
-                       dnet_status = VCONFKEY_DNET_OFF;
-               }
+       res = vconf_get_int(VCONFKEY_DNET_STATE, &dnet_status);
+       if(unlikely(res < 0)) {
+               LOG_ONCE_W("get err #%d <%s>\n", res, VCONFKEY_DNET_STATE);
+               dnet_status = VCONFKEY_DNET_OFF;
+       }
 
        return dnet_status;
 }
@@ -351,9 +373,12 @@ static int get_camera_status()
 static int get_sound_status()
 {
        int sound_status = 0;
+       int res = 0;
 
-       if (unlikely(vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
-                                   &sound_status) < 0)) {
+       res = vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL,
+                                       &sound_status);
+       if (unlikely(res < 0)) {
+               LOG_ONCE_W("get err #%d\n", res);
                sound_status = 0;
        }
 
@@ -406,9 +431,12 @@ static int get_audio_status()
 static int get_vibration_status()
 {
        int vibration_status = 0;
+       int res = 0;
 
-       if (unlikely(vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
-                                   &vibration_status) < 0)) {
+       res = vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL,
+                                       &vibration_status);
+       if(unlikely(res < 0)) {
+               LOG_ONCE_W("get err #%d\n", res);
                vibration_status = 0;
        }
 
@@ -2148,7 +2176,7 @@ static uint64_t get_system_lcd_energy()
                             NULL, &glob_buf);
 
        if (err) {
-               LOGE("Globbing for LCD failed with error %d", err);
+               LOG_ONCE_E("Globbing for LCD failed with error %d\n", err);
                return 0;
        }