Change how to check pkginfo server ready flag
[platform/core/appfw/pkgmgr-info.git] / src / 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 #undef LOG_TAG
28 #define LOG_TAG "PKGMGR_INFO"
29
30 #define _LOGE(fmt, arg...) LOGE(fmt, ##arg)
31 #define _LOGI(fmt, arg...) LOGI(fmt, ##arg)
32 #define _LOGD(fmt, arg...) LOGD(fmt, ##arg)
33
34 #define PKGMGR_INFO_ENABLE_DLOG
35
36 #define COLOR_RED               "\033[0;31m"
37 #define COLOR_BLUE              "\033[0;34m"
38 #define COLOR_END               "\033[0;m"
39
40 #ifdef PKGMGR_INFO_ENABLE_DLOG
41 #define PKGMGR_INFO_DEBUG(fmt, ...) \
42         do { \
43                 LOGD(fmt, ##__VA_ARGS__); \
44         } while (0)
45
46 #define PKGMGR_INFO_DEBUG_ERR(fmt, ...) \
47         do { \
48                 LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
49         } while (0)
50
51 #define PKGMGR_INFO_BEGIN() \
52         do { \
53                 LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
54         } while (0)
55
56 #define PKGMGR_INFO_END() \
57         do { \
58                 LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
59         } while (0)
60
61 #else
62 #define PKGMGR_INFO_DEBUG(fmt, ...) \
63         do { \
64                 printf("\n [%s: %s(): %d] " fmt"\n",  rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
65         } while (0)
66
67 #define PKGMGR_INFO_BEGIN() \
68         do { \
69                 printf("\n [%s: %d] : BEGIN >>>> %s() \n", rindex(__FILE__, '/')+1,  __LINE__ , __FUNCTION__); \
70         } while (0)
71
72 #define PKGMGR_INFO_END() \
73         do { \
74                 printf("\n [%s: %d]: END   <<<< %s()\n", rindex(__FILE__, '/')+1,  __LINE__ , __FUNCTION__); \
75         } while (0)
76 #endif
77
78
79 #define ret_if(expr) do { \
80         if (expr) { \
81                 PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
82                 return; \
83         } \
84 } while (0)
85
86 #define retm_if(expr, fmt, arg...) do { \
87         if (expr) { \
88                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
89                 return; \
90         } \
91 } while (0)
92
93 #define retv_if(expr, val) do { \
94         if (expr) { \
95                 PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
96                 return (val); \
97         } \
98 } while (0)
99
100 #define retvm_if(expr, val, fmt, arg...) do { \
101         if (expr) { \
102                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
103                 return (val); \
104         } \
105 } while (0)
106
107 #define trym_if(expr, fmt, arg...) do { \
108         if (expr) { \
109                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
110                 goto catch; \
111         } \
112 } while (0)
113
114 #define tryvm_if(expr, val, fmt, arg...) do { \
115         if (expr) { \
116                 PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
117                 val; \
118                 goto catch; \
119         } \
120 } while (0)
121
122 #endif  /* __PKGMGR_INFO_DEBUG_H__ */