summaryrefslogtreecommitdiff
path: root/common/include/ivug-debug.h
blob: fae7537c0c9c07d16098f6d6954e09e0b9d9887d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *	  http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef _IVUG_DEBUG_H_
#define _IVUG_DEBUG_H_

#include <dlog.h>

#define IVUG_LOG_OUTPUT_DLOG

enum {
	IVUG_MSG_COLOR_DEFAULT	= 0,
	IVUG_MSG_COLOR_BLACK	= 30,
	IVUG_MSG_COLOR_RED		= 31,
	IVUG_MSG_COLOR_GREEN	= 32,
	IVUG_MSG_COLOR_YELLOW	= 33,
	IVUG_MSG_COLOR_BLUE		= 34,
	IVUG_MSG_COLOR_MAGENTA	= 35,
	IVUG_MSG_COLOR_CYAN		= 36,
	IVUG_MSG_COLOR_WHITE		= 37,
};

#ifdef IVUG_LOG_OUTPUT_DLOG

#undef LOG_TAG
#define LOG_TAG "IV-COMMON"

#define IVUG_DEBUG_MSG(fmt, arg...)			LOGD("[%s : %05d]" fmt "\n", __func__, __LINE__, ##arg)
#define IVUG_DEBUG_WARNING(fmt, arg...)		LOGW("[%s : %05d]" fmt "\n", __func__, __LINE__, ##arg)
#define IVUG_DEBUG_ERROR(fmt, arg...)		LOGE("[%s : %05d]" fmt "\n", __func__, __LINE__ , ##arg)
#define IVUG_DEBUG_CRITICAL(fmt, arg...)	LOGE("[%s : %05d]" fmt "\n", __func__, __LINE__ , ##arg)

#else	//USE_DLOG
#define IVUG_DEBUG_MSG(fmt, arg...)			fprintf(stdout, "[D: %s : %05d]" fmt "\n", __func__, __LINE__, ##arg)
#define IVUG_DEBUG_WARNING(fmt, arg...)		fprintf(stdout, "[W: %s : %05d]" fmt "\n", __func__, __LINE__, ##arg)
#define IVUG_DEBUG_ERROR(fmt, arg...)		fprintf(stdout, "[E: %s : %05d]" fmt "\n", __func__, __LINE__ , ##arg)
#define IVUG_DEBUG_CRITICAL(fmt, arg...)		fprintf(stdout, "[E: %s : %05d]" fmt "\n", __func__, __LINE__ , ##arg)
#define IVUG_DEBUG_PRINT(fmt,arg...)			fprintf(stdout, "[%s : %05d] >>> leave \n", __func__, __LINE__ , ##arg)

#endif //IVUG_LOG_OUTPUT_DLOG

/*
	How to add new Category..

	TODO:
*/

#define MSG_MOUSE_SZCAT "IV-MOUSE"
#define LVL_MOUSE DBG_MSG_LVL_HIGH

#define MSG_MOUSE_FATAL(...) 	__MSG_FATAL(LVL_MOUSE, MSG_MOUSE_SZCAT, ##__VA_ARGS__)
#define MSG_MOUSE_ERROR(...)	__MSG_ERROR(LVL_MOUSE, MSG_MOUSE_SZCAT, ##__VA_ARGS__)
#define MSG_MOUSE_WARN(...)		__MSG_WARN(LVL_MOUSE, MSG_MOUSE_SZCAT, ##__VA_ARGS__)
#define MSG_MOUSE_HIGH(...)		__MSG_HIGH(LVL_MOUSE, MSG_MOUSE_SZCAT, ##__VA_ARGS__)
#define MSG_MOUSE_MED(...)		__MSG_MED(LVL_MOUSE, MSG_MOUSE_SZCAT, ##__VA_ARGS__)
#define MSG_MOUSE_LOW(...)		__MSG_LOW(LVL_MOUSE, MSG_MOUSE_SZCAT, ##__VA_ARGS__)


#define SLIDER_ITEM_SZ "IV-SITEM"
#define LVL_SLIDER_ITEM DBG_MSG_LVL_HIGH


#define MSG_SITEM_FATAL(...) 		__MSG_FATAL(LVL_SLIDER_ITEM, SLIDER_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SITEM_ERROR(...)		__MSG_ERROR(LVL_SLIDER_ITEM, SLIDER_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SITEM_WARN(...)		__MSG_WARN(LVL_SLIDER_ITEM, SLIDER_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SITEM_HIGH(...)		__MSG_HIGH(LVL_SLIDER_ITEM, SLIDER_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SITEM_MED(...)		__MSG_MED(LVL_SLIDER_ITEM, SLIDER_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SITEM_LOW(...)		__MSG_LOW(LVL_SLIDER_ITEM, SLIDER_ITEM_SZ, ##__VA_ARGS__)


