03501244930627561cef347a6f3c51bc5c527f8b
[platform/core/appfw/pkgmgr-info.git] / include / pkgmgrinfo_debug.h
1 /*
2  * pkgmgrinfo_debug
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6   * Contact: junsuk. oh <junsuk77.oh@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #ifndef __PKGMGR_INFO_DEBUG_H__
23 #define __PKGMGR_INFO_DEBUG_H__
24
25 #include <dlog.h>
26
27 #define _LOGE(fmt, arg...) LOGE(fmt, ##arg)
28 #define _LOGI(fmt, arg...) LOGI(fmt, ##arg)
29 #define _LOGD(fmt, arg...) LOGD(fmt, ##arg)
30
31 #define PKGMGR_INFO_ENABLE_DLOG
32
33 #define COLOR_RED               "\033[0;31m"
34 #define COLOR_BLUE              "\033[0;34m"
35 #define COLOR_END               "\033[0;m"
36
37 #ifdef PKGMGR_INFO_ENABLE_DLOG
38 #define PKGMGR_INFO_DEBUG(fmt, ...)\
39         do\
40         {\
41                 LOGD(fmt, ##__VA_ARGS__);\
42         } while (0)
43
44 #define PKGMGR_INFO_DEBUG_ERR(fmt, ...)\
45         do\
46         {\
47                 LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__);\
48         }while (0)
49
50 #define PKGMGR_INFO_BEGIN() \
51         do\
52     {\
53                 LOGD(COLOR_BLUE"BEGIN >>>>"COLOR_END);\
54     } while( 0 )
55
56 #define PKGMGR_INFO_END() \
57         do\
58     {\
59                 LOGD(COLOR_BLUE"END <<<<"COLOR_END);\
60     } \
61     while( 0 )
62
63 #else
64 #define PKGMGR_INFO_DEBUG(fmt, ...) \
65         do\
66         {\
67                 printf("\n [%s: %s(): %d] " fmt"\n",  rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
68         } while (0)
69
70 #define PKGMGR_INFO_BEGIN() \
71         do\
72     {\
73         printf("\n [%s: %d] : BEGIN >>>> %s() \n", rindex(__FILE__, '/')+1,  __LINE__ , __FUNCTION__);\
74     } while( 0 )
75
76 #define PKGMGR_INFO_END() \
77         do\
78     {\
79         printf("\n [%s: %d]: END   <<<< %s()\n", rindex(__FILE__, '/')+1,  __LINE__ , __FUNCTION__); \
80     } \
81     while( 0 )
82 #endif
83
84
85 #define ret_if(expr) do { \
86         if (expr) { \
87                 PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
88                 return; \
89         } \
90 } while (0)
91
92 #define retm_if(expr, fmt, arg...) do { \
93         if (expr) { \
94                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
95                 return; \
96         } \
97 } while (0)
98
99 #define retv_if(expr, val) do { \
100         if (expr) { \
101                 PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
102                 return (val); \
103         } \
104 } while (0)
105
106 #define retvm_if(expr, val, fmt, arg...) do { \
107         if (expr) { \
108                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
109                 return (val); \
110         } \
111 } while (0)
112
113 #define trym_if(expr, fmt, arg...) do { \
114         if (expr) { \
115                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
116                 goto catch; \
117         } \
118 } while (0)
119
120 #define tryvm_if(expr, val, fmt, arg...) do { \
121         if (expr) { \
122                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
123                 val; \
124                 goto catch; \
125         } \
126 } while (0)
127
128 #endif  /* __PKGMGR_INFO_DEBUG_H__ */