2012/08/21: tizen 2.0 beta
[apps/home/call-setting.git] / include / cst-debug.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <dlog.h>
18 #include <stdio.h>
19
20 #ifndef CISS_LOG_TAG
21 #define CISS_LOG_TAG "CISS"
22 #endif
23
24 #define DBGFILE(fmt, arg...) \
25         do { \
26                         FILE *fp; \
27                         fp = fopen(CISS_DEBUG_FILE, "a"); \
28                         fprintf(fp, "[CISS][%s:%d] "fmt"\n",  __func__, __LINE__, ##arg); \
29                         if(fp) \
30                                 fclose(fp); \
31         } while(0)
32
33 #define DBG(fmt, arg...) \
34         do { \
35                 LOG(LOG_INFO, CISS_LOG_TAG, "[CISS][%s:%d] "fmt"\n",  __func__, __LINE__, ##arg); \
36         } while(0)
37
38 #define ENTER(arg...) \
39     do {\
40         LOG(LOG_INFO, CISS_LOG_TAG, "[CISS][%s:%d] Enter func=%p", __func__, __LINE__, ##arg);\
41     }while(0)
42
43 #define LEAVE() \
44     do {\
45         LOG(LOG_INFO, CISS_LOG_TAG, "[CISS][%s:%d] Leave func", __func__, __LINE__);\
46     } while(0)
47
48 #define ERR(fmt, arg...) \
49         do { \
50                 LOG(LOG_INFO, CISS_LOG_TAG, "[CISS][%s:%d] "fmt"\n",  __func__, __LINE__, ##arg); \
51         } while(0)
52
53 #define warn_if(expr, fmt, arg...) do { \
54                 if(expr) { \
55                         DBG("(%s) -> "fmt, #expr, ##arg); \
56                 } \
57         } while (0)
58
59 #define ret_if(expr) do { \
60                 if(expr) { \
61                         DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
62                         return; \
63                 } \
64         } while (0)
65
66 #define retv_if(expr, val) do { \
67                 if(expr) { \
68                         DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
69                         return (val); \
70                 } \
71         } while (0)
72
73 #define retm_if(expr, fmt, arg...) do { \
74                 if(expr) { \
75                         ERR(fmt, ##arg); \
76                         DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
77                         return; \
78                 } \
79         } while (0)
80
81 #define retvm_if(expr, val, fmt, arg...) do { \
82                 if(expr) { \
83                         ERR(fmt, ##arg); \
84                         DBG("(%s) -> %s() return", #expr, __FUNCTION__); \
85                         return (val); \
86                 } \
87         } while (0)
88