Release version 1.1.5
[platform/core/appfw/appcore-widget.git] / src / widget-log.h
1 /*
2  * Copyright (c) 2015 - 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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
18 #ifndef __APPFW_WIDGET_LOG_H__
19 #define __APPFW_WIDGET_LOG_H__
20
21 #include <dlog.h>
22
23 #define _E(fmt, arg...) LOGE(fmt, ##arg)
24 #define _I(fmt, arg...) LOGI(fmt, ##arg)
25 #define _D(fmt, arg...) LOGD(fmt, ##arg)
26 #define _W(fmt, arg...) LOGW(fmt, ##arg)
27
28 #ifndef EXPORT_API
29 #define EXPORT_API __attribute__ ((visibility("default")))
30 #endif
31
32 #ifndef _E
33 #define _E(fmt, arg...) LOGE(fmt, ##arg)
34 #endif
35
36 #ifndef _I
37 #define _I(...) LOGI(__VA_ARGS__)
38 #endif
39
40 #ifndef _D
41 #define _D(...) LOGD(__VA_ARGS__)
42 #endif
43
44 #ifndef _W
45 #define _W(...) LOGW(__VA_ARGS__)
46 #endif
47
48 #define _warn_if(expr, fmt, arg...)             \
49         do {                                    \
50                 if (expr)                       \
51                         _ERR(fmt, ##arg);       \
52         } while (0)
53
54 #define _ret_if(expr)                           \
55         do {                                    \
56                 if (expr)                       \
57                         return;                 \
58         } while (0)
59
60 #define _retv_if(expr, val)                     \
61         do {                                    \
62                 if (expr)                       \
63                         return (val);           \
64         } while (0)
65
66 #define _retm_if(expr, fmt, arg...)             \
67         do {                                    \
68                 if (expr) {                     \
69                         _ERR(fmt, ##arg);       \
70                         return;                 \
71                 }                               \
72         } while (0)
73
74 #define _retvm_if(expr, val, fmt, arg...)       \
75         do {                                    \
76                 if (expr) {                     \
77                         _ERR(fmt, ##arg);       \
78                         return (val);           \
79                 }                               \
80         } while (0)
81
82 #endif /* __APPFW_WIDGET_LOG_H_ */
83