initial upload
[apps/native/smart-surveillance-camera.git] / include / log.h
1  /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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 #ifndef __LOG_H__
18 #define __LOG_H__
19
20 #include <strings.h>
21 #include <dlog.h>
22
23 #ifdef  LOG_TAG
24 #undef  LOG_TAG
25 #endif
26 #define LOG_TAG "SIV"
27
28 #if !defined(_D)
29 #define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s][%s:%d] " fmt "\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##arg)
30 #endif
31
32 #if !defined(_I)
33 #define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s][%s:%d] " fmt "\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##arg)
34 #endif
35
36 #if !defined(_W)
37 #define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s][%s:%d] " fmt "\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##arg)
38 #endif
39
40 #if !defined(_E)
41 #define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s][%s:%d] " fmt "\n", rindex(__FILE__, '/') + 1, __func__, __LINE__, ##arg)
42 #endif
43
44 #define retvm_if(expr, val, fmt, arg...) do { \
45         if (expr) { \
46                 _E(fmt, ##arg); \
47                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
48                 return val; \
49         } \
50 } while (0)
51
52 #define retv_if(expr, val) do { \
53         if (expr) { \
54                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
55                 return (val); \
56         } \
57 } while (0)
58
59 #define retm_if(expr, fmt, arg...) do { \
60         if (expr) { \
61                 _E(fmt, ##arg); \
62                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
63                 return; \
64         } \
65 } while (0)
66
67 #define ret_if(expr) do { \
68         if (expr) { \
69                 _E("(%s) -> %s() return", #expr, __FUNCTION__); \
70                 return; \
71         } \
72 } while (0)
73
74 #define goto_if(expr, val) do { \
75         if (expr) { \
76                 _E("(%s) -> goto", #expr); \
77                 goto val; \
78         } \
79 } while (0)
80
81 #define break_if(expr) { \
82         if (expr) { \
83                 _E("(%s) -> break", #expr); \
84                 break; \
85         } \
86 }
87
88 #define continue_if(expr) { \
89         if (expr) { \
90                 _E("(%s) -> continue", #expr); \
91                 continue; \
92         } \
93 }
94 #endif