[FIX] wrong pack size of system memory total/used
[platform/core/system/swap-manager.git] / daemon / debug.h
1 /*
2  *  DA manager
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Cherepanov Vitaliy <v.cherepanov@samsung.com>
9  * Nikita Kalyazin    <n.kalyazin@samsung.com>
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * Contributors:
24  * - Samsung RnD Institute Russia
25  *
26  */
27
28
29 #ifndef _DAEMON_DEBUG_H_
30 #define _DAEMON_DEBUG_H_
31
32 #include <stdint.h>             // for uint64_t, int64_t
33 #include <pthread.h>    // for pthread_mutex_t
34
35 #include "da_protocol.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /*
42  * DEBUG DEFINES
43  */
44 //#define DEB_PRINTBUF
45 //#define PARSE_DEBUG_ON
46 //threads debug
47 //#define THREAD_SAMPLING_DEBUG
48 //#define THREAD_REPLAY_DEBUG
49
50
51 //DEBUG ON PARSING
52 #ifdef PARSE_DEBUG_ON
53 #define parse_deb LOGI
54 #else
55 #define parse_deb(...) do{}while(0)
56 #endif /*parse_on*/
57
58 //PRINT BUFFER DEBUG
59 #define printBuf(buf, len) print_buf(buf, len, __FUNCTION__)
60 void print_buf (char * buf, int len, const char *info);
61
62 //THREAD SAMPLING DEBUG
63 #ifdef THREAD_SAMPLING_DEBUG
64         #define LOGI_th_samp LOGI
65 #else
66         #define LOGI_th_samp(...)       do{} while(0)
67 #endif
68
69 //THREAD REPLAY DEBUG
70 #ifdef THREAD_REPLAY_DEBUG
71         #define LOGI_th_rep LOGI
72 #else
73         #define LOGI_th_rep(...)        do{} while(0)
74 #endif
75
76
77 /*
78  * END DEBUG DEFINES
79  */
80 #ifdef DEBUG
81
82 #ifdef NOLOGI
83         #define LOGI(...)       do{} while(0)
84         #define LOGI_(...)      do{} while(0)
85 #else
86 //      #define LOGI(...)       do{ fprintf(stderr, "[INF] (%s):", __FUNCTION__); fflush(stderr); fprintf(stderr, __VA_ARGS__ ); fflush(stderr); usleep(100000);} while(0)
87         #define LOGI(...)       do{ fprintf(stderr, "[INF] (%s):", __FUNCTION__); fflush(stderr); fprintf(stderr, __VA_ARGS__ ); fflush(stderr); } while(0)
88 //      #define LOGI(...)       do{} while(0)
89         #define LOGI_(...)      do{ fprintf(stderr, __VA_ARGS__ ); fflush(stderr); } while(0)
90         //#define LOGI_(...)    do{} while(0)
91 #endif
92
93 //      #define LOGE(...)       do{ fprintf(stderr, "[ERR] (%s):", __FUNCTION__); fflush(stderr); fprintf(stderr, __VA_ARGS__ ); fflush(stderr); usleep(1000000);} while(0)
94         #define LOGE(...)       do{ fprintf(stderr, "[ERR] (%s):", __FUNCTION__); fflush(stderr); fprintf(stderr, __VA_ARGS__ ); fflush(stderr); } while(0)
95         #define LOGW(...)       do{ fprintf(stderr, "[WRN] (%s):", __FUNCTION__); fflush(stderr); fprintf(stderr, __VA_ARGS__ ); fflush(stderr); } while(0)
96
97
98 #else
99         #define LOGI(...)       do{} while(0)
100         #define LOGI_(...)      do{} while(0)
101         #define LOGE(...)       do{} while(0)
102         #define LOGW(...)       do{} while(0)
103 #endif
104
105
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif // _DAEMON_DEBUG_H_