4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef _MMFILE_DEBUG_H_
23 #define _MMFILE_DEBUG_H_
35 #define LOG_TAG "MM_FILEINFO"
39 #ifdef __MMFILE_TEST_MODE__
45 #define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
46 #define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
48 /*#define LOG_COLOR */
51 #define FONT_COLOR_RESET "\033[0m"
52 #define FONT_COLOR_RED "\033[31m"
53 #define FONT_COLOR_GREEN "\033[32m"
54 #define FONT_COLOR_YELLOW "\033[33m"
55 #define FONT_COLOR_BLUE "\033[34m"
56 #define FONT_COLOR_PURPLE "\033[35m"
57 #define FONT_COLOR_CYAN "\033[36m"
58 #define FONT_COLOR_GRAY "\033[37m"
60 #define debug_log(mode, fmt, arg...) do { \
61 if (mode == DEBUG) { \
62 LOGD(FONT_COLOR_RESET fmt, ##arg); \
63 } else if (mode == RELEASE) { \
64 if (DEBUG_MODE == 1) \
65 LOGD(FONT_COLOR_RESET fmt, ##arg); \
69 #define debug_msg(mode, fmt, arg...) do { \
70 if (mode == DEBUG) { \
71 LOGD(FONT_COLOR_RESET fmt, ##arg); \
72 } else if (mode == RELEASE) { \
73 if (DEBUG_MODE == 1) \
74 LOGD(FONT_COLOR_RESET fmt, ##arg); \
78 #define debug_warning(mode, fmt, arg...) do { \
79 if (mode == DEBUG) { \
80 LOGW(FONT_COLOR_GREEN fmt, ##arg); \
81 } else if (mode == RELEASE) { \
82 if (DEBUG_MODE == 1) \
83 LOGW(FONT_COLOR_GREEN fmt, ##arg); \
87 #define debug_error(mode, fmt, arg...) do { \
88 if (mode == DEBUG) { \
89 LOGE(FONT_COLOR_RED fmt, ##arg); \
90 } else if (mode == RELEASE) { \
91 if (DEBUG_MODE == 1) \
92 LOGE(FONT_COLOR_RED fmt, ##arg); \
96 #define debug_fenter(mode) do { \
97 if (mode == DEBUG) { \
98 LOGE(FONT_COLOR_RESET "<ENTER> \n"); \
99 } else if (mode == RELEASE) { \
100 if (DEBUG_MODE == 1) \
101 LOGE(FONT_COLOR_RESET "<ENTER> \n"); \
105 #define debug_fleave(mode) do { \
106 if (mode == DEBUG) { \
107 LOGE(FONT_COLOR_RESET "<LEAVE> \n"); \
108 } else if (mode == RELEASE) { \
109 if (DEBUG_MODE == 1) \
110 LOGE(FONT_COLOR_RESET "<LEAVE> \n"); \
116 #define debug_log(mode, fmt, arg...) do { \
117 if (mode == DEBUG) { \
118 LOGD(" "fmt"", ##arg); \
119 } else if (mode == RELEASE) { \
120 if (DEBUG_MODE == 1) \
121 LOGD(" "fmt"", ##arg); \
125 #define debug_msg(mode, fmt, arg...) do { \
126 if (mode == DEBUG) { \
127 LOGD(" "fmt"", ##arg); \
128 } else if (mode == RELEASE) { \
129 if (DEBUG_MODE == 1) \
130 LOGD(" "fmt"", ##arg); \
134 #define debug_warning(mode, fmt, arg...) do { \
135 if (mode == DEBUG) { \
136 LOGW(" "fmt"", ##arg); \
137 } else if (mode == RELEASE) { \
138 if (DEBUG_MODE == 1) \
139 LOGW(" "fmt"", ##arg); \
143 #define debug_error(mode, fmt, arg...) do { \
144 if (mode == DEBUG) { \
145 LOGE(" "fmt"", ##arg); \
146 } else if (mode == RELEASE) { \
147 if (DEBUG_MODE == 1) \
148 LOGE(" "fmt"", ##arg); \
152 #define debug_fenter(mode) do { \
153 if (mode == DEBUG) { \
154 LOGE("<ENTER> \n"); \
155 } else if (mode == RELEASE) { \
156 if (DEBUG_MODE == 1) \
157 LOGE("<ENTER> \n"); \
161 #define debug_fleave(mode) do { \
162 if (mode == DEBUG) { \
163 LOGE("<LEAVE> \n"); \
164 } else if (mode == RELEASE) { \
165 if (DEBUG_MODE == 1) \
166 LOGE("<LEAVE> \n"); \
171 #define mm_file_retv_if_fails(expr, val) do { \
177 #define mm_file_retvm_if_fails(mode, expr, val) do { \
179 debug_error(mode, "ERROR [%s]", #expr); \
188 #endif /* _MMFILE_DEBUG_H_ */