b81f948261682621cd57af2aa7fdbf2e33ece862
[platform/core/appfw/slp-pkgmgr.git] / client / src / pkgmgr_client_debug.h
1 /*
2  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4   * Contact: junsuk. oh <junsuk77.oh@samsung.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __PKGMGR_CLIENT_DEBUG_H__
21 #define __PKGMGR_CLIENT_DEBUG_H__
22
23 #include <dlog.h>
24
25 #ifdef LOG_TAG
26 #undef LOG_TAG
27 #endif /* LOG_TAG */
28 #define LOG_TAG "PKGMGR"
29
30 #ifndef ERR
31 #define ERR(fmt, args...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
32 #endif
33
34 #ifndef DBG
35 #define DBG(fmt, args...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
36 #endif
37
38 #ifndef INFO
39 #define INFO(fmt, args...) LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
40 #endif
41
42 #define ret_if(expr) \
43         do { \
44                 if (expr) { \
45                         ERR("(%s) ", #expr); \
46                         return; \
47                 } \
48         } while (0)
49
50 #define retm_if(expr, fmt, arg...) \
51         do { \
52                 if (expr) { \
53                         ERR("(%s) "fmt, #expr, ##arg); \
54                         return; \
55                 } \
56         } while (0)
57
58 #define retv_if(expr, val) \
59         do { \
60                 if (expr) { \
61                         ERR("(%s) ", #expr); \
62                         return (val); \
63                 } \
64         } while (0)
65
66 #define retvm_if(expr, val, fmt, arg...) \
67         do { \
68                 if (expr) { \
69                         ERR("(%s) "fmt, #expr, ##arg); \
70                         return (val); \
71                 } \
72         } while (0)
73
74 #define trym_if(expr, fmt, arg...) \
75         do { \
76                 if (expr) { \
77                         ERR("(%s) "fmt, #expr, ##arg); \
78                         goto catch; \
79                 } \
80         } while (0)
81
82 #define tryvm_if(expr, val, fmt, arg...) \
83         do { \
84                 if (expr) { \
85                         ERR("(%s) "fmt, #expr, ##arg); \
86                         val; \
87                         goto catch; \
88                 } \
89         } while (0)
90
91 #endif  /* __PKGMGR_CLIENT_DEBUG_H__ */