Init master branch with timer code
[apps/native/st-things-light.git] / inc / log.h
1 /* ****************************************************************
2  *
3  * Copyright 2017 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  ******************************************************************/
18 #ifndef __LOG_H__
19 #define  __LOG_H__
20
21 #include <dlog.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #ifdef LOG_TAG
28 #undef LOG_TAG
29 #endif
30 #define LOG_TAG "SMART_LIGHT"
31
32 #define _E(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args)
33 #define _W(fmt, args...) dlog_print(DLOG_WARN, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args)
34 #define _I(fmt, args...)  dlog_print(DLOG_INFO, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args)
35 #define _D(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s : %s(%d) > "fmt"\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##args)
36
37 #define FN_CALL dlog_print(DLOG_DEBUG, LOG_TAG, ">>>>>>>> %s() called\n", __func__)
38 #define FN_END dlog_print(DLOG_DEBUG, LOG_TAG, "<<<<<<<< %s() ended\n", __func__)
39
40
41 #define retvm_if(expr, val, fmt, arg...) do { \
42         if (expr) { \
43                 _E(fmt, ##arg); \
44                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
45                 return val; \
46         } \
47 } while (0)
48
49 #define retv_if(expr, val) do { \
50         if (expr) { \
51                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
52                 return (val); \
53         } \
54 } while (0)
55
56 #define retm_if(expr, fmt, arg...) do { \
57         if (expr) { \
58                 _E(fmt, ##arg); \
59                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
60                 return; \
61         } \
62 } while (0)
63
64 #define ret_if(expr) do { \
65         if (expr) { \
66                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
67                 return; \
68         } \
69 } while (0)
70
71 #define goto_if(expr, val) do { \
72         if (expr) { \
73                 _E("(%s) -> goto", #expr); \
74                 goto val; \
75         } \
76 } while (0)
77
78 #define break_if(expr) { \
79         if (expr) { \
80                 _E("(%s) -> break", #expr); \
81                 break; \
82         } \
83 }
84
85 #define continue_if(expr) { \
86         if (expr) { \
87                 _E("(%s) -> continue", #expr); \
88                 continue; \
89         } \
90 }
91
92 #ifdef __cplusplus
93 }
94 #endif
95
96 #endif /* __LOG_H__ */
97