#define SLIDER_SZ "IV-SLIDER"
#define LVL_SLIDER DBG_MSG_LVL_HIGH

#define MSG_SLIDER_FATAL(...) 		__MSG_FATAL(LVL_SLIDER, SLIDER_SZ, ##__VA_ARGS__)
#define MSG_SLIDER_ERROR(...)		__MSG_ERROR(LVL_SLIDER, SLIDER_SZ, ##__VA_ARGS__)
#define MSG_SLIDER_WARN(...)		__MSG_WARN(LVL_SLIDER, SLIDER_SZ, ##__VA_ARGS__)
#define MSG_SLIDER_HIGH(...)		__MSG_HIGH(LVL_SLIDER, SLIDER_SZ, ##__VA_ARGS__)
#define MSG_SLIDER_MED(...)		__MSG_MED(LVL_SLIDER, SLIDER_SZ, ##__VA_ARGS__)
#define MSG_SLIDER_LOW(...)		__MSG_LOW(LVL_SLIDER, SLIDER_SZ, ##__VA_ARGS__)

#define SETAS_SZ "IV-SETAS"
#define LVL_SETAS DBG_MSG_LVL_HIGH

#define MSG_SETAS_FATAL(...) 		__MSG_FATAL(LVL_SETAS, SETAS_SZ, ##__VA_ARGS__)
#define MSG_SETAS_ERROR(...)		__MSG_ERROR(LVL_SETAS, SETAS_SZ, ##__VA_ARGS__)
#define MSG_SETAS_WARN(...)			__MSG_WARN(LVL_SETAS, SETAS_SZ, ##__VA_ARGS__)
#define MSG_SETAS_HIGH(...)			__MSG_HIGH(LVL_SETAS, SETAS_SZ, ##__VA_ARGS__)
#define MSG_SETAS_MED(...)			__MSG_MED(LVL_SETAS, SETAS_SZ, ##__VA_ARGS__)
#define MSG_SETAS_LOW(...)			__MSG_LOW(LVL_SETAS, SETAS_SZ, ##__VA_ARGS__)

#define DETAIL_SZ "IV-DETAIL"
#define LVL_DETAIL DBG_MSG_LVL_MED

#define MSG_DETAIL_FATAL(...) 		__MSG_FATAL(LVL_DETAIL, DETAIL_SZ, ##__VA_ARGS__)
#define MSG_DETAIL_ERROR(...)		__MSG_ERROR(LVL_DETAIL, DETAIL_SZ, ##__VA_ARGS__)
#define MSG_DETAIL_WARN(...)		__MSG_WARN(LVL_DETAIL, DETAIL_SZ, ##__VA_ARGS__)
#define MSG_DETAIL_HIGH(...)		__MSG_HIGH(LVL_DETAIL, DETAIL_SZ, ##__VA_ARGS__)
#define MSG_DETAIL_MED(...)			__MSG_MED(LVL_DETAIL, DETAIL_SZ, ##__VA_ARGS__)
#define MSG_DETAIL_LOW(...)			__MSG_LOW(LVL_DETAIL, DETAIL_SZ, ##__VA_ARGS__)

#define SDATA_SZ "IV-SDATA"
#define LVL_SDATA DBG_MSG_LVL_HIGH

#define MSG_SDATA_FATAL(...) 		__MSG_FATAL(LVL_SDATA, SDATA_SZ, ##__VA_ARGS__)
#define MSG_SDATA_ERROR(...)		__MSG_ERROR(LVL_SDATA, SDATA_SZ, ##__VA_ARGS__)
#define MSG_SDATA_WARN(...)			__MSG_WARN(LVL_SDATA, SDATA_SZ, ##__VA_ARGS__)
#define MSG_SDATA_HIGH(...)			__MSG_HIGH(LVL_SDATA, SDATA_SZ, ##__VA_ARGS__)
#define MSG_SDATA_MED(...)			__MSG_MED(LVL_SDATA, SDATA_SZ, ##__VA_ARGS__)
#define MSG_SDATA_LOW(...)			__MSG_LOW(LVL_SDATA, SDATA_SZ, ##__VA_ARGS__)


#define IVCOMMON_SZ "IV-COMMON"
#define LVL_IVCOMMON DBG_MSG_LVL_HIGH

