summaryrefslogtreecommitdiff
path: root/include/ps_debug_util.h
blob: eb6b80071f4a8037bfa4bee8e5686d2c32854cb0 (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
/*
 * 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 __DEF_PS_DEBUG_UTIL_H__
#define __DEF_PS_DEBUG_UTIL_H__

#ifdef __ENABLE_DEBUG_UTIL

#include <assert.h>

#ifdef __ENABLE_PLATFORM_DEBUG

#include <dlog.h>

#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "SEARCH"

#define SEARCH_FUNC_START \
			do {\
				LOGD("[%s() START ----->]\n", __FUNCTION__);\
			}while(0)

#define SEARCH_FUNC_END \
			do {\
				LOGD("[%s() <----- END]\n", __FUNCTION__);\
			}while(0)

#define SEARCH_FUNC_LINE \
			do {\
				LOGD("[%s() \t%s:%d]\n", __FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
			}while(0)

#define SEARCH_DEBUG_LOG(fmt, arg...) \
			do {\
				LOGD("\x1b[32m[SEARCH][D][" fmt "]\x1b[0m\n", ##arg);\
			}while(0)

#define SEARCH_DEBUG_WARNING(fmt, arg...) \
			do {\
				LOGW("\x1b[33m[SEARCH][W][" fmt "]\x1b[0m\n", ##arg);\
			}while(0)

#define SEARCH_DEBUG_ERROR(fmt, arg...) \
			do {\
				LOGE("\x1b[31m[SEARCH][E][" fmt "]\x1b[0m\n", ##arg);\
			}while(0)

#define SEARCH_ASSERT_IF(cond) \
			do {\
				if(cond) {\
					LOGE("\x1b[31m[%s() \t%s:%d][ASSERT]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					assert(0);\
				}\
			}while(0)

#define SEARCH_RETV_IF(cond,ret) \
			do {\
				if(cond) {\
					LOGW("\x1b[33m[%s() \t%s:%d][RET_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					return ret;\
				}\
			}while(0)

#define SEARCH_RET_IF(cond) \
			do {\
				if(cond) {\
					LOGW("\x1b[33m[%s() \t%s:%d][RET_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					return;\
				}\
			}while(0)

#define SEARCH_RET_IF_STR_INVALID(str,ret) \
			do {\
				if((str == NULL) || strlen(str) == 0) {\
					LOGW("\x1b[33m[%s() \t%s:%d][RET_STR_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					return ret;\
				}\
			}while(0)

#else

#include <stdio.h>

#define SEARCH_FUNC_START \
			do {\
				fprintf(stderr, "[SEARCH][%s() START ----->]\n", __FUNCTION__);\
			}while(0)

#define SEARCH_FUNC_END \
			do {\
				fprintf("[SEARCH][%s() <----- END]\n", __FUNCTION__);\
			}while(0)

#define SEARCH_FUNC_LINE \
			do {\
				fprintf("[SEARCH][%s() \t%s:%d]\n", __FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
			}while(0)

#define SEARCH_DEBUG_LOG(fmt, arg...) \
			do {\
				fprintf(stderr, "[SEARCH][D][" fmt "\n", ##arg);\
			}while(0)

#define SEARCH_DEBUG_WARNING(fmt, arg...) \
			do {\
				fprintf(stderr, "[SEARCH][W][" fmt "\n", ##arg);\
			}while(0)

#define SEARCH_DEBUG_ERROR(fmt, arg...) \
			do {\
				fprintf(stderr, "[SEARCH][E][" fmt "\n", ##arg);\
			}while(0)

#define SEARCH_ASSERT_IF(cond) \
			do {\
				if(cond) {\
					fprintf(stderr, "[%s() \t%s:%d][ASSERT]",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					assert(0);\
				}\
			}while(0)

#define SEARCH_RETV_IF(cond,ret) \
			do {\
				if(cond) {\
					fprintf(stderr, "[%s() \t%s:%d][RET_IF]",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					return ret;\
				}\
			}while(0)

#define SEARCH_RET_IF(cond) \
			do {\
				if(cond) {\
					fprintf(stderr, "[%s() \t%s:%d][RET_IF]",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					return;\
				}\
			}while(0)

#define SEARCH_RET_IF_STR_INVALID(str,ret) \
			do {\
				if((str == NULL) || strlen(str) == 0) {\
					fprintf("\x1b[33m[%s() \t%s:%d][RET_STR_IF]\x1b[0m",__FUNCTION__, strrchr(__FILE__, '/')+1, __LINE__);\
					return ret;\
				}\
			}while(0)
			
#endif

#else

#define SEARCH_FUNC_START
#define SEARCH_FUNC_END
#define SEARCH_FUNC_LINE
#define SEARCH_DEBUG_LOG(fmt, arg...)
#define SEARCH_DEBUG_WARNING(fmt, arg...)
#define SEARCH_DEBUG_ERROR(fmt, arg...)
#define SEARCH_ASSERT_IF(cond)
#define SEARCH_RETV_IF(cond,ret)
#define SEARCH_RET_IF(cond)
#define SEARCH_RET_IF_STR_INVALID(str,ret)

#endif				// __ENABLE_DEBUG_UTIL

#endif				// __DEF_PS_DEBUG_UTIL_H__