[cleanup] revise file location
[platform/core/connectivity/bluetooth-share.git] / app / applog.h
1 /*
2  * bluetooth-share
3  *
4  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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 __APPLOG_H__
21 #define __APPLOG_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /*
28  * SYSLOG_INFO(), SYSLOG_ERR(), SYSLOG_DBG() are syslog() wrappers.
29  * PRT_INFO(), PRT_ERR(), PRT_DBG() are fprintf() wrappers.
30  *
31  * If SLP_DEBUG is not defined, SYSLOG_DBG() and PRT_DBG() is ignored.
32  *
33  * IF SLP_SYSLOG_OUT or SLP_DAEMON is defined,
34  *   INFO(), ERR(), DBG() are SYSLOG_XXX()
35  * Otherwise,
36  *   They are PRT_XXX()
37  *
38  *
39  * warn_if(exrp, fmt, ...)
40  *   If expr is true, The fmt string is printed using ERR().
41  *
42  * ret_if(), retv_if(), retm_if(), retvm_if()
43  *   If expr is true, current function return.
44  *   Postfix 'v' means that it has a return value and
45  *   'm' means that it has output message.
46  *
47  */
48
49 #include <stdio.h>
50 #include <dlog.h>
51
52 #undef LOG_TAG
53 #define LOG_TAG "BLUETOOTH_SHARE"
54
55 #define INFO(fmt, arg...) \
56         SLOGI(fmt, ##arg)
57
58 #define ERR(fmt, arg...) \
59         SLOGE(fmt, ##arg)
60
61 #define DBG(fmt, arg...) \
62         SLOGD(fmt, ##arg)
63
64 #define FN_START DBG("[ENTER FUNC]");
65 #define FN_END DBG("[EXIT FUNC]");
66
67 #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
68 #define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
69 #define INFO_SECURE(fmt, args...) SECURE_SLOGI(fmt, ##args)
70
71 #define warn_if(expr, fmt, arg...) do { \
72                 if (expr) { \
73                         ERR(fmt, ##arg); \
74                 } \
75         } while (0)
76
77 #define ret_if(expr) do { \
78                 if (expr) { \
79                         return; \
80                 } \
81         } while (0)
82
83 #define retv_if(expr, val) do { \
84                 if (expr) { \
85                         return (val); \
86                 } \
87         } while (0)
88
89 #define retm_if(expr, fmt, arg...) do { \
90                 if (expr) { \
91                         ERR(fmt, ##arg); \
92                         return; \
93                 } \
94         } while (0)
95
96 #define retvm_if(expr, val, fmt, arg...) do { \
97                 if (expr) { \
98                         ERR(fmt, ##arg); \
99                         return (val); \
100                 } \
101         } while (0)
102
103 #ifdef __cplusplus
104 }
105 #endif
106 #endif                          /* __APPLOG_H__ */