#define MSG_IMAGEVIEW_FATAL(...) 		__MSG_FATAL(LVL_IVCOMMON, IVCOMMON_SZ, ##__VA_ARGS__)
#define MSG_IMAGEVIEW_ERROR(...)		__MSG_ERROR(LVL_IVCOMMON, IVCOMMON_SZ, ##__VA_ARGS__)
#define MSG_IMAGEVIEW_WARN(...)			__MSG_WARN(LVL_IVCOMMON, IVCOMMON_SZ, ##__VA_ARGS__)
#define MSG_IMAGEVIEW_HIGH(...)			__MSG_HIGH(LVL_IVCOMMON, IVCOMMON_SZ, ##__VA_ARGS__)
#define MSG_IMAGEVIEW_MED(...)			__MSG_MED(LVL_IVCOMMON, IVCOMMON_SZ, ##__VA_ARGS__)
#define MSG_IMAGEVIEW_LOW(...)			__MSG_LOW(LVL_IVCOMMON, IVCOMMON_SZ, ##__VA_ARGS__)

#define MAINVIEW_SZ "IV-MAIN"
#define LVL_MAINVIEW DBG_MSG_LVL_HIGH

#define MSG_MAIN_FATAL(...) 		__MSG_FATAL(LVL_MAINVIEW, MAINVIEW_SZ, ##__VA_ARGS__)
#define MSG_MAIN_ERROR(...)		__MSG_ERROR(LVL_MAINVIEW, MAINVIEW_SZ, ##__VA_ARGS__)
#define MSG_MAIN_WARN(...)			__MSG_WARN(LVL_MAINVIEW, MAINVIEW_SZ, ##__VA_ARGS__)
#define MSG_MAIN_HIGH(...)			__MSG_HIGH(LVL_MAINVIEW, MAINVIEW_SZ, ##__VA_ARGS__)
#define MSG_MAIN_MED(...)			__MSG_MED(LVL_MAINVIEW, MAINVIEW_SZ, ##__VA_ARGS__)
#define MSG_MAIN_LOW(...)			__MSG_LOW(LVL_MAINVIEW, MAINVIEW_SZ, ##__VA_ARGS__)

#define UTIL_SZ "IV-UTIL"
#define LVL_UTIL DBG_MSG_LVL_HIGH

#define MSG_UTIL_FATAL(...) 		__MSG_FATAL(LVL_UTIL, UTIL_SZ, ##__VA_ARGS__)
#define MSG_UTIL_ERROR(...)		__MSG_ERROR(LVL_UTIL, UTIL_SZ, ##__VA_ARGS__)
#define MSG_UTIL_WARN(...)			__MSG_WARN(LVL_UTIL, UTIL_SZ, ##__VA_ARGS__)
#define MSG_UTIL_HIGH(...)			__MSG_HIGH(LVL_UTIL, UTIL_SZ, ##__VA_ARGS__)
#define MSG_UTIL_MED(...)			__MSG_MED(LVL_UTIL, UTIL_SZ, ##__VA_ARGS__)
#define MSG_UTIL_LOW(...)			__MSG_LOW(LVL_UTIL, UTIL_SZ, ##__VA_ARGS__)

#define IVUG_SZ "IV-COMMON"
#define LVL_IVUG DBG_MSG_LVL_HIGH

#define MSG_IVUG_FATAL(...) 				__MSG_FATAL(LVL_IVUG, IVUG_SZ, ##__VA_ARGS__)
#define MSG_IVUG_ERROR(...)		__MSG_ERROR(LVL_IVUG, IVUG_SZ, ##__VA_ARGS__)
#define MSG_IVUG_WARN(...)			__MSG_WARN(LVL_IVUG, IVUG_SZ, ##__VA_ARGS__)
#define MSG_IVUG_HIGH(...)			__MSG_HIGH(LVL_IVUG, IVUG_SZ, ##__VA_ARGS__)
#define MSG_IVUG_MED(...)			__MSG_MED(LVL_IVUG, IVUG_SZ, ##__VA_ARGS__)
#define MSG_IVUG_LOW(...)			__MSG_LOW(LVL_IVUG, IVUG_SZ, ##__VA_ARGS__)

#define NOTI_SZ "IV-NOTI"
#define LVL_NOTI DBG_MSG_LVL_LOW

#define MSG_NOTI_FATAL(...) 				__MSG_FATAL(LVL_NOTI, NOTI_SZ, ##__VA_ARGS__)
#define MSG_NOTI_ERROR(...)		__MSG_ERROR(LVL_NOTI, NOTI_SZ, ##__VA_ARGS__)
#define MSG_NOTI_WARN(...)			__MSG_WARN(LVL_NOTI, NOTI_SZ, ##__VA_ARGS__)
#define MSG_NOTI_HIGH(...)			__MSG_HIGH(LVL_NOTI, NOTI_SZ, ##__VA_ARGS__)
#define MSG_NOTI_MED(...)			__MSG_MED(LVL_NOTI, NOTI_SZ, ##__VA_ARGS__)
#define MSG_NOTI_LOW(...)			__MSG_LOW(LVL_NOTI, NOTI_SZ, ##__VA_ARGS__)

