Initialize Tizen 2.3
[apps/home/ug-setting-gallery-efl.git] / include / sg-debug.h
1 /*\r
2  * Copyright 2012  Samsung Electronics Co., Ltd\r
3  *\r
4  * Licensed under the Flora License, Version 1.1 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *        http://floralicense.org/license/\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 #ifndef __gallery_debug_H__\r
18 #define __gallery_debug_H__\r
19 \r
20 #define ENABLE_LOG_SYSTEM\r
21 \r
22 #ifdef ENABLE_LOG_SYSTEM\r
23 #define USE_DLOG_SYSTEM\r
24 \r
25 #ifdef USE_DLOG_SYSTEM\r
26 #include <dlog.h>\r
27 \r
28 #ifdef LOG_TAG\r
29 #undef LOG_TAG\r
30 #endif\r
31 \r
32 #define LOG_TAG "gallery-setting"\r
33 \r
34 #define gallery_debug(fmt, arg...) do{ \\r
35                         LOGD("[%s :%05d] "fmt "\n",__FUNCTION__, __LINE__,##arg);     \\r
36                 } while (0)\r
37 #define gallery_info(fmt, arg...) do{ \\r
38                         LOGI("[%s :%05d] "fmt "\n",__FUNCTION__, __LINE__,##arg);     \\r
39                 } while (0)\r
40 #define gallery_warn(fmt, arg...) do{ \\r
41                         LOGW("[%s :%05d] "fmt "\n",__FUNCTION__, __LINE__,##arg);     \\r
42                 } while (0)\r
43 #define gallery_error(fmt, arg...) do{ \\r
44                         LOGE("[%s :%05d] "fmt "\n",__FUNCTION__, __LINE__,##arg);     \\r
45                 } while (0)\r
46 \r
47 #define gallery_func_enter()    LOGD( "[%s: %05d] <<<< enter  \n", __func__, __LINE__)\r
48 #define gallery_func_leave()    LOGD( "[%s: %05d] >>>> leave  \n", __func__, __LINE__ )\r
49 \r
50 #else //USE_DLOG_SYSTEM\r
51 #define gallery_debug(fmt, arg...) do { \\r
52         fprintf(stderr,"[%s:%05d]  " fmt "\n",__func__, __LINE__, ##arg); \\r
53 } while(0)\r
54 \r
55 #define gallery_info(fmt, arg...) do { \\r
56         fprintf(stderr,"[%s:%05d]  " fmt "\n",__func__, __LINE__, ##arg); \\r
57 } while(0)\r
58 \r
59 #define gallery_warn(fmt, arg...) do { \\r
60         fprintf(stderr,"[%s:%05d]  " fmt "\n",__func__, __LINE__, ##arg); \\r
61 } while(0)\r
62 \r
63 #define gallery_error(fmt, arg...) do { \\r
64         fprintf(stderr,"[%s:%05d]  " fmt "\n",__func__, __LINE__, ##arg); \\r
65 } while(0)\r
66 #define gallery_func_enter()            fprintf(stdout, "[%s : %05d] <<< enter \n", __func__, __LINE__ , ##arg)\r
67 #define gallery_func_leave()            fprintf(stdout, "[%s : %05d] >>> leave \n", __func__, __LINE__ , ##arg)\r
68 \r
69 #endif // #ifdef USE_DLOG_SYSTEM\r
70 \r
71 #else //ENABLE_LOG_SYSTEM\r
72 #define gallery_debug(fmt, arg...)\r
73 #define gallery_info(fmt, arg...)\r
74 #define gallery_warn(fmt, arg...)\r
75 #define gallery_error(fmt, arg...)\r
76 #endif //ENABLE_LOG_SYSTEM\r
77 \r
78 \r
79 #define gallery_ret_if(expr) do { \\r
80         if(expr) { \\r
81                 return; \\r
82         } \\r
83 } while (0)\r
84 #define gallery_retv_if(expr, val) do { \\r
85         if(expr) { \\r
86                 return (val); \\r
87         } \\r
88 } while (0)\r
89 \r
90 #define gallery_retm_if(expr, fmt, arg...) do { \\r
91         if(expr) { \\r
92                 gallery_warn(fmt, ##arg); \\r
93                 return; \\r
94         } \\r
95 } while (0)\r
96 \r
97 #define gallery_retvm_if(expr, val, fmt, arg...) do { \\r
98         if(expr) { \\r
99                 gallery_warn(fmt, ##arg); \\r
100                 return (val); \\r
101         } \\r
102 } while (0)\r
103 \r
104 \r
105 #endif //__gallery_debug_H__\r
106 \r