Tizen 2.1 base
[apps/native/ug-bluetooth-efl.git] / include / bt-debug.h
1 /*
2  * Copyright (c) 2012-2013 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://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software 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 #ifndef __BT_DEBUG_H
18 #define __BT_DEBUG_H
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include <dlog.h>
25 #include <stdio.h>
26 #include <string.h>
27
28 #undef LOG_TAG
29 #define LOG_TAG "UG_SETTING_BLUETOOTH"
30
31 #define BT_INFO(fmt, arg...) SLOGI(fmt, ##arg)
32
33 #define BT_ERR(fmt, arg...) SLOGE(fmt, ##arg)
34
35 #define BT_DBG(fmt, arg...) SLOGD(fmt, ##arg)
36
37 #define FUNCTION_TRACE
38
39 #ifdef FUNCTION_TRACE
40 #define FN_START BT_DBG("[ENTER FUNC]");
41 #define FN_END BT_DBG("[EXIT FUNC]");
42 #else
43 #define FN_START
44 #define FN_END
45 #endif
46
47 #define warn_if(expr, fmt, arg...) \
48         do { \
49                 if (expr) { \
50                         BT_ERR("(%s) -> "fmt, #expr, ##arg); \
51                 } \
52         } while (0);
53
54 #define ret_if(expr) \
55         do { \
56                 if (expr) { \
57                         BT_ERR("(%s) return", #expr); \
58                         return; \
59                 } \
60         } while (0);
61
62 #define retv_if(expr, val) \
63         do { \
64                 if (expr) { \
65                         BT_ERR("(%s) return", #expr); \
66                         return (val); \
67                 } \
68         } while (0);
69
70 #define retm_if(expr, fmt, arg...) \
71         do { \
72                 if (expr) { \
73                         BT_ERR(fmt, ##arg); \
74                         BT_ERR("(%s) return", #expr); \
75                         return; \
76                 } \
77         } while (0);
78
79 #define retvm_if(expr, val, fmt, arg...) \
80         do { \
81                 if (expr) { \
82                         BT_ERR(fmt, ##arg); \
83                         BT_ERR("(%s) return", #expr); \
84                         return (val); \
85                 } \
86         } while (0);
87
88 #ifdef __cplusplus
89 }
90 #endif
91 #endif                          /* __BT_DEBUG_H */