#define PHOTO_SZ "IV-PHOTO"
#define LVL_PHOTO DBG_MSG_LVL_HIGH

#define MSG_PHOTO_FATAL(...) 				__MSG_FATAL(LVL_PHOTO, PHOTO_SZ, ##__VA_ARGS__)
#define MSG_PHOTO_ERROR(...)		__MSG_ERROR(LVL_PHOTO, PHOTO_SZ, ##__VA_ARGS__)
#define MSG_PHOTO_WARN(...)			__MSG_WARN(LVL_PHOTO, PHOTO_SZ, ##__VA_ARGS__)
#define MSG_PHOTO_HIGH(...)			__MSG_HIGH(LVL_PHOTO, PHOTO_SZ, ##__VA_ARGS__)
#define MSG_PHOTO_MED(...)			__MSG_MED(LVL_PHOTO, PHOTO_SZ, ##__VA_ARGS__)
#define MSG_PHOTO_LOW(...)			__MSG_LOW(LVL_PHOTO, PHOTO_SZ, ##__VA_ARGS__)

#define EFFECT_SZ "IV-EFFECT"
#define LVL_EFFECT DBG_MSG_LVL_HIGH

#define MSG_EFFECT_FATAL(...) 				__MSG_FATAL(LVL_EFFECT, EFFECT_SZ, ##__VA_ARGS__)
#define MSG_EFFECT_ERROR(...)		__MSG_ERROR(LVL_EFFECT, EFFECT_SZ, ##__VA_ARGS__)
#define MSG_EFFECT_WARN(...)			__MSG_WARN(LVL_EFFECT, EFFECT_SZ, ##__VA_ARGS__)
#define MSG_EFFECT_HIGH(...)			__MSG_HIGH(LVL_EFFECT, EFFECT_SZ, ##__VA_ARGS__)
#define MSG_EFFECT_MED(...)			__MSG_MED(LVL_EFFECT, EFFECT_SZ, ##__VA_ARGS__)
#define MSG_EFFECT_LOW(...)			__MSG_LOW(LVL_EFFECT, EFFECT_SZ, ##__VA_ARGS__)


#define SLIST_ITEM_SZ "IV-SLIST"
#define LVL_SLIST_ITEM DBG_MSG_LVL_HIGH

#define MSG_SLIST_FATAL(...) 		__MSG_FATAL(LVL_SLIST_ITEM, SLIST_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SLIST_ERROR(...)		__MSG_ERROR(LVL_SLIST_ITEM, SLIST_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SLIST_WARN(...)		__MSG_WARN(LVL_SLIST_ITEM, SLIST_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SLIST_HIGH(...)		__MSG_HIGH(LVL_SLIST_ITEM, SLIST_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SLIST_MED(...)		__MSG_MED(LVL_SLIST_ITEM, SLIST_ITEM_SZ, ##__VA_ARGS__)
#define MSG_SLIST_LOW(...)		__MSG_LOW(LVL_SLIST_ITEM, SLIST_ITEM_SZ, ##__VA_ARGS__)


#define IV_ASSERT(expr) ASSERT(DBG_MSG_LVL_ALL, "IV-COMMON", expr)


#define IVUG_FUNC_ENTER()					MSG_IVUG_HIGH("ENTER %s(L%d)", __func__, __LINE__)
#define IVUG_FUNC_LEAVE()					MSG_IVUG_HIGH("LEAVE %s(L%d)", __func__, __LINE__)

//expr check statements
#define ivug_ret_if(expr) \
	do { \
		if(expr) { \
			MSG_IMAGEVIEW_WARN("[%s] Return", #expr );\
			return; \
		} \
	} while (0)

#define ivug_retv_if(expr, val) \
	do { \
		if(expr) { \
			MSG_IMAGEVIEW_WARN("[%s] Return value %d", #expr, val );\
			return (val); \
		} \
	} while (0)

#define ivug_retm_if(expr, fmt, args...) \
	do { \
		if(expr) { \
			MSG_IMAGEVIEW_WARN("[%s] Return, message "fmt, #expr, ##args );\
			return; \
		} \
	} while (0)

#define ivug_retvm_if(expr, val, fmt, args...) \
	do { \
		if(expr) { \
			MSG_IMAGEVIEW_WARN("[%s] Return value, message "fmt, #expr, ##args );\
			return (val); \
		} \
	} while (0)


#include "debug.h"


#endif //_IVUG_DEBUG